diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/CHANGELOG.md b/sdk/resourcemanager/applicationinsights/armapplicationinsights/CHANGELOG.md index b39482611510..994e71c965fc 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/CHANGELOG.md +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/CHANGELOG.md @@ -1,10 +1,12 @@ # Release History -## 2.0.0-beta.3 (2025-03-07) +## 2.0.0 (2026-05-20) ### Breaking Changes -- Enum `Kind` has been removed -- Enum `MyWorkbookManagedIdentityType` has been removed +- Function `*WorkbooksClient.Update` parameter(s) have been changed from `(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook, options *WorkbooksClientUpdateOptions)` to `(ctx context.Context, resourceGroupName string, resourceName string, workbookUpdateParameters WorkbookUpdateParameters, options *WorkbooksClientUpdateOptions)` +- Type of `Workbook.Kind` has been changed from `*SharedTypeKind` to `*WorkbookSharedTypeKind` +- Type of `WorkbookProperties.TimeModified` has been changed from `*string` to `*time.Time` +- Enum `SharedTypeKind` has been removed - Function `*ClientFactory.NewMyWorkbooksClient` has been removed - Function `NewMyWorkbooksClient` has been removed - Function `*MyWorkbooksClient.CreateOrUpdate` has been removed @@ -13,43 +15,92 @@ - Function `*MyWorkbooksClient.NewListByResourceGroupPager` has been removed - Function `*MyWorkbooksClient.NewListBySubscriptionPager` has been removed - Function `*MyWorkbooksClient.Update` has been removed -- Struct `ErrorDefinition` has been removed -- Struct `InnerErrorTrace` has been removed +- Struct `AnnotationError` has been removed +- Struct `ComponentsResource` has been removed +- Struct `ErrorFieldContract` has been removed +- Struct `ErrorResponse` has been removed +- Struct `ErrorResponseComponents` has been removed +- Struct `ErrorResponseComponentsError` has been removed +- Struct `InnerError` has been removed +- Struct `LinkProperties` has been removed - Struct `MyWorkbook` has been removed - Struct `MyWorkbookError` has been removed -- Struct `MyWorkbookManagedIdentity` has been removed - Struct `MyWorkbookProperties` has been removed - Struct `MyWorkbookResource` has been removed -- Struct `MyWorkbookUserAssignedIdentities` has been removed - Struct `MyWorkbooksListResult` has been removed -- Field `InnerError` of struct `WorkbookErrorDefinition` has been removed +- Struct `WebtestsResource` has been removed +- Struct `WorkItemConfigurationError` has been removed +- Struct `WorkbookError` has been removed +- Struct `WorkbookResource` has been removed +- Field `Name`, `SharedTypeKind`, `SourceResourceID`, `WorkbookID` of struct `WorkbookProperties` has been removed ### Features Added - New value `WebTestKindStandard` added to enum type `WebTestKind` +- New enum type `CreatedByType` with values `CreatedByTypeApplication`, `CreatedByTypeKey`, `CreatedByTypeManagedIdentity`, `CreatedByTypeUser` +- New enum type `ManagedServiceIdentityType` with values `ManagedServiceIdentityTypeNone`, `ManagedServiceIdentityTypeSystemAssigned`, `ManagedServiceIdentityTypeSystemAssignedUserAssigned`, `ManagedServiceIdentityTypeUserAssigned` +- New enum type `StorageType` with values `StorageTypeServiceProfiler` +- New enum type `WorkbookSharedTypeKind` with values `WorkbookSharedTypeKindShared` +- New enum type `WorkbookUpdateSharedTypeKind` with values `WorkbookUpdateSharedTypeKindShared` +- New function `*ClientFactory.NewComponentLinkedStorageAccountsClient() *ComponentLinkedStorageAccountsClient` - New function `*ClientFactory.NewDeletedWorkbooksClient() *DeletedWorkbooksClient` +- New function `*ClientFactory.NewLiveTokenClient() *LiveTokenClient` - New function `*ClientFactory.NewOperationsClient() *OperationsClient` -- New function `NewDeletedWorkbooksClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DeletedWorkbooksClient, error)` -- New function `*DeletedWorkbooksClient.NewListBySubscriptionPager(*DeletedWorkbooksClientListBySubscriptionOptions) *runtime.Pager[DeletedWorkbooksClientListBySubscriptionResponse]` -- New function `NewOperationsClient(azcore.TokenCredential, *arm.ClientOptions) (*OperationsClient, error)` -- New function `*OperationsClient.NewListPager(*OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse]` +- New function `*ClientFactory.NewWorkbookTemplatesClient() *WorkbookTemplatesClient` +- New function `NewComponentLinkedStorageAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ComponentLinkedStorageAccountsClient, error)` +- New function `*ComponentLinkedStorageAccountsClient.CreateAndUpdate(ctx context.Context, resourceGroupName string, resourceName string, storageType StorageType, linkedStorageAccountsProperties ComponentLinkedStorageAccounts, options *ComponentLinkedStorageAccountsClientCreateAndUpdateOptions) (ComponentLinkedStorageAccountsClientCreateAndUpdateResponse, error)` +- New function `*ComponentLinkedStorageAccountsClient.Delete(ctx context.Context, resourceGroupName string, resourceName string, storageType StorageType, options *ComponentLinkedStorageAccountsClientDeleteOptions) (ComponentLinkedStorageAccountsClientDeleteResponse, error)` +- New function `*ComponentLinkedStorageAccountsClient.Get(ctx context.Context, resourceGroupName string, resourceName string, storageType StorageType, options *ComponentLinkedStorageAccountsClientGetOptions) (ComponentLinkedStorageAccountsClientGetResponse, error)` +- New function `*ComponentLinkedStorageAccountsClient.Update(ctx context.Context, resourceGroupName string, resourceName string, storageType StorageType, linkedStorageAccountsProperties ComponentLinkedStorageAccountsPatch, options *ComponentLinkedStorageAccountsClientUpdateOptions) (ComponentLinkedStorageAccountsClientUpdateResponse, error)` +- New function `NewDeletedWorkbooksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeletedWorkbooksClient, error)` +- New function `*DeletedWorkbooksClient.NewListBySubscriptionPager(options *DeletedWorkbooksClientListBySubscriptionOptions) *runtime.Pager[DeletedWorkbooksClientListBySubscriptionResponse]` +- New function `NewLiveTokenClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*LiveTokenClient, error)` +- New function `*LiveTokenClient.Get(ctx context.Context, resourceURI string, options *LiveTokenClientGetOptions) (LiveTokenClientGetResponse, error)` +- New function `NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error)` +- New function `*OperationsClient.NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse]` +- New function `NewWorkbookTemplatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkbookTemplatesClient, error)` +- New function `*WorkbookTemplatesClient.CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookTemplateProperties WorkbookTemplate, options *WorkbookTemplatesClientCreateOrUpdateOptions) (WorkbookTemplatesClientCreateOrUpdateResponse, error)` +- New function `*WorkbookTemplatesClient.Delete(ctx context.Context, resourceGroupName string, resourceName string, options *WorkbookTemplatesClientDeleteOptions) (WorkbookTemplatesClientDeleteResponse, error)` +- New function `*WorkbookTemplatesClient.Get(ctx context.Context, resourceGroupName string, resourceName string, options *WorkbookTemplatesClientGetOptions) (WorkbookTemplatesClientGetResponse, error)` +- New function `*WorkbookTemplatesClient.NewListByResourceGroupPager(resourceGroupName string, options *WorkbookTemplatesClientListByResourceGroupOptions) *runtime.Pager[WorkbookTemplatesClientListByResourceGroupResponse]` +- New function `*WorkbookTemplatesClient.Update(ctx context.Context, resourceGroupName string, resourceName string, workbookTemplateUpdateParameters WorkbookTemplateUpdateParameters, options *WorkbookTemplatesClientUpdateOptions) (WorkbookTemplatesClientUpdateResponse, error)` +- New function `*WorkbooksClient.NewListBySubscriptionPager(category CategoryType, options *WorkbooksClientListBySubscriptionOptions) *runtime.Pager[WorkbooksClientListBySubscriptionResponse]` +- New function `*WorkbooksClient.RevisionGet(ctx context.Context, resourceGroupName string, resourceName string, revisionID string, options *WorkbooksClientRevisionGetOptions) (WorkbooksClientRevisionGetResponse, error)` +- New function `*WorkbooksClient.NewRevisionsListPager(resourceGroupName string, resourceName string, options *WorkbooksClientRevisionsListOptions) *runtime.Pager[WorkbooksClientRevisionsListResponse]` +- New struct `ComponentLinkedStorageAccounts` +- New struct `ComponentLinkedStorageAccountsPatch` - New struct `DeletedWorkbook` -- New struct `DeletedWorkbookError` -- New struct `DeletedWorkbookErrorDefinition` -- New struct `DeletedWorkbookInnerErrorTrace` - New struct `DeletedWorkbookProperties` -- New struct `DeletedWorkbookResource` - New struct `DeletedWorkbooksListResult` -- New struct `ErrorFieldContract` - New struct `HeaderField` -- New struct `ResourceAutoGenerated` -- New struct `TrackedResourceAutoGenerated` +- New struct `LinkedStorageAccountsProperties` +- New struct `LiveTokenResponse` +- New struct `SystemData` +- New struct `UserAssignedIdentity` - New struct `WebTestPropertiesRequest` - New struct `WebTestPropertiesValidationRules` - New struct `WebTestPropertiesValidationRulesContentValidation` -- New field `Details` in struct `ErrorResponse` +- New struct `WorkbookPropertiesUpdateParameters` +- New struct `WorkbookResourceIdentity` +- New struct `WorkbookTemplate` +- New struct `WorkbookTemplateGallery` +- New struct `WorkbookTemplateLocalizedGallery` +- New struct `WorkbookTemplateProperties` +- New struct `WorkbookTemplateUpdateParameters` +- New struct `WorkbookTemplatesListResult` +- New struct `WorkbookUpdateParameters` +- New field `NextLink` in struct `AnnotationsListResult` +- New field `NextLink` in struct `ComponentAPIKeyListResult` +- New field `NextLink` in struct `WebTestLocationsListResult` - New field `Request`, `ValidationRules` in struct `WebTestProperties` -- New field `Innererror` in struct `WorkbookErrorDefinition` +- New field `NextLink` in struct `WorkItemConfigurationsListResult` +- New field `Etag`, `Identity`, `SystemData` in struct `Workbook` +- New field `Description`, `DisplayName`, `Revision`, `SourceID`, `StorageURI` in struct `WorkbookProperties` +- New field `SourceID` in struct `WorkbooksClientCreateOrUpdateOptions` +- New field `CanFetchContent` in struct `WorkbooksClientGetOptions` +- New field `SourceID` in struct `WorkbooksClientListByResourceGroupOptions` +- New field `SourceID` in struct `WorkbooksClientUpdateOptions` +- New field `NextLink` in struct `WorkbooksListResult` ## 1.2.0 (2023-11-24) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/analyticsitems_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/analyticsitems_client.go index 788f35efb1c4..8068f83f292c 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/analyticsitems_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/analyticsitems_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -20,15 +19,17 @@ import ( // AnalyticsItemsClient contains the methods for the AnalyticsItems group. // Don't use this type directly, use NewAnalyticsItemsClient() instead. +// +// Generated from API version 2015-05-01 type AnalyticsItemsClient struct { internal *arm.Client subscriptionID string } // NewAnalyticsItemsClient creates a new instance of AnalyticsItemsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewAnalyticsItemsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AnalyticsItemsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -43,8 +44,6 @@ func NewAnalyticsItemsClient(subscriptionID string, credential azcore.TokenCrede // Delete - Deletes a specific Analytics Items defined within an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - scopePath - Enum indicating if this item definition is owned by a specific user or is shared between all users with access @@ -95,21 +94,19 @@ func (client *AnalyticsItemsClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") + reqQP.Set("api-version", version20150501) if options != nil && options.ID != nil { reqQP.Set("id", *options.ID) } if options != nil && options.Name != nil { reqQP.Set("name", *options.Name) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // Get - Gets a specific Analytics Items defined within an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - scopePath - Enum indicating if this item definition is owned by a specific user or is shared between all users with access @@ -161,14 +158,14 @@ func (client *AnalyticsItemsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") + reqQP.Set("api-version", version20150501) if options != nil && options.ID != nil { reqQP.Set("id", *options.ID) } if options != nil && options.Name != nil { reqQP.Set("name", *options.Name) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -184,8 +181,6 @@ func (client *AnalyticsItemsClient) getHandleResponse(resp *http.Response) (Anal // List - Gets a list of Analytics Items defined within an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - scopePath - Enum indicating if this item definition is owned by a specific user or is shared between all users with access @@ -237,7 +232,7 @@ func (client *AnalyticsItemsClient) listCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") + reqQP.Set("api-version", version20150501) if options != nil && options.IncludeContent != nil { reqQP.Set("includeContent", strconv.FormatBool(*options.IncludeContent)) } @@ -247,7 +242,7 @@ func (client *AnalyticsItemsClient) listCreateRequest(ctx context.Context, resou if options != nil && options.Type != nil { reqQP.Set("type", string(*options.Type)) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -263,8 +258,6 @@ func (client *AnalyticsItemsClient) listHandleResponse(resp *http.Response) (Ana // Put - Adds or Updates a specific Analytics Item within an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - scopePath - Enum indicating if this item definition is owned by a specific user or is shared between all users with access @@ -317,12 +310,13 @@ func (client *AnalyticsItemsClient) putCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") + reqQP.Set("api-version", version20150501) if options != nil && options.OverrideItem != nil { reqQP.Set("overrideItem", strconv.FormatBool(*options.OverrideItem)) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, itemProperties); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/analyticsitems_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/analyticsitems_client_example_test.go index d11fe8e3e339..6ea9471f4262 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/analyticsitems_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/analyticsitems_client_example_test.go @@ -1,192 +1,196 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AnalyticsItemList.json -func ExampleAnalyticsItemsClient_List() { +// Generated from example definition: 2015-05-01/AnalyticsItemDelete.json +func ExampleAnalyticsItemsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAnalyticsItemsClient().List(ctx, "my-resource-group", "my-component", armapplicationinsights.ItemScopePathAnalyticsItems, &armapplicationinsights.AnalyticsItemsClientListOptions{Scope: nil, - Type: nil, - IncludeContent: nil, - }) + res, err := clientFactory.NewAnalyticsItemsClient().Delete(ctx, "my-resource-group", "my-component", armapplicationinsights.ItemScopePathAnalyticsItems, &armapplicationinsights.AnalyticsItemsClientDeleteOptions{ + ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5")}) 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.ComponentAnalyticsItemArray = []*armapplicationinsights.ComponentAnalyticsItem{ - // { - // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), - // ID: to.Ptr("b753348d-333a-4678-a684-c0e9090713b7"), - // Name: to.Ptr("1"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), - // TimeModified: to.Ptr("2017-06-29T10:27:03Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), - // }, - // { - // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), - // ID: to.Ptr("0d2f1b19-04b2-4c93-bc6f-2466b23c5284"), - // Name: to.Ptr("4"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), - // TimeModified: to.Ptr("2017-06-29T10:27:13Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), - // }, - // { - // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), - // ID: to.Ptr("3d17bebb-0b20-4b58-9bbd-22aeed70be51"), - // Name: to.Ptr("2"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), - // TimeModified: to.Ptr("2018-02-10T23:21:05.9952874Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), - // }, - // { - // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), - // ID: to.Ptr("2be491c6-10d9-4cf6-9490-2a7ce7270c54"), - // Name: to.Ptr("5"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), - // TimeModified: to.Ptr("2017-06-29T10:27:17Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), - // }, - // { - // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), - // ID: to.Ptr("d8f83601-4a40-4dc1-8516-0a28dcb74420"), - // Name: to.Ptr("8"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), - // TimeCreated: to.Ptr("2018-02-10T23:20:19.0174631Z"), - // TimeModified: to.Ptr("2018-02-10T23:20:19.0174631Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), - // }, - // { - // Content: to.Ptr("let newExceptionsTimeRange = 7d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), - // ID: to.Ptr("fd3afe4d-9139-4c76-9b47-81d0fada977b"), - // Name: to.Ptr("Exceptions - New in the last 7 days"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), - // TimeCreated: to.Ptr("2018-02-11T22:05:57.6019354Z"), - // TimeModified: to.Ptr("2018-02-12T11:01:15.5687326Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), - // }, - // { - // Content: to.Ptr("let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), - // ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5"), - // Name: to.Ptr("Exceptions - New in the last 24 hours"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeShared), - // TimeCreated: to.Ptr("2018-02-12T11:44:39.2980634Z"), - // TimeModified: to.Ptr("2018-02-14T13:13:19.3381394Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), - // }} + // res = armapplicationinsights.AnalyticsItemsClientDeleteResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AnalyticsItemGet.json +// Generated from example definition: 2015-05-01/AnalyticsItemGet.json func ExampleAnalyticsItemsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAnalyticsItemsClient().Get(ctx, "my-resource-group", "my-component", armapplicationinsights.ItemScopePathAnalyticsItems, &armapplicationinsights.AnalyticsItemsClientGetOptions{ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5"), - Name: nil, - }) + res, err := clientFactory.NewAnalyticsItemsClient().Get(ctx, "my-resource-group", "my-component", armapplicationinsights.ItemScopePathAnalyticsItems, &armapplicationinsights.AnalyticsItemsClientGetOptions{ + ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5")}) 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.ComponentAnalyticsItem = armapplicationinsights.ComponentAnalyticsItem{ - // Content: to.Ptr("let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), - // ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5"), - // Name: to.Ptr("Exceptions - New in the last 24 hours"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeShared), - // TimeCreated: to.Ptr("2018-02-12T11:44:39.2980634Z"), - // TimeModified: to.Ptr("2018-02-14T13:13:19.3381394Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), + // res = armapplicationinsights.AnalyticsItemsClientGetResponse{ + // ComponentAnalyticsItem: armapplicationinsights.ComponentAnalyticsItem{ + // Content: to.Ptr("let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), + // ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5"), + // Name: to.Ptr("Exceptions - New in the last 24 hours"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeShared), + // TimeCreated: to.Ptr("2018-02-12T11:44:39.2980634Z"), + // TimeModified: to.Ptr("2018-02-14T13:13:19.3381394Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AnalyticsItemPut.json -func ExampleAnalyticsItemsClient_Put() { +// Generated from example definition: 2015-05-01/AnalyticsItemList.json +func ExampleAnalyticsItemsClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAnalyticsItemsClient().Put(ctx, "my-resource-group", "my-component", armapplicationinsights.ItemScopePathAnalyticsItems, armapplicationinsights.ComponentAnalyticsItem{ - Content: to.Ptr("let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), - Name: to.Ptr("Exceptions - New in the last 24 hours"), - Scope: to.Ptr(armapplicationinsights.ItemScopeShared), - Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - }, &armapplicationinsights.AnalyticsItemsClientPutOptions{OverrideItem: nil}) + res, err := clientFactory.NewAnalyticsItemsClient().List(ctx, "my-resource-group", "my-component", armapplicationinsights.ItemScopePathAnalyticsItems, 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.ComponentAnalyticsItem = armapplicationinsights.ComponentAnalyticsItem{ - // Content: to.Ptr("let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), - // ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5"), - // Name: to.Ptr("Exceptions - New in the last 24 hours"), - // Scope: to.Ptr(armapplicationinsights.ItemScopeShared), - // TimeCreated: to.Ptr("2018-02-12T11:44:39.2980634Z"), - // TimeModified: to.Ptr("2018-02-14T13:13:19.3381394Z"), - // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), - // Version: to.Ptr("1.0"), + // res = armapplicationinsights.AnalyticsItemsClientListResponse{ + // ComponentAnalyticsItemArray: []*armapplicationinsights.ComponentAnalyticsItem{ + // { + // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), + // ID: to.Ptr("b753348d-333a-4678-a684-c0e9090713b7"), + // Name: to.Ptr("1"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), + // TimeModified: to.Ptr("2017-06-29T10:27:03Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, + // { + // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), + // ID: to.Ptr("0d2f1b19-04b2-4c93-bc6f-2466b23c5284"), + // Name: to.Ptr("4"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), + // TimeModified: to.Ptr("2017-06-29T10:27:13Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, + // { + // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), + // ID: to.Ptr("3d17bebb-0b20-4b58-9bbd-22aeed70be51"), + // Name: to.Ptr("2"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), + // TimeModified: to.Ptr("2018-02-10T23:21:05.9952874Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, + // { + // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), + // ID: to.Ptr("2be491c6-10d9-4cf6-9490-2a7ce7270c54"), + // Name: to.Ptr("5"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), + // TimeModified: to.Ptr("2017-06-29T10:27:17Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, + // { + // Content: to.Ptr("//Top 10 countries by traffic in the past 24 hours\nrequests \n | where timestamp > ago(24h) \n | summarize count() by client_CountryOrRegion\n | top 10 by count_ \n | render piechart"), + // ID: to.Ptr("d8f83601-4a40-4dc1-8516-0a28dcb74420"), + // Name: to.Ptr("8"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), + // TimeCreated: to.Ptr("2018-02-10T23:20:19.0174631Z"), + // TimeModified: to.Ptr("2018-02-10T23:20:19.0174631Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, + // { + // Content: to.Ptr("let newExceptionsTimeRange = 7d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), + // ID: to.Ptr("fd3afe4d-9139-4c76-9b47-81d0fada977b"), + // Name: to.Ptr("Exceptions - New in the last 7 days"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeUser), + // TimeCreated: to.Ptr("2018-02-11T22:05:57.6019354Z"), + // TimeModified: to.Ptr("2018-02-12T11:01:15.5687326Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, + // { + // Content: to.Ptr("let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), + // ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5"), + // Name: to.Ptr("Exceptions - New in the last 24 hours"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeShared), + // TimeCreated: to.Ptr("2018-02-12T11:44:39.2980634Z"), + // TimeModified: to.Ptr("2018-02-14T13:13:19.3381394Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AnalyticsItemDelete.json -func ExampleAnalyticsItemsClient_Delete() { +// Generated from example definition: 2015-05-01/AnalyticsItemPut.json +func ExampleAnalyticsItemsClient_Put() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewAnalyticsItemsClient().Delete(ctx, "my-resource-group", "my-component", armapplicationinsights.ItemScopePathAnalyticsItems, &armapplicationinsights.AnalyticsItemsClientDeleteOptions{ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5"), - Name: nil, - }) + res, err := clientFactory.NewAnalyticsItemsClient().Put(ctx, "my-resource-group", "my-component", armapplicationinsights.ItemScopePathAnalyticsItems, armapplicationinsights.ComponentAnalyticsItem{ + Content: to.Ptr("let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), + Name: to.Ptr("Exceptions - New in the last 24 hours"), + Scope: to.Ptr(armapplicationinsights.ItemScopeShared), + Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + }, 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 = armapplicationinsights.AnalyticsItemsClientPutResponse{ + // ComponentAnalyticsItem: armapplicationinsights.ComponentAnalyticsItem{ + // Content: to.Ptr("let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n"), + // ID: to.Ptr("3466c160-4a10-4df8-afdf-0007f3f6dee5"), + // Name: to.Ptr("Exceptions - New in the last 24 hours"), + // Scope: to.Ptr(armapplicationinsights.ItemScopeShared), + // TimeCreated: to.Ptr("2018-02-12T11:44:39.2980634Z"), + // TimeModified: to.Ptr("2018-02-14T13:13:19.3381394Z"), + // Type: to.Ptr(armapplicationinsights.ItemTypeQuery), + // Version: to.Ptr("1.0"), + // }, + // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/annotations_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/annotations_client.go index bc16728e2f51..ddd754bf87fd 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/annotations_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/annotations_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // AnnotationsClient contains the methods for the Annotations group. // Don't use this type directly, use NewAnnotationsClient() instead. +// +// Generated from API version 2015-05-01 type AnnotationsClient struct { internal *arm.Client subscriptionID string } // NewAnnotationsClient creates a new instance of AnnotationsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewAnnotationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AnnotationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewAnnotationsClient(subscriptionID string, credential azcore.TokenCredenti // Create - Create an Annotation of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - annotationProperties - Properties that need to be specified to create an annotation of a Application Insights component. @@ -73,14 +72,14 @@ func (client *AnnotationsClient) Create(ctx context.Context, resourceGroupName s // createCreateRequest creates the Create request. func (client *AnnotationsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, annotationProperties Annotation, _ *AnnotationsClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -90,9 +89,10 @@ func (client *AnnotationsClient) createCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, annotationProperties); err != nil { return nil, err } @@ -110,8 +110,6 @@ func (client *AnnotationsClient) createHandleResponse(resp *http.Response) (Anno // Delete - Delete an Annotation of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - annotationID - The unique annotation ID. This is unique within a Application Insights component. @@ -140,14 +138,14 @@ func (client *AnnotationsClient) Delete(ctx context.Context, resourceGroupName s // deleteCreateRequest creates the Delete request. func (client *AnnotationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, annotationID string, _ *AnnotationsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -161,15 +159,13 @@ func (client *AnnotationsClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // Get - Get the annotation for given id. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - annotationID - The unique annotation ID. This is unique within a Application Insights component. @@ -199,14 +195,14 @@ func (client *AnnotationsClient) Get(ctx context.Context, resourceGroupName stri // getCreateRequest creates the Get request. func (client *AnnotationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, annotationID string, _ *AnnotationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -220,8 +216,8 @@ func (client *AnnotationsClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -236,8 +232,6 @@ func (client *AnnotationsClient) getHandleResponse(resp *http.Response) (Annotat } // NewListPager - Gets the list of annotations for a component for given time range -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - start - The start time to query from for annotations, cannot be older than 90 days from current date. @@ -246,21 +240,20 @@ func (client *AnnotationsClient) getHandleResponse(resp *http.Response) (Annotat func (client *AnnotationsClient) NewListPager(resourceGroupName string, resourceName string, start string, end string, options *AnnotationsClientListOptions) *runtime.Pager[AnnotationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AnnotationsClientListResponse]{ More: func(page AnnotationsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *AnnotationsClientListResponse) (AnnotationsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AnnotationsClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, start, end, options) - if err != nil { - return AnnotationsClientListResponse{}, err + 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.listCreateRequest(ctx, resourceGroupName, resourceName, start, end, options) + }, nil) if err != nil { return AnnotationsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AnnotationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -270,14 +263,14 @@ func (client *AnnotationsClient) NewListPager(resourceGroupName string, resource // listCreateRequest creates the List request. func (client *AnnotationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, start string, end string, _ *AnnotationsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -287,10 +280,10 @@ func (client *AnnotationsClient) listCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") + reqQP.Set("api-version", version20150501) reqQP.Set("end", end) reqQP.Set("start", start) - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/annotations_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/annotations_client_example_test.go index 6efa6a00cea1..235baba4b27a 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/annotations_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/annotations_client_example_test.go @@ -1,57 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_test import ( "context" - "log" - - "time" - "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/applicationinsights/armapplicationinsights/v2" + "log" + "time" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AnnotationsList.json -func ExampleAnnotationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAnnotationsClient().NewListPager("my-resource-group", "my-component", "2018-02-05T00%253A30%253A00.000Z", "2018-02-06T00%253A33A00.000Z", 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.AnnotationsListResult = armapplicationinsights.AnnotationsListResult{ - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AnnotationsCreate.json +// Generated from example definition: 2015-05-01/AnnotationsCreate.json func ExampleAnnotationsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -68,41 +37,49 @@ func ExampleAnnotationsClient_Create() { // 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.AnnotationArray = []*armapplicationinsights.Annotation{ - // { - // AnnotationName: to.Ptr("TestAnnotation"), - // Category: to.Ptr("Text"), - // EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-31T13:41:38.657Z"); return t}()), - // ID: to.Ptr("444e2c08-274a-4bbb-a89e-d77bb720f44a"), - // Properties: to.Ptr("{\"Comments\":\"Testing\",\"Label\":\"Success\"}"), - // }} + // res = armapplicationinsights.AnnotationsClientCreateResponse{ + // AnnotationArray: []*armapplicationinsights.Annotation{ + // { + // AnnotationName: to.Ptr("TestAnnotation"), + // Category: to.Ptr("Text"), + // EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-31T13:41:38.657+00:00"); return t}()), + // ID: to.Ptr("444e2c08-274a-4bbb-a89e-d77bb720f44a"), + // Properties: to.Ptr("{\"Comments\":\"Testing\",\"Label\":\"Success\"}"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AnnotationsDelete.json +// Generated from example definition: 2015-05-01/AnnotationsDelete.json func ExampleAnnotationsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewAnnotationsClient().Delete(ctx, "my-resource-group", "my-component", "bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a", nil) + res, err := clientFactory.NewAnnotationsClient().Delete(ctx, "my-resource-group", "my-component", "bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a", 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 = armapplicationinsights.AnnotationsClientDeleteResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AnnotationsGet.json +// Generated from example definition: 2015-05-01/AnnotationsGet.json func ExampleAnnotationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -113,12 +90,60 @@ func ExampleAnnotationsClient_Get() { // 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.AnnotationArray = []*armapplicationinsights.Annotation{ - // { - // AnnotationName: to.Ptr("TestAnnotation"), - // Category: to.Ptr("Text"), - // EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-31T13:41:38.657Z"); return t}()), - // ID: to.Ptr("444e2c08-274a-4bbb-a89e-d77bb720f44a"), - // Properties: to.Ptr("{\"Comments\":\"Testing\",\"Label\":\"Success\"}"), - // }} + // res = armapplicationinsights.AnnotationsClientGetResponse{ + // AnnotationArray: []*armapplicationinsights.Annotation{ + // { + // AnnotationName: to.Ptr("TestAnnotation"), + // Category: to.Ptr("Text"), + // EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-31T13:41:38.657+00:00"); return t}()), + // ID: to.Ptr("444e2c08-274a-4bbb-a89e-d77bb720f44a"), + // Properties: to.Ptr("{\"Comments\":\"Testing\",\"Label\":\"Success\"}"), + // }, + // }, + // } +} + +// Generated from example definition: 2015-05-01/AnnotationsList.json +func ExampleAnnotationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAnnotationsClient().NewListPager("my-resource-group", "my-component", "2018-02-05T00%253A30%253A00.000Z", "2018-02-06T00%253A33A00.000Z", 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 = armapplicationinsights.AnnotationsClientListResponse{ + // AnnotationsListResult: armapplicationinsights.AnnotationsListResult{ + // Value: []*armapplicationinsights.Annotation{ + // { + // AnnotationName: to.Ptr("InsightsPortal-20180126-1"), + // Category: to.Ptr("Deployment"), + // EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-29T20:30:31+00:00"); return t}()), + // ID: to.Ptr("4de4524f-fca5-44a8-b7e6-a67d5107796e"), + // Properties: to.Ptr("{\"ReleaseDefinitionName\":\"InsightsPortal-PPEProd-KeyVault\",\"ReleaseRequestedFor\":\"6a970e9b-6220-47f3-a78c-b8be97506698\",\"TeamFoundationCollectionUri\":\"https://mseng.visualstudio.com/\",\"BuildNumber\":\"20180126.1\",\"ReleaseDescription\":\"Triggered by InsightsPortal_master_PROD1_vNext 20180126.1.\",\"ReleaseId\":\"31075\",\"ReleaseWebUrl\":\"https://mseng.visualstudio.com/96a62c4a-58c2-4dbb-94b6-5979ebc7f2af/_release?releaseId=31075\\u0026_a=release-summary\",\"SourceBranch\":\"refs/heads/master\",\"BuildRepositoryProvider\":\"TfsGit\",\"ReleaseEnvironmentName\":\"AIMON VIP SWAP\",\"BuildRepositoryName\":\"InsightsPortal\",\"ReleaseName\":\"InsightsPortal-20180126-1\"}"), + // }, + // { + // AnnotationName: to.Ptr("InsightsPortal-20180125-1"), + // Category: to.Ptr("Deployment"), + // EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-29T20:38:35+00:00"); return t}()), + // ID: to.Ptr("9a82214f-8f98-4699-b5bc-cad6101ed223"), + // Properties: to.Ptr("{\"ReleaseDefinitionName\":\"InsightsPortal-PPEProd-KeyVault\",\"ReleaseRequestedFor\":\"6a970e9b-6220-47f3-a78c-b8be97506698\",\"TeamFoundationCollectionUri\":\"https://mseng.visualstudio.com/\",\"BuildNumber\":\"20180125.1\",\"ReleaseDescription\":\"Triggered by InsightsPortal_master_PROD1_vNext 20180125.1.\",\"ReleaseId\":\"31035\",\"ReleaseWebUrl\":\"https://mseng.visualstudio.com/96a62c4a-58c2-4dbb-94b6-5979ebc7f2af/_release?releaseId=31035\\u0026_a=release-summary\",\"SourceBranch\":\"refs/heads/master\",\"BuildRepositoryProvider\":\"TfsGit\",\"ReleaseEnvironmentName\":\"Prod VIP Swap \",\"BuildRepositoryName\":\"InsightsPortal\",\"ReleaseName\":\"InsightsPortal-20180125-1\"}"), + // }, + // }, + // }, + // } + } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/apikeys_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/apikeys_client.go index d4e4683fff11..fa3e8cb2e042 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/apikeys_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/apikeys_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // APIKeysClient contains the methods for the APIKeys group. // Don't use this type directly, use NewAPIKeysClient() instead. +// +// Generated from API version 2015-05-01 type APIKeysClient struct { internal *arm.Client subscriptionID string } // NewAPIKeysClient creates a new instance of APIKeysClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewAPIKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIKeysClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,11 +43,9 @@ func NewAPIKeysClient(subscriptionID string, credential azcore.TokenCredential, // Create - Create an API Key of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. -// - apiKeyProperties - Properties that need to be specified to create an API key of a Application Insights component. +// - apiKeyProperties - Properties that need to be specified to create an API Key of an Application Insights component. // - options - APIKeysClientCreateOptions contains the optional parameters for the APIKeysClient.Create method. func (client *APIKeysClient) Create(ctx context.Context, resourceGroupName string, resourceName string, apiKeyProperties APIKeyRequest, options *APIKeysClientCreateOptions) (APIKeysClientCreateResponse, error) { var err error @@ -73,14 +72,14 @@ func (client *APIKeysClient) Create(ctx context.Context, resourceGroupName strin // createCreateRequest creates the Create request. func (client *APIKeysClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, apiKeyProperties APIKeyRequest, _ *APIKeysClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -90,9 +89,10 @@ func (client *APIKeysClient) createCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, apiKeyProperties); err != nil { return nil, err } @@ -110,8 +110,6 @@ func (client *APIKeysClient) createHandleResponse(resp *http.Response) (APIKeysC // Delete - Delete an API Key of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - keyID - The API Key ID. This is unique within a Application Insights component. @@ -141,14 +139,14 @@ func (client *APIKeysClient) Delete(ctx context.Context, resourceGroupName strin // deleteCreateRequest creates the Delete request. func (client *APIKeysClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, keyID string, _ *APIKeysClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -162,8 +160,8 @@ func (client *APIKeysClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -179,8 +177,6 @@ func (client *APIKeysClient) deleteHandleResponse(resp *http.Response) (APIKeysC // Get - Get the API Key for this key id. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - keyID - The API Key ID. This is unique within a Application Insights component. @@ -210,14 +206,14 @@ func (client *APIKeysClient) Get(ctx context.Context, resourceGroupName string, // getCreateRequest creates the Get request. func (client *APIKeysClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, keyID string, _ *APIKeysClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -231,8 +227,8 @@ func (client *APIKeysClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -247,29 +243,26 @@ func (client *APIKeysClient) getHandleResponse(resp *http.Response) (APIKeysClie } // NewListPager - Gets a list of API keys of an Application Insights component. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - APIKeysClientListOptions contains the optional parameters for the APIKeysClient.NewListPager method. func (client *APIKeysClient) NewListPager(resourceGroupName string, resourceName string, options *APIKeysClientListOptions) *runtime.Pager[APIKeysClientListResponse] { return runtime.NewPager(runtime.PagingHandler[APIKeysClientListResponse]{ More: func(page APIKeysClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *APIKeysClientListResponse) (APIKeysClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "APIKeysClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, options) - if err != nil { - return APIKeysClientListResponse{}, err + 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.listCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) if err != nil { return APIKeysClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return APIKeysClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -279,14 +272,14 @@ func (client *APIKeysClient) NewListPager(resourceGroupName string, resourceName // listCreateRequest creates the List request. func (client *APIKeysClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *APIKeysClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -296,8 +289,8 @@ func (client *APIKeysClient) listCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/apikeys_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/apikeys_client_example_test.go index 6596d1ec1031..c2538039bbcc 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/apikeys_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/apikeys_client_example_test.go @@ -1,84 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/APIKeysList.json -func ExampleAPIKeysClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIKeysClient().NewListPager("my-resource-group", "my-component", 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.ComponentAPIKeyListResult = armapplicationinsights.ComponentAPIKeyListResult{ - // Value: []*armapplicationinsights.ComponentAPIKey{ - // { - // Name: to.Ptr("test"), - // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:58:52 GMT"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/fe2e0138-47c1-46c5-8726-872f54c1ca08"), - // LinkedReadProperties: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/draft"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/extendqueries"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/search"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/aggregate"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig")}, - // LinkedWriteProperties: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations")}, - // }, - // { - // Name: to.Ptr("test2"), - // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:59:18 GMT"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a"), - // LinkedReadProperties: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/draft"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/extendqueries"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/search"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/aggregate"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig")}, - // LinkedWriteProperties: []*string{ - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/APIKeysCreate.json +// Generated from example definition: 2015-05-01/APIKeysCreate.json func ExampleAPIKeysClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -86,9 +27,11 @@ func ExampleAPIKeysClient_Create() { Name: to.Ptr("test2"), LinkedReadProperties: []*string{ to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), - to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig")}, + to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig"), + }, LinkedWriteProperties: []*string{ - to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations")}, + to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations"), + }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -96,27 +39,31 @@ func ExampleAPIKeysClient_Create() { // 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.ComponentAPIKey = armapplicationinsights.ComponentAPIKey{ - // Name: to.Ptr("test"), - // APIKey: to.Ptr("0000000000000000000000000000000000000000"), - // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:58:52 GMT"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/00000000-0000-0000-0000-000000000000"), - // LinkedReadProperties: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig")}, + // res = armapplicationinsights.APIKeysClientCreateResponse{ + // ComponentAPIKey: armapplicationinsights.ComponentAPIKey{ + // Name: to.Ptr("test"), + // APIKey: to.Ptr("0000000000000000000000000000000000000000"), + // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:58:52 GMT"), + // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/00000000-0000-0000-0000-000000000000"), + // LinkedReadProperties: []*string{ + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig"), + // }, // LinkedWriteProperties: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations")}, - // } + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/APIKeysDelete.json +// Generated from example definition: 2015-05-01/APIKeysDelete.json func ExampleAPIKeysClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -127,30 +74,33 @@ func ExampleAPIKeysClient_Delete() { // 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.ComponentAPIKey = armapplicationinsights.ComponentAPIKey{ - // Name: to.Ptr("test2"), - // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:59:18 GMT"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a"), - // LinkedReadProperties: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/draft"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/extendqueries"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/search"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/aggregate"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig")}, + // res = armapplicationinsights.APIKeysClientDeleteResponse{ + // ComponentAPIKey: armapplicationinsights.ComponentAPIKey{ + // Name: to.Ptr("test2"), + // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:59:18 GMT"), + // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a"), + // LinkedReadProperties: []*string{ + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/draft"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/extendqueries"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/search"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/aggregate"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig"), + // }, // LinkedWriteProperties: []*string{ // }, - // } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/APIKeysGet.json +// Generated from example definition: 2015-05-01/APIKeysGet.json func ExampleAPIKeysClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -161,18 +111,83 @@ func ExampleAPIKeysClient_Get() { // 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.ComponentAPIKey = armapplicationinsights.ComponentAPIKey{ - // Name: to.Ptr("test2"), - // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:59:18 GMT"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a"), - // LinkedReadProperties: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/draft"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/extendqueries"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/search"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/aggregate"), - // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig")}, + // res = armapplicationinsights.APIKeysClientGetResponse{ + // ComponentAPIKey: armapplicationinsights.ComponentAPIKey{ + // Name: to.Ptr("test2"), + // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:59:18 GMT"), + // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a"), + // LinkedReadProperties: []*string{ + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/draft"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/extendqueries"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/search"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/aggregate"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig"), + // }, // LinkedWriteProperties: []*string{ // }, - // } + // }, + // } +} + +// Generated from example definition: 2015-05-01/APIKeysList.json +func ExampleAPIKeysClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAPIKeysClient().NewListPager("my-resource-group", "my-component", 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 = armapplicationinsights.APIKeysClientListResponse{ + // ComponentAPIKeyListResult: armapplicationinsights.ComponentAPIKeyListResult{ + // Value: []*armapplicationinsights.ComponentAPIKey{ + // { + // Name: to.Ptr("test"), + // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:58:52 GMT"), + // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/fe2e0138-47c1-46c5-8726-872f54c1ca08"), + // LinkedReadProperties: []*string{ + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/draft"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/extendqueries"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/search"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/aggregate"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig"), + // }, + // LinkedWriteProperties: []*string{ + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations"), + // }, + // }, + // { + // Name: to.Ptr("test2"), + // CreatedDate: to.Ptr("Thu, 28 Sep 2017 16:59:18 GMT"), + // ID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/Microsoft.Insights/components/my-component/apikeys/bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a"), + // LinkedReadProperties: []*string{ + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/draft"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/extendqueries"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/search"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/aggregate"), + // to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig"), + // }, + // LinkedWriteProperties: []*string{ + // }, + // }, + // }, + // }, + // } + } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/autorest.md b/sdk/resourcemanager/applicationinsights/armapplicationinsights/autorest.md deleted file mode 100644 index 29d646404deb..000000000000 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/autorest.md +++ /dev/null @@ -1,13 +0,0 @@ -### AutoRest Configuration - -> see https://aka.ms/autorest - -``` yaml -azure-arm: true -require: -- https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/readme.go.md -license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.0.0-beta.3 -tag: package-2024-08-01 -``` \ No newline at end of file diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/build.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/build.go deleted file mode 100644 index 261f3c125b7e..000000000000 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/build.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/applicationinsights/armapplicationinsights - -package armapplicationinsights diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/client_factory.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/client_factory.go index ed5d365ca67a..e6eead939ec5 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/client_factory.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/client_factory.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,7 +18,7 @@ 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 ID of the target subscription. +// - 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) { diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentavailablefeatures_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentavailablefeatures_client.go index a4bf1b15962a..168370422aa7 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentavailablefeatures_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentavailablefeatures_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // ComponentAvailableFeaturesClient contains the methods for the ComponentAvailableFeatures group. // Don't use this type directly, use NewComponentAvailableFeaturesClient() instead. +// +// Generated from API version 2015-05-01 type ComponentAvailableFeaturesClient struct { internal *arm.Client subscriptionID string } // NewComponentAvailableFeaturesClient creates a new instance of ComponentAvailableFeaturesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewComponentAvailableFeaturesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ComponentAvailableFeaturesClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewComponentAvailableFeaturesClient(subscriptionID string, credential azcor // Get - Returns all available features of the application insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - ComponentAvailableFeaturesClientGetOptions contains the optional parameters for the ComponentAvailableFeaturesClient.Get @@ -73,14 +72,14 @@ func (client *ComponentAvailableFeaturesClient) Get(ctx context.Context, resourc // getCreateRequest creates the Get request. func (client *ComponentAvailableFeaturesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ComponentAvailableFeaturesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/getavailablebillingfeatures" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -90,8 +89,8 @@ func (client *ComponentAvailableFeaturesClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentavailablefeatures_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentavailablefeatures_client_example_test.go index a098fb9814a0..b890c61f3f76 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentavailablefeatures_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentavailablefeatures_client_example_test.go @@ -1,27 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/AvailableBillingFeaturesGet.json +// Generated from example definition: 2015-05-01/AvailableBillingFeaturesGet.json func ExampleComponentAvailableFeaturesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -32,190 +29,195 @@ func ExampleComponentAvailableFeaturesClient_Get() { // 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.ComponentAvailableFeatures = armapplicationinsights.ComponentAvailableFeatures{ - // Result: []*armapplicationinsights.ComponentFeature{ - // { - // Capabilities: []*armapplicationinsights.ComponentFeatureCapability{ - // { - // Description: to.Ptr("Number of application hosts"), - // Name: to.Ptr("hostnumber"), - // Value: to.Ptr("Unlimited"), - // }, - // { - // Description: to.Ptr("Included data"), - // MeterID: to.Ptr("acf26b15-ee92-440d-9973-9a72d77641aa"), - // MeterRateFrequency: to.Ptr("GB/month"), - // Name: to.Ptr("includeddata"), - // Value: to.Ptr("1"), - // }, - // { - // Description: to.Ptr("Additional data"), - // MeterID: to.Ptr("b90f8b65-6c3e-43fc-9149-bdfc73b6a5b9"), - // MeterRateFrequency: to.Ptr("/GB"), - // Name: to.Ptr("additionaldata"), - // }, - // { - // Description: to.Ptr("Data retention"), - // Name: to.Ptr("dataretention"), - // Unit: to.Ptr("days"), - // Value: to.Ptr("90"), - // }, - // { - // Description: to.Ptr("Response time monitoring and diagnostics"), - // Name: to.Ptr("responsetimemonitoring"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Failed requests monitoring and diagnostics"), - // Name: to.Ptr("failedrequestsmonitoring"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Browser performance"), - // Name: to.Ptr("browserperformance"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Usage analysis"), - // Name: to.Ptr("usageanalysis"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Server monitoring"), - // Name: to.Ptr("servermonitoring"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Alerting and notifications"), - // Name: to.Ptr("alertingandnotifications"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Daily notification of failed request rate spikes"), - // Name: to.Ptr("notificationfailedrequestrate"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Telemetry analyzer"), - // Name: to.Ptr("telemetryanalyzer"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Search and Analytics"), - // Name: to.Ptr("searchandanalytics"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Web tests (multi-step tests)"), - // MeterID: to.Ptr("0aa0e0e9-3f58-4dcf-9bb0-9db7ae1d5954"), - // MeterRateFrequency: to.Ptr("/test (per month)"), - // Name: to.Ptr("webtests"), - // }, - // { - // Description: to.Ptr("Live stream metrics"), - // Name: to.Ptr("livestreammetrics"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Application map"), - // Name: to.Ptr("applicationmap"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Daily notification for many key metrics"), - // Name: to.Ptr("dailynotificationforkeymetrics"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Work item integration"), - // Name: to.Ptr("workitemintegration"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("API access"), - // Name: to.Ptr("apiaccess"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Power BI integration"), - // Name: to.Ptr("powerbiintegration"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Bulk data import"), - // Name: to.Ptr("bulkdataimport"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Automatic data evaluation"), - // Name: to.Ptr("automaticdataevaluation"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Analytics integration with Azure dashboards"), - // Name: to.Ptr("analyticsintegration"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Continuous export"), - // MeterID: to.Ptr("90fa4d31-3ea2-4178-a894-ec4c76c712b2"), - // MeterRateFrequency: to.Ptr("/GB"), - // Name: to.Ptr("continuousexport"), - // Value: to.Ptr("Enabled"), - // }, - // { - // Description: to.Ptr("Default daily cap"), - // Name: to.Ptr("defaultdailycap"), - // Unit: to.Ptr("G"), - // Value: to.Ptr("100"), - // }, - // { - // Description: to.Ptr("Default maximum daily cap"), - // Name: to.Ptr("defaultmaxdailycap"), - // Unit: to.Ptr("G"), - // Value: to.Ptr("1000"), - // }}, - // FeatureName: to.Ptr("Basic"), - // IsHidden: to.Ptr(true), - // IsMainFeature: to.Ptr(true), - // MeterID: to.Ptr("c9a05f12-4910-4527-a9ec-1db4e4dba60e"), - // MeterRateFrequency: to.Ptr("/month"), - // SupportedAddonFeatures: to.Ptr("Application Insights Enterprise"), - // Title: to.Ptr("Application Insights Basic"), + // res = armapplicationinsights.ComponentAvailableFeaturesClientGetResponse{ + // ComponentAvailableFeatures: armapplicationinsights.ComponentAvailableFeatures{ + // Result: []*armapplicationinsights.ComponentFeature{ + // { + // Capabilities: []*armapplicationinsights.ComponentFeatureCapability{ + // { + // Description: to.Ptr("Number of application hosts"), + // Name: to.Ptr("hostnumber"), + // Value: to.Ptr("Unlimited"), + // }, + // { + // Description: to.Ptr("Included data"), + // MeterID: to.Ptr("acf26b15-ee92-440d-9973-9a72d77641aa"), + // MeterRateFrequency: to.Ptr("GB/month"), + // Name: to.Ptr("includeddata"), + // Value: to.Ptr("1"), + // }, + // { + // Description: to.Ptr("Additional data"), + // MeterID: to.Ptr("b90f8b65-6c3e-43fc-9149-bdfc73b6a5b9"), + // MeterRateFrequency: to.Ptr("/GB"), + // Name: to.Ptr("additionaldata"), + // }, + // { + // Description: to.Ptr("Data retention"), + // Name: to.Ptr("dataretention"), + // Unit: to.Ptr("days"), + // Value: to.Ptr("90"), + // }, + // { + // Description: to.Ptr("Response time monitoring and diagnostics"), + // Name: to.Ptr("responsetimemonitoring"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Failed requests monitoring and diagnostics"), + // Name: to.Ptr("failedrequestsmonitoring"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Browser performance"), + // Name: to.Ptr("browserperformance"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Usage analysis"), + // Name: to.Ptr("usageanalysis"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Server monitoring"), + // Name: to.Ptr("servermonitoring"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Alerting and notifications"), + // Name: to.Ptr("alertingandnotifications"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Daily notification of failed request rate spikes"), + // Name: to.Ptr("notificationfailedrequestrate"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Telemetry analyzer"), + // Name: to.Ptr("telemetryanalyzer"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Search and Analytics"), + // Name: to.Ptr("searchandanalytics"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Web tests (multi-step tests)"), + // MeterID: to.Ptr("0aa0e0e9-3f58-4dcf-9bb0-9db7ae1d5954"), + // MeterRateFrequency: to.Ptr("/test (per month)"), + // Name: to.Ptr("webtests"), + // }, + // { + // Description: to.Ptr("Live stream metrics"), + // Name: to.Ptr("livestreammetrics"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Application map"), + // Name: to.Ptr("applicationmap"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Daily notification for many key metrics"), + // Name: to.Ptr("dailynotificationforkeymetrics"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Work item integration"), + // Name: to.Ptr("workitemintegration"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("API access"), + // Name: to.Ptr("apiaccess"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Power BI integration"), + // Name: to.Ptr("powerbiintegration"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Bulk data import"), + // Name: to.Ptr("bulkdataimport"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Automatic data evaluation"), + // Name: to.Ptr("automaticdataevaluation"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Analytics integration with Azure dashboards"), + // Name: to.Ptr("analyticsintegration"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Continuous export"), + // MeterID: to.Ptr("90fa4d31-3ea2-4178-a894-ec4c76c712b2"), + // MeterRateFrequency: to.Ptr("/GB"), + // Name: to.Ptr("continuousexport"), + // Value: to.Ptr("Enabled"), + // }, + // { + // Description: to.Ptr("Default daily cap"), + // Name: to.Ptr("defaultdailycap"), + // Unit: to.Ptr("G"), + // Value: to.Ptr("100"), + // }, + // { + // Description: to.Ptr("Default maximum daily cap"), + // Name: to.Ptr("defaultmaxdailycap"), + // Unit: to.Ptr("G"), + // Value: to.Ptr("1000"), + // }, + // }, + // FeatureName: to.Ptr("Basic"), + // IsHidden: to.Ptr(true), + // IsMainFeature: to.Ptr(true), + // MeterID: to.Ptr("c9a05f12-4910-4527-a9ec-1db4e4dba60e"), + // MeterRateFrequency: to.Ptr("/month"), + // SupportedAddonFeatures: to.Ptr("Application Insights Enterprise"), + // Title: to.Ptr("Application Insights Basic"), + // }, + // { + // Capabilities: []*armapplicationinsights.ComponentFeatureCapability{ + // { + // Description: to.Ptr("Enterprise Included data"), + // MeterID: to.Ptr("acf26b15-ee92-440d-9973-9a72d77641aa"), + // MeterRateFrequency: to.Ptr("GB/month"), + // Name: to.Ptr("enterpriseincludeddata"), + // Value: to.Ptr("0.20"), + // }, + // { + // Description: to.Ptr("Enterprise Additional data"), + // MeterID: to.Ptr("3fedc88a-b68f-4936-bbf0-f290a254388c"), + // MeterRateFrequency: to.Ptr("/GB"), + // Name: to.Ptr("enterpriseadditionaldata"), + // }, + // { + // Description: to.Ptr("Default daily cap"), + // Name: to.Ptr("defaultdailycap"), + // Unit: to.Ptr("G"), + // Value: to.Ptr("100"), + // }, + // { + // Description: to.Ptr("Default maximum daily cap"), + // Name: to.Ptr("defaultmaxdailycap"), + // Unit: to.Ptr("G"), + // Value: to.Ptr("1000"), + // }, + // }, + // FeatureName: to.Ptr("Application Insights Enterprise"), + // IsHidden: to.Ptr(false), + // IsMainFeature: to.Ptr(false), + // MeterID: to.Ptr("222f32c5-a319-4787-b934-5fb95105b2c8"), + // MeterRateFrequency: to.Ptr("/node/month"), + // Title: to.Ptr("Enterprise"), + // }, // }, - // { - // Capabilities: []*armapplicationinsights.ComponentFeatureCapability{ - // { - // Description: to.Ptr("Enterprise Included data"), - // MeterID: to.Ptr("acf26b15-ee92-440d-9973-9a72d77641aa"), - // MeterRateFrequency: to.Ptr("GB/month"), - // Name: to.Ptr("enterpriseincludeddata"), - // Value: to.Ptr("0.20"), - // }, - // { - // Description: to.Ptr("Enterprise Additional data"), - // MeterID: to.Ptr("3fedc88a-b68f-4936-bbf0-f290a254388c"), - // MeterRateFrequency: to.Ptr("/GB"), - // Name: to.Ptr("enterpriseadditionaldata"), - // }, - // { - // Description: to.Ptr("Default daily cap"), - // Name: to.Ptr("defaultdailycap"), - // Unit: to.Ptr("G"), - // Value: to.Ptr("100"), - // }, - // { - // Description: to.Ptr("Default maximum daily cap"), - // Name: to.Ptr("defaultmaxdailycap"), - // Unit: to.Ptr("G"), - // Value: to.Ptr("1000"), - // }}, - // FeatureName: to.Ptr("Application Insights Enterprise"), - // IsHidden: to.Ptr(false), - // IsMainFeature: to.Ptr(false), - // MeterID: to.Ptr("222f32c5-a319-4787-b934-5fb95105b2c8"), - // MeterRateFrequency: to.Ptr("/node/month"), - // Title: to.Ptr("Enterprise"), - // }}, + // }, // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentcurrentbillingfeatures_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentcurrentbillingfeatures_client.go index 60356b325c04..848f4b7c6858 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentcurrentbillingfeatures_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentcurrentbillingfeatures_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // ComponentCurrentBillingFeaturesClient contains the methods for the ComponentCurrentBillingFeatures group. // Don't use this type directly, use NewComponentCurrentBillingFeaturesClient() instead. +// +// Generated from API version 2015-05-01 type ComponentCurrentBillingFeaturesClient struct { internal *arm.Client subscriptionID string } // NewComponentCurrentBillingFeaturesClient creates a new instance of ComponentCurrentBillingFeaturesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewComponentCurrentBillingFeaturesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ComponentCurrentBillingFeaturesClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewComponentCurrentBillingFeaturesClient(subscriptionID string, credential // Get - Returns current billing features for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - ComponentCurrentBillingFeaturesClientGetOptions contains the optional parameters for the ComponentCurrentBillingFeaturesClient.Get @@ -73,14 +72,14 @@ func (client *ComponentCurrentBillingFeaturesClient) Get(ctx context.Context, re // getCreateRequest creates the Get request. func (client *ComponentCurrentBillingFeaturesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ComponentCurrentBillingFeaturesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -90,8 +89,8 @@ func (client *ComponentCurrentBillingFeaturesClient) getCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -107,12 +106,9 @@ func (client *ComponentCurrentBillingFeaturesClient) getHandleResponse(resp *htt // Update - Update current billing features for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. -// - billingFeaturesProperties - Properties that need to be specified to update billing features for an Application Insights -// component. +// - billingFeaturesProperties - The request body // - options - ComponentCurrentBillingFeaturesClientUpdateOptions contains the optional parameters for the ComponentCurrentBillingFeaturesClient.Update // method. func (client *ComponentCurrentBillingFeaturesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ComponentBillingFeatures, options *ComponentCurrentBillingFeaturesClientUpdateOptions) (ComponentCurrentBillingFeaturesClientUpdateResponse, error) { @@ -140,14 +136,14 @@ func (client *ComponentCurrentBillingFeaturesClient) Update(ctx context.Context, // updateCreateRequest creates the Update request. func (client *ComponentCurrentBillingFeaturesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ComponentBillingFeatures, _ *ComponentCurrentBillingFeaturesClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -157,9 +153,10 @@ func (client *ComponentCurrentBillingFeaturesClient) updateCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, billingFeaturesProperties); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentcurrentbillingfeatures_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentcurrentbillingfeatures_client_example_test.go index dbfad224a665..f859e9b9abbd 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentcurrentbillingfeatures_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentcurrentbillingfeatures_client_example_test.go @@ -1,28 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/CurrentBillingFeaturesGet.json +// Generated from example definition: 2015-05-01/CurrentBillingFeaturesGet.json func ExampleComponentCurrentBillingFeaturesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -33,9 +30,11 @@ func ExampleComponentCurrentBillingFeaturesClient_Get() { // 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.ComponentBillingFeatures = armapplicationinsights.ComponentBillingFeatures{ - // CurrentBillingFeatures: []*string{ - // to.Ptr("Basic")}, + // res = armapplicationinsights.ComponentCurrentBillingFeaturesClientGetResponse{ + // ComponentBillingFeatures: armapplicationinsights.ComponentBillingFeatures{ + // CurrentBillingFeatures: []*string{ + // to.Ptr("Basic"), + // }, // DataVolumeCap: &armapplicationinsights.ComponentDataVolumeCap{ // Cap: to.Ptr[float32](500), // MaxHistoryCap: to.Ptr[float32](500), @@ -44,24 +43,26 @@ func ExampleComponentCurrentBillingFeaturesClient_Get() { // StopSendNotificationWhenHitThreshold: to.Ptr(false), // WarningThreshold: to.Ptr[int32](90), // }, - // } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/CurrentBillingFeaturesUpdate.json +// Generated from example definition: 2015-05-01/CurrentBillingFeaturesUpdate.json func ExampleComponentCurrentBillingFeaturesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewComponentCurrentBillingFeaturesClient().Update(ctx, "my-resource-group", "my-component", armapplicationinsights.ComponentBillingFeatures{ CurrentBillingFeatures: []*string{ to.Ptr("Basic"), - to.Ptr("Application Insights Enterprise")}, + to.Ptr("Application Insights Enterprise"), + }, DataVolumeCap: &armapplicationinsights.ComponentDataVolumeCap{ Cap: to.Ptr[float32](100), StopSendNotificationWhenHitCap: to.Ptr(true), @@ -73,10 +74,12 @@ func ExampleComponentCurrentBillingFeaturesClient_Update() { // 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.ComponentBillingFeatures = armapplicationinsights.ComponentBillingFeatures{ - // CurrentBillingFeatures: []*string{ - // to.Ptr("Basic"), - // to.Ptr("Application Insights Enterprise")}, + // res = armapplicationinsights.ComponentCurrentBillingFeaturesClientUpdateResponse{ + // ComponentBillingFeatures: armapplicationinsights.ComponentBillingFeatures{ + // CurrentBillingFeatures: []*string{ + // to.Ptr("Basic"), + // to.Ptr("Application Insights Enterprise"), + // }, // DataVolumeCap: &armapplicationinsights.ComponentDataVolumeCap{ // Cap: to.Ptr[float32](100), // MaxHistoryCap: to.Ptr[float32](500), @@ -85,5 +88,6 @@ func ExampleComponentCurrentBillingFeaturesClient_Update() { // StopSendNotificationWhenHitThreshold: to.Ptr(false), // WarningThreshold: to.Ptr[int32](90), // }, - // } + // }, + // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentfeaturecapabilities_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentfeaturecapabilities_client.go index b296b63f369c..2d3a0f27fcb1 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentfeaturecapabilities_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentfeaturecapabilities_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // ComponentFeatureCapabilitiesClient contains the methods for the ComponentFeatureCapabilities group. // Don't use this type directly, use NewComponentFeatureCapabilitiesClient() instead. +// +// Generated from API version 2015-05-01 type ComponentFeatureCapabilitiesClient struct { internal *arm.Client subscriptionID string } // NewComponentFeatureCapabilitiesClient creates a new instance of ComponentFeatureCapabilitiesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewComponentFeatureCapabilitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ComponentFeatureCapabilitiesClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewComponentFeatureCapabilitiesClient(subscriptionID string, credential azc // Get - Returns feature capabilities of the application insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - ComponentFeatureCapabilitiesClientGetOptions contains the optional parameters for the ComponentFeatureCapabilitiesClient.Get @@ -73,14 +72,14 @@ func (client *ComponentFeatureCapabilitiesClient) Get(ctx context.Context, resou // getCreateRequest creates the Get request. func (client *ComponentFeatureCapabilitiesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ComponentFeatureCapabilitiesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/featurecapabilities" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -90,8 +89,8 @@ func (client *ComponentFeatureCapabilitiesClient) getCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentfeaturecapabilities_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentfeaturecapabilities_client_example_test.go index d1defab36e02..d8bb5c536b23 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentfeaturecapabilities_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentfeaturecapabilities_client_example_test.go @@ -1,27 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/FeatureCapabilitiesGet.json +// Generated from example definition: 2015-05-01/FeatureCapabilitiesGet.json func ExampleComponentFeatureCapabilitiesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -32,21 +29,23 @@ func ExampleComponentFeatureCapabilitiesClient_Get() { // 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.ComponentFeatureCapabilities = armapplicationinsights.ComponentFeatureCapabilities{ - // AnalyticsIntegration: to.Ptr(true), - // APIAccessLevel: to.Ptr("Premium"), - // ApplicationMap: to.Ptr(true), - // BurstThrottlePolicy: to.Ptr("B2"), - // DailyCap: to.Ptr[float32](0.0323), - // DailyCapResetTime: to.Ptr[float32](4), - // LiveStreamMetrics: to.Ptr(true), - // MultipleStepWebTest: to.Ptr(true), - // OpenSchema: to.Ptr(true), - // PowerBIIntegration: to.Ptr(true), - // ProactiveDetection: to.Ptr(false), - // SupportExportData: to.Ptr(true), - // ThrottleRate: to.Ptr[float32](0), - // TrackingType: to.Ptr("Basic"), - // WorkItemIntegration: to.Ptr(true), + // res = armapplicationinsights.ComponentFeatureCapabilitiesClientGetResponse{ + // ComponentFeatureCapabilities: armapplicationinsights.ComponentFeatureCapabilities{ + // AnalyticsIntegration: to.Ptr(true), + // APIAccessLevel: to.Ptr("Premium"), + // ApplicationMap: to.Ptr(true), + // BurstThrottlePolicy: to.Ptr("B2"), + // DailyCap: to.Ptr[float32](0.0323), + // DailyCapResetTime: to.Ptr[float32](4), + // LiveStreamMetrics: to.Ptr(true), + // MultipleStepWebTest: to.Ptr(true), + // OpenSchema: to.Ptr(true), + // PowerBIIntegration: to.Ptr(true), + // ProactiveDetection: to.Ptr(false), + // SupportExportData: to.Ptr(true), + // ThrottleRate: to.Ptr[float32](0), + // TrackingType: to.Ptr("Basic"), + // WorkItemIntegration: to.Ptr(true), + // }, // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentlinkedstorageaccounts_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentlinkedstorageaccounts_client.go index 65e13bbb9782..165cc397b6c7 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentlinkedstorageaccounts_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentlinkedstorageaccounts_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // ComponentLinkedStorageAccountsClient contains the methods for the ComponentLinkedStorageAccounts group. // Don't use this type directly, use NewComponentLinkedStorageAccountsClient() instead. +// +// Generated from API version 2020-03-01-preview type ComponentLinkedStorageAccountsClient struct { internal *arm.Client subscriptionID string } // NewComponentLinkedStorageAccountsClient creates a new instance of ComponentLinkedStorageAccountsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewComponentLinkedStorageAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ComponentLinkedStorageAccountsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewComponentLinkedStorageAccountsClient(subscriptionID string, credential a // CreateAndUpdate - Replace current linked storage account for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - storageType - The type of the Application Insights component data source for the linked storage account. @@ -75,15 +74,15 @@ func (client *ComponentLinkedStorageAccountsClient) CreateAndUpdate(ctx context. // createAndUpdateCreateRequest creates the CreateAndUpdate request. func (client *ComponentLinkedStorageAccountsClient) createAndUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, storageType StorageType, linkedStorageAccountsProperties ComponentLinkedStorageAccounts, _ *ComponentLinkedStorageAccountsClientCreateAndUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/linkedStorageAccounts/{storageType}" 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -97,9 +96,10 @@ func (client *ComponentLinkedStorageAccountsClient) createAndUpdateCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-03-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, linkedStorageAccountsProperties); err != nil { return nil, err } @@ -117,8 +117,6 @@ func (client *ComponentLinkedStorageAccountsClient) createAndUpdateHandleRespons // Delete - Delete linked storage accounts for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - storageType - The type of the Application Insights component data source for the linked storage account. @@ -147,15 +145,15 @@ func (client *ComponentLinkedStorageAccountsClient) Delete(ctx context.Context, // deleteCreateRequest creates the Delete request. func (client *ComponentLinkedStorageAccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, storageType StorageType, _ *ComponentLinkedStorageAccountsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/linkedStorageAccounts/{storageType}" 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -169,16 +167,13 @@ func (client *ComponentLinkedStorageAccountsClient) deleteCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-03-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} + reqQP.Set("api-version", version20200301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // Get - Returns the current linked storage settings for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - storageType - The type of the Application Insights component data source for the linked storage account. @@ -208,15 +203,15 @@ func (client *ComponentLinkedStorageAccountsClient) Get(ctx context.Context, res // getCreateRequest creates the Get request. func (client *ComponentLinkedStorageAccountsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, storageType StorageType, _ *ComponentLinkedStorageAccountsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/linkedStorageAccounts/{storageType}" 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -230,8 +225,8 @@ func (client *ComponentLinkedStorageAccountsClient) getCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-03-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -247,8 +242,6 @@ func (client *ComponentLinkedStorageAccountsClient) getHandleResponse(resp *http // Update - Update linked storage accounts for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - storageType - The type of the Application Insights component data source for the linked storage account. @@ -280,15 +273,15 @@ func (client *ComponentLinkedStorageAccountsClient) Update(ctx context.Context, // updateCreateRequest creates the Update request. func (client *ComponentLinkedStorageAccountsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, storageType StorageType, linkedStorageAccountsProperties ComponentLinkedStorageAccountsPatch, _ *ComponentLinkedStorageAccountsClientUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/linkedStorageAccounts/{storageType}" 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -302,9 +295,10 @@ func (client *ComponentLinkedStorageAccountsClient) updateCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-03-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200301Preview) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, linkedStorageAccountsProperties); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentlinkedstorageaccounts_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentlinkedstorageaccounts_client_example_test.go index 956ae41cce72..3278af5f6c4b 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentlinkedstorageaccounts_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentlinkedstorageaccounts_client_example_test.go @@ -1,125 +1,133 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2020-03-01-preview/examples/ComponentLinkedStorageAccountsGet.json -func ExampleComponentLinkedStorageAccountsClient_Get() { +// Generated from example definition: 2020-03-01-preview/ComponentLinkedStorageAccountsCreateAndUpdate.json +func ExampleComponentLinkedStorageAccountsClient_CreateAndUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("86dc51d3-92ed-4d7e-947a-775ea79b4918", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewComponentLinkedStorageAccountsClient().Get(ctx, "someResourceGroupName", "myComponent", armapplicationinsights.StorageTypeServiceProfiler, nil) + res, err := clientFactory.NewComponentLinkedStorageAccountsClient().CreateAndUpdate(ctx, "someResourceGroupName", "myComponent", armapplicationinsights.StorageTypeServiceProfiler, armapplicationinsights.ComponentLinkedStorageAccounts{ + Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ + LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), + }, + }, 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.ComponentLinkedStorageAccounts = armapplicationinsights.ComponentLinkedStorageAccounts{ - // Name: to.Ptr("serviceprofile"), - // Type: to.Ptr("microsoft.insights/components/linkedStorageAccounts"), - // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/microsoft.insights/components/myComponent/linkedStorageAccounts/serviceprofiler"), - // Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ - // LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), + // res = armapplicationinsights.ComponentLinkedStorageAccountsClientCreateAndUpdateResponse{ + // ComponentLinkedStorageAccounts: armapplicationinsights.ComponentLinkedStorageAccounts{ + // Name: to.Ptr("serviceprofile"), + // Type: to.Ptr("microsoft.insights/components/linkedStorageAccounts"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupNameproviders/microsoft.insights/components/myComponent/linkedStorageAccounts/serviceprofiler"), + // Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ + // LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2020-03-01-preview/examples/ComponentLinkedStorageAccountsCreateAndUpdate.json -func ExampleComponentLinkedStorageAccountsClient_CreateAndUpdate() { +// Generated from example definition: 2020-03-01-preview/ComponentLinkedStorageAccountsDelete.json +func ExampleComponentLinkedStorageAccountsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("86dc51d3-92ed-4d7e-947a-775ea79b4918", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewComponentLinkedStorageAccountsClient().CreateAndUpdate(ctx, "someResourceGroupName", "myComponent", armapplicationinsights.StorageTypeServiceProfiler, armapplicationinsights.ComponentLinkedStorageAccounts{ - Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ - LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), - }, - }, nil) + res, err := clientFactory.NewComponentLinkedStorageAccountsClient().Delete(ctx, "someResourceGroupName", "myComponent", armapplicationinsights.StorageTypeServiceProfiler, 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.ComponentLinkedStorageAccounts = armapplicationinsights.ComponentLinkedStorageAccounts{ - // Name: to.Ptr("serviceprofile"), - // Type: to.Ptr("microsoft.insights/components/linkedStorageAccounts"), - // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupNameproviders/microsoft.insights/components/myComponent/linkedStorageAccounts/serviceprofiler"), - // Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ - // LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), - // }, + // res = armapplicationinsights.ComponentLinkedStorageAccountsClientDeleteResponse{ // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2020-03-01-preview/examples/ComponentLinkedStorageAccountsUpdate.json -func ExampleComponentLinkedStorageAccountsClient_Update() { +// Generated from example definition: 2020-03-01-preview/ComponentLinkedStorageAccountsGet.json +func ExampleComponentLinkedStorageAccountsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("86dc51d3-92ed-4d7e-947a-775ea79b4918", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewComponentLinkedStorageAccountsClient().Update(ctx, "someResourceGroupName", "myComponent", armapplicationinsights.StorageTypeServiceProfiler, armapplicationinsights.ComponentLinkedStorageAccountsPatch{ - Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ - LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), - }, - }, nil) + res, err := clientFactory.NewComponentLinkedStorageAccountsClient().Get(ctx, "someResourceGroupName", "myComponent", armapplicationinsights.StorageTypeServiceProfiler, 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.ComponentLinkedStorageAccounts = armapplicationinsights.ComponentLinkedStorageAccounts{ - // Name: to.Ptr("serviceprofile"), - // Type: to.Ptr("microsoft.insights/components/linkedStorageAccounts"), - // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/microsoft.insights/components/myComponent/linkedStorageAccounts/serviceprofiler"), - // Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ - // LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), + // res = armapplicationinsights.ComponentLinkedStorageAccountsClientGetResponse{ + // ComponentLinkedStorageAccounts: armapplicationinsights.ComponentLinkedStorageAccounts{ + // Name: to.Ptr("serviceprofile"), + // Type: to.Ptr("microsoft.insights/components/linkedStorageAccounts"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/microsoft.insights/components/myComponent/linkedStorageAccounts/serviceprofiler"), + // Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ + // LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2020-03-01-preview/examples/ComponentLinkedStorageAccountsDelete.json -func ExampleComponentLinkedStorageAccountsClient_Delete() { +// Generated from example definition: 2020-03-01-preview/ComponentLinkedStorageAccountsUpdate.json +func ExampleComponentLinkedStorageAccountsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("86dc51d3-92ed-4d7e-947a-775ea79b4918", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewComponentLinkedStorageAccountsClient().Delete(ctx, "someResourceGroupName", "myComponent", armapplicationinsights.StorageTypeServiceProfiler, nil) + res, err := clientFactory.NewComponentLinkedStorageAccountsClient().Update(ctx, "someResourceGroupName", "myComponent", armapplicationinsights.StorageTypeServiceProfiler, armapplicationinsights.ComponentLinkedStorageAccountsPatch{ + Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ + LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), + }, + }, 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 = armapplicationinsights.ComponentLinkedStorageAccountsClientUpdateResponse{ + // ComponentLinkedStorageAccounts: armapplicationinsights.ComponentLinkedStorageAccounts{ + // Name: to.Ptr("serviceprofile"), + // Type: to.Ptr("microsoft.insights/components/linkedStorageAccounts"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/microsoft.insights/components/myComponent/linkedStorageAccounts/serviceprofiler"), + // Properties: &armapplicationinsights.LinkedStorageAccountsProperties{ + // LinkedStorageAccount: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/someResourceGroupName/providers/Microsoft.Storage/storageAccounts/storageaccountname"), + // }, + // }, + // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentquotastatus_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentquotastatus_client.go index 9f125822a777..c0abd3137eab 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentquotastatus_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentquotastatus_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // ComponentQuotaStatusClient contains the methods for the ComponentQuotaStatus group. // Don't use this type directly, use NewComponentQuotaStatusClient() instead. +// +// Generated from API version 2015-05-01 type ComponentQuotaStatusClient struct { internal *arm.Client subscriptionID string } // NewComponentQuotaStatusClient creates a new instance of ComponentQuotaStatusClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewComponentQuotaStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ComponentQuotaStatusClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewComponentQuotaStatusClient(subscriptionID string, credential azcore.Toke // Get - Returns daily data volume cap (quota) status for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - ComponentQuotaStatusClientGetOptions contains the optional parameters for the ComponentQuotaStatusClient.Get @@ -73,14 +72,14 @@ func (client *ComponentQuotaStatusClient) Get(ctx context.Context, resourceGroup // getCreateRequest creates the Get request. func (client *ComponentQuotaStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ComponentQuotaStatusClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -90,8 +89,8 @@ func (client *ComponentQuotaStatusClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentquotastatus_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentquotastatus_client_example_test.go index 348d752f7c5b..a2ff990ac8ea 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentquotastatus_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/componentquotastatus_client_example_test.go @@ -1,27 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/QuotaStatusGet.json +// Generated from example definition: 2015-05-01/QuotaStatusGet.json func ExampleComponentQuotaStatusClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -32,9 +29,11 @@ func ExampleComponentQuotaStatusClient_Get() { // 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.ComponentQuotaStatus = armapplicationinsights.ComponentQuotaStatus{ - // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), - // ExpirationTime: to.Ptr("2017-08-10T05:00:00"), - // ShouldBeThrottled: to.Ptr(true), + // res = armapplicationinsights.ComponentQuotaStatusClientGetResponse{ + // ComponentQuotaStatus: armapplicationinsights.ComponentQuotaStatus{ + // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), + // ExpirationTime: to.Ptr("2017-08-10T05:00:00"), + // ShouldBeThrottled: to.Ptr(true), + // }, // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/components_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/components_client.go index 30b4c01829fd..d82b73ca21fd 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/components_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/components_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // ComponentsClient contains the methods for the Components group. // Don't use this type directly, use NewComponentsClient() instead. +// +// Generated from API version 2020-02-02 type ComponentsClient struct { internal *arm.Client subscriptionID string } // NewComponentsClient creates a new instance of ComponentsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewComponentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ComponentsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -43,8 +44,6 @@ func NewComponentsClient(subscriptionID string, credential azcore.TokenCredentia // CreateOrUpdate - Creates (or updates) an Application Insights component. Note: You cannot specify a different value for // InstrumentationKey nor AppId in the Put operation. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-02-02 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - insightProperties - Properties that need to be specified to create an Application Insights component. @@ -75,14 +74,14 @@ func (client *ComponentsClient) CreateOrUpdate(ctx context.Context, resourceGrou // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *ComponentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, insightProperties Component, _ *ComponentsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -92,9 +91,10 @@ func (client *ComponentsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-02-02") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200202) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, insightProperties); err != nil { return nil, err } @@ -112,8 +112,6 @@ func (client *ComponentsClient) createOrUpdateHandleResponse(resp *http.Response // Delete - Deletes an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-02-02 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - ComponentsClientDeleteOptions contains the optional parameters for the ComponentsClient.Delete method. @@ -141,14 +139,14 @@ func (client *ComponentsClient) Delete(ctx context.Context, resourceGroupName st // deleteCreateRequest creates the Delete request. func (client *ComponentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ComponentsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -158,16 +156,13 @@ func (client *ComponentsClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-02-02") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} + reqQP.Set("api-version", version20200202) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // Get - Returns an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-02-02 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - ComponentsClientGetOptions contains the optional parameters for the ComponentsClient.Get method. @@ -196,14 +191,14 @@ func (client *ComponentsClient) Get(ctx context.Context, resourceGroupName strin // getCreateRequest creates the Get request. func (client *ComponentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ComponentsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -213,8 +208,8 @@ func (client *ComponentsClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-02-02") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200202) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -230,8 +225,6 @@ func (client *ComponentsClient) getHandleResponse(resp *http.Response) (Componen // GetPurgeStatus - Get status for an ongoing purge operation. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-02-02 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - purgeID - In a purge status request, this is the Id of the operation the status of which is returned. @@ -262,14 +255,14 @@ func (client *ComponentsClient) GetPurgeStatus(ctx context.Context, resourceGrou // getPurgeStatusCreateRequest creates the GetPurgeStatus request. func (client *ComponentsClient) getPurgeStatusCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, purgeID string, _ *ComponentsClientGetPurgeStatusOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -283,8 +276,8 @@ func (client *ComponentsClient) getPurgeStatusCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-02-02") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200202) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -299,8 +292,6 @@ func (client *ComponentsClient) getPurgeStatusHandleResponse(resp *http.Response } // NewListPager - Gets a list of all Application Insights components within a subscription. -// -// Generated from API version 2020-02-02 // - options - ComponentsClientListOptions contains the optional parameters for the ComponentsClient.NewListPager method. func (client *ComponentsClient) NewListPager(options *ComponentsClientListOptions) *runtime.Pager[ComponentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ComponentsClientListResponse]{ @@ -337,8 +328,8 @@ func (client *ComponentsClient) listCreateRequest(ctx context.Context, _ *Compon return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-02-02") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200202) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -353,8 +344,6 @@ func (client *ComponentsClient) listHandleResponse(resp *http.Response) (Compone } // NewListByResourceGroupPager - Gets a list of Application Insights components within a resource group. -// -// Generated from API version 2020-02-02 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ComponentsClientListByResourceGroupOptions contains the optional parameters for the ComponentsClient.NewListByResourceGroupPager // method. @@ -384,21 +373,21 @@ func (client *ComponentsClient) NewListByResourceGroupPager(resourceGroupName st // listByResourceGroupCreateRequest creates the ListByResourceGroup request. func (client *ComponentsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ComponentsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-02-02") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200202) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -414,16 +403,13 @@ func (client *ComponentsClient) listByResourceGroupHandleResponse(resp *http.Res // Purge - Purges data in an Application Insights component by a set of user-defined filters. // In order to manage system resources, purge requests are throttled at 50 requests per hour. You should batch the execution -// of purge requests by sending a single command whose predicate includes all -// user identities that require purging. Use the in operator to specify multiple identities. You should run the query prior -// to using for a purge request to verify that the results are expected. Note: -// this operation is intended for Classic resources, for workspace-based Application Insights resource please run purge operation -// (directly on the -// workspace)(https://docs.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge) , scoped to specific resource -// id. +// of purge requests by sending a single command whose predicate includes all user identities that require purging. Use the +// in operator to specify multiple identities. You should run the query prior to using for a purge request to verify that +// the results are expected. +// Note: this operation is intended for Classic resources, for workspace-based Application Insights resource please run purge +// operation (directly on the workspace)(https://docs.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge) , scoped +// to specific resource id. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-02-02 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - body - Describes the body of a request to purge data in a single table of an Application Insights component @@ -453,14 +439,14 @@ func (client *ComponentsClient) Purge(ctx context.Context, resourceGroupName str // purgeCreateRequest creates the Purge request. func (client *ComponentsClient) purgeCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, body ComponentPurgeBody, _ *ComponentsClientPurgeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -470,9 +456,10 @@ func (client *ComponentsClient) purgeCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-02-02") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200202) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { return nil, err } @@ -490,8 +477,6 @@ func (client *ComponentsClient) purgeHandleResponse(resp *http.Response) (Compon // UpdateTags - Updates an existing component's tags. To update other fields use the CreateOrUpdate method. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-02-02 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - componentTags - Updated tag information to set into the component instance. @@ -521,14 +506,14 @@ func (client *ComponentsClient) UpdateTags(ctx context.Context, resourceGroupNam // updateTagsCreateRequest creates the UpdateTags request. func (client *ComponentsClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, componentTags TagsResource, _ *ComponentsClientUpdateTagsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -538,9 +523,10 @@ func (client *ComponentsClient) updateTagsCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-02-02") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20200202) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, componentTags); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/components_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/components_client_example_test.go index 70e9e1e00bb3..c92329f6bf8f 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/components_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/components_client_example_test.go @@ -1,217 +1,168 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsList.json -func ExampleComponentsClient_NewListPager() { +// Generated from example definition: 2020-02-02/ComponentsCreate.json +func ExampleComponentsClient_CreateOrUpdate_componentCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewComponentsClient().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.ComponentListResult = armapplicationinsights.ComponentListResult{ - // Value: []*armapplicationinsights.Component{ - // { - // Name: to.Ptr("my-component"), - // Type: to.Ptr("Microsoft.Insights/components"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), - // Location: to.Ptr("South Central US"), - // Tags: map[string]*string{ - // }, - // Kind: to.Ptr("web"), - // Properties: &armapplicationinsights.ComponentProperties{ - // AppID: to.Ptr("16526d1a-dfba-4362-a9e9-123456789abc"), - // ApplicationID: to.Ptr("my-component"), - // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - // ConnectionString: to.Ptr("InstrumentationKey=dc5931c7-a7ad-4ad0-89d6-123456789abc"), - // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-14T12:24:05.004Z"); return t}()), - // DisableIPMasking: to.Ptr(false), - // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - // HockeyAppID: to.Ptr(""), - // HockeyAppToken: to.Ptr(""), - // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), - // InstrumentationKey: to.Ptr("dc5931c7-a7ad-4ad0-89d6-123456789abc"), - // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - // SamplingPercentage: to.Ptr[float64](75), - // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), - // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // }, - // }, - // { - // Name: to.Ptr("my-other-component"), - // Type: to.Ptr("Microsoft.Insights/components"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-other-resource-group/providers/Microsoft.Insights/components/my-other-component"), - // Location: to.Ptr("South Central US"), - // Tags: map[string]*string{ - // }, - // Kind: to.Ptr("web"), - // Properties: &armapplicationinsights.ComponentProperties{ - // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), - // ApplicationID: to.Ptr("my-other-component"), - // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), - // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.593Z"); return t}()), - // DisableIPMasking: to.Ptr(false), - // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - // HockeyAppID: to.Ptr(""), - // HockeyAppToken: to.Ptr(""), - // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), - // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), - // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - // SamplingPercentage: to.Ptr[float64](30), - // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), - // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // }, - // }}, - // } + res, err := clientFactory.NewComponentsClient().CreateOrUpdate(ctx, "my-resource-group", "my-component", armapplicationinsights.Component{ + Kind: to.Ptr("web"), + Location: to.Ptr("South Central US"), + Properties: &armapplicationinsights.ComponentProperties{ + ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + }, + }, 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 = armapplicationinsights.ComponentsClientCreateOrUpdateResponse{ + // Component: armapplicationinsights.Component{ + // Name: to.Ptr("my-component"), + // Type: to.Ptr("Microsoft.Insights/components"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), + // Kind: to.Ptr("web"), + // Location: to.Ptr("South Central US"), + // Properties: &armapplicationinsights.ComponentProperties{ + // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), + // ApplicationID: to.Ptr("my-component"), + // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.5934061+00:00"); return t}()), + // DisableIPMasking: to.Ptr(false), + // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + // HockeyAppID: to.Ptr(""), + // HockeyAppToken: to.Ptr(""), + // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), + // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), + // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + // SamplingPercentage: to.Ptr[float64](100), + // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), + // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + // ProvisioningState: to.Ptr("Succeeded"), + // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // }, + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsListByResourceGroup.json -func ExampleComponentsClient_NewListByResourceGroupPager() { +// Generated from example definition: 2020-02-02/ComponentsUpdate.json +func ExampleComponentsClient_CreateOrUpdate_componentUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewComponentsClient().NewListByResourceGroupPager("my-resource-group", 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.ComponentListResult = armapplicationinsights.ComponentListResult{ - // Value: []*armapplicationinsights.Component{ - // { - // Name: to.Ptr("my-component"), - // Type: to.Ptr("Microsoft.Insights/components"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), - // Location: to.Ptr("South Central US"), - // Tags: map[string]*string{ - // }, - // Kind: to.Ptr("web"), - // Properties: &armapplicationinsights.ComponentProperties{ - // AppID: to.Ptr("16526d1a-dfba-4362-a9e9-123456789abc"), - // ApplicationID: to.Ptr("my-component"), - // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - // ConnectionString: to.Ptr("InstrumentationKey=dc5931c7-a7ad-4ad0-89d6-123456789abc"), - // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-14T12:24:05.004Z"); return t}()), - // DisableIPMasking: to.Ptr(false), - // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - // HockeyAppID: to.Ptr(""), - // HockeyAppToken: to.Ptr(""), - // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), - // InstrumentationKey: to.Ptr("dc5931c7-a7ad-4ad0-89d6-123456789abc"), - // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - // SamplingPercentage: to.Ptr[float64](100), - // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), - // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // }, - // }, - // { - // Name: to.Ptr("my-other-component"), - // Type: to.Ptr("Microsoft.Insights/components"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-other-resource-group/providers/Microsoft.Insights/components/my-other-component"), - // Location: to.Ptr("South Central US"), - // Tags: map[string]*string{ - // }, - // Kind: to.Ptr("web"), - // Properties: &armapplicationinsights.ComponentProperties{ - // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), - // ApplicationID: to.Ptr("my-other-component"), - // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), - // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.593Z"); return t}()), - // DisableIPMasking: to.Ptr(false), - // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - // HockeyAppID: to.Ptr(""), - // HockeyAppToken: to.Ptr(""), - // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), - // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), - // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - // SamplingPercentage: to.Ptr[float64](50), - // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), - // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // }, - // }}, - // } + res, err := clientFactory.NewComponentsClient().CreateOrUpdate(ctx, "my-resource-group", "my-component", armapplicationinsights.Component{ + Kind: to.Ptr("web"), + Location: to.Ptr("South Central US"), + Tags: map[string]*string{ + "ApplicationGatewayType": to.Ptr("Internal-Only"), + "BillingEntity": to.Ptr("Self"), + }, + }, 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 = armapplicationinsights.ComponentsClientCreateOrUpdateResponse{ + // Component: armapplicationinsights.Component{ + // Name: to.Ptr("my-component"), + // Type: to.Ptr("Microsoft.Insights/components"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), + // Kind: to.Ptr("web"), + // Location: to.Ptr("South Central US"), + // Properties: &armapplicationinsights.ComponentProperties{ + // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), + // ApplicationID: to.Ptr("my-component"), + // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.5934061+00:00"); return t}()), + // DisableIPMasking: to.Ptr(false), + // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + // HockeyAppID: to.Ptr(""), + // HockeyAppToken: to.Ptr(""), + // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), + // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), + // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + // SamplingPercentage: to.Ptr[float64](100), + // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), + // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + // ProvisioningState: to.Ptr("Succeeded"), + // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // }, + // Tags: map[string]*string{ + // "ApplicationGatewayType": to.Ptr("Internal-Only"), + // "BillingEntity": to.Ptr("Self"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsDelete.json +// Generated from example definition: 2020-02-02/ComponentsDelete.json func ExampleComponentsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewComponentsClient().Delete(ctx, "my-resource-group", "my-component", nil) + res, err := clientFactory.NewComponentsClient().Delete(ctx, "my-resource-group", "my-component", 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 = armapplicationinsights.ComponentsClientDeleteResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsGet.json +// Generated from example definition: 2020-02-02/ComponentsGet.json func ExampleComponentsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -222,223 +173,255 @@ func ExampleComponentsClient_Get() { // 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.Component = armapplicationinsights.Component{ - // Name: to.Ptr("my-component"), - // Type: to.Ptr("Microsoft.Insights/components"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), - // Location: to.Ptr("South Central US"), - // Tags: map[string]*string{ - // }, - // Kind: to.Ptr("web"), - // Properties: &armapplicationinsights.ComponentProperties{ - // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), - // ApplicationID: to.Ptr("my-component"), - // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), - // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.593Z"); return t}()), - // DisableIPMasking: to.Ptr(false), - // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - // HockeyAppID: to.Ptr(""), - // HockeyAppToken: to.Ptr(""), - // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), - // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), - // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - // SamplingPercentage: to.Ptr[float64](100), - // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), - // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // res = armapplicationinsights.ComponentsClientGetResponse{ + // Component: armapplicationinsights.Component{ + // Name: to.Ptr("my-component"), + // Type: to.Ptr("Microsoft.Insights/components"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), + // Kind: to.Ptr("web"), + // Location: to.Ptr("South Central US"), + // Properties: &armapplicationinsights.ComponentProperties{ + // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), + // ApplicationID: to.Ptr("my-component"), + // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.5934061+00:00"); return t}()), + // DisableIPMasking: to.Ptr(false), + // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + // HockeyAppID: to.Ptr(""), + // HockeyAppToken: to.Ptr(""), + // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), + // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), + // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + // SamplingPercentage: to.Ptr[float64](100), + // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), + // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + // ProvisioningState: to.Ptr("Succeeded"), + // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // }, + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsCreate.json -func ExampleComponentsClient_CreateOrUpdate_componentCreate() { +// Generated from example definition: 2020-02-02/ComponentsPurgeStatus.json +func ExampleComponentsClient_GetPurgeStatus() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("00000000-0000-0000-0000-00000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewComponentsClient().CreateOrUpdate(ctx, "my-resource-group", "my-component", armapplicationinsights.Component{ - Location: to.Ptr("South Central US"), - Kind: to.Ptr("web"), - Properties: &armapplicationinsights.ComponentProperties{ - ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - }, - }, nil) + res, err := clientFactory.NewComponentsClient().GetPurgeStatus(ctx, "OIAutoRest5123", "aztest5048", "purge-970318e7-b859-4edb-8903-83b1b54d0b74", 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.Component = armapplicationinsights.Component{ - // Name: to.Ptr("my-component"), - // Type: to.Ptr("Microsoft.Insights/components"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), - // Location: to.Ptr("South Central US"), - // Tags: map[string]*string{ - // }, - // Kind: to.Ptr("web"), - // Properties: &armapplicationinsights.ComponentProperties{ - // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), - // ApplicationID: to.Ptr("my-component"), - // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), - // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.593Z"); return t}()), - // DisableIPMasking: to.Ptr(false), - // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - // HockeyAppID: to.Ptr(""), - // HockeyAppToken: to.Ptr(""), - // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), - // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), - // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - // SamplingPercentage: to.Ptr[float64](100), - // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), - // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // res = armapplicationinsights.ComponentsClientGetPurgeStatusResponse{ + // ComponentPurgeStatusResponse: armapplicationinsights.ComponentPurgeStatusResponse{ + // Status: to.Ptr(armapplicationinsights.PurgeStateCompleted), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsUpdate.json -func ExampleComponentsClient_CreateOrUpdate_componentUpdate() { +// Generated from example definition: 2020-02-02/ComponentsList.json +func ExampleComponentsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewComponentsClient().CreateOrUpdate(ctx, "my-resource-group", "my-component", armapplicationinsights.Component{ - Location: to.Ptr("South Central US"), - Tags: map[string]*string{ - "ApplicationGatewayType": to.Ptr("Internal-Only"), - "BillingEntity": to.Ptr("Self"), - }, - Kind: to.Ptr("web"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewComponentsClient().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 = armapplicationinsights.ComponentsClientListResponse{ + // ComponentListResult: armapplicationinsights.ComponentListResult{ + // Value: []*armapplicationinsights.Component{ + // { + // Name: to.Ptr("my-component"), + // Type: to.Ptr("Microsoft.Insights/components"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), + // Kind: to.Ptr("web"), + // Location: to.Ptr("South Central US"), + // Properties: &armapplicationinsights.ComponentProperties{ + // AppID: to.Ptr("16526d1a-dfba-4362-a9e9-123456789abc"), + // ApplicationID: to.Ptr("my-component"), + // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + // ConnectionString: to.Ptr("InstrumentationKey=dc5931c7-a7ad-4ad0-89d6-123456789abc"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-14T12:24:05.0041213+00:00"); return t}()), + // DisableIPMasking: to.Ptr(false), + // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + // HockeyAppID: to.Ptr(""), + // HockeyAppToken: to.Ptr(""), + // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), + // InstrumentationKey: to.Ptr("dc5931c7-a7ad-4ad0-89d6-123456789abc"), + // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + // SamplingPercentage: to.Ptr[float64](75), + // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), + // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + // ProvisioningState: to.Ptr("Succeeded"), + // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // }, + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // }, + // { + // Name: to.Ptr("my-other-component"), + // Type: to.Ptr("Microsoft.Insights/components"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-other-resource-group/providers/Microsoft.Insights/components/my-other-component"), + // Kind: to.Ptr("web"), + // Location: to.Ptr("South Central US"), + // Properties: &armapplicationinsights.ComponentProperties{ + // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), + // ApplicationID: to.Ptr("my-other-component"), + // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.5934061+00:00"); return t}()), + // DisableIPMasking: to.Ptr(false), + // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + // HockeyAppID: to.Ptr(""), + // HockeyAppToken: to.Ptr(""), + // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), + // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), + // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + // SamplingPercentage: to.Ptr[float64](30), + // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), + // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + // ProvisioningState: to.Ptr("Succeeded"), + // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // }, + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // }, + // }, + // }, + // } } - // 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.Component = armapplicationinsights.Component{ - // Name: to.Ptr("my-component"), - // Type: to.Ptr("Microsoft.Insights/components"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), - // Location: to.Ptr("South Central US"), - // Tags: map[string]*string{ - // "ApplicationGatewayType": to.Ptr("Internal-Only"), - // "BillingEntity": to.Ptr("Self"), - // }, - // Kind: to.Ptr("web"), - // Properties: &armapplicationinsights.ComponentProperties{ - // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), - // ApplicationID: to.Ptr("my-component"), - // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), - // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.593Z"); return t}()), - // DisableIPMasking: to.Ptr(false), - // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - // HockeyAppID: to.Ptr(""), - // HockeyAppToken: to.Ptr(""), - // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), - // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), - // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - // SamplingPercentage: to.Ptr[float64](100), - // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), - // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsUpdateTagsOnly.json -func ExampleComponentsClient_UpdateTags() { +// Generated from example definition: 2020-02-02/ComponentsListByResourceGroup.json +func ExampleComponentsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewComponentsClient().UpdateTags(ctx, "my-resource-group", "my-component", armapplicationinsights.TagsResource{ - Tags: map[string]*string{ - "ApplicationGatewayType": to.Ptr("Internal-Only"), - "BillingEntity": to.Ptr("Self"), - "Color": to.Ptr("AzureBlue"), - "CustomField_01": to.Ptr("Custom text in some random field named randomly"), - "NodeType": to.Ptr("Edge"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewComponentsClient().NewListByResourceGroupPager("my-resource-group", 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 = armapplicationinsights.ComponentsClientListByResourceGroupResponse{ + // ComponentListResult: armapplicationinsights.ComponentListResult{ + // Value: []*armapplicationinsights.Component{ + // { + // Name: to.Ptr("my-component"), + // Type: to.Ptr("Microsoft.Insights/components"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), + // Kind: to.Ptr("web"), + // Location: to.Ptr("South Central US"), + // Properties: &armapplicationinsights.ComponentProperties{ + // AppID: to.Ptr("16526d1a-dfba-4362-a9e9-123456789abc"), + // ApplicationID: to.Ptr("my-component"), + // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + // ConnectionString: to.Ptr("InstrumentationKey=dc5931c7-a7ad-4ad0-89d6-123456789abc"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-14T12:24:05.0041213+00:00"); return t}()), + // DisableIPMasking: to.Ptr(false), + // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + // HockeyAppID: to.Ptr(""), + // HockeyAppToken: to.Ptr(""), + // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), + // InstrumentationKey: to.Ptr("dc5931c7-a7ad-4ad0-89d6-123456789abc"), + // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + // SamplingPercentage: to.Ptr[float64](100), + // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), + // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + // ProvisioningState: to.Ptr("Succeeded"), + // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // }, + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // }, + // { + // Name: to.Ptr("my-other-component"), + // Type: to.Ptr("Microsoft.Insights/components"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-other-resource-group/providers/Microsoft.Insights/components/my-other-component"), + // Kind: to.Ptr("web"), + // Location: to.Ptr("South Central US"), + // Properties: &armapplicationinsights.ComponentProperties{ + // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), + // ApplicationID: to.Ptr("my-other-component"), + // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.5934061+00:00"); return t}()), + // DisableIPMasking: to.Ptr(false), + // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + // HockeyAppID: to.Ptr(""), + // HockeyAppToken: to.Ptr(""), + // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), + // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), + // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + // SamplingPercentage: to.Ptr[float64](50), + // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), + // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + // ProvisioningState: to.Ptr("Succeeded"), + // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // }, + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // }, + // }, + // }, + // } } - // 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.Component = armapplicationinsights.Component{ - // Name: to.Ptr("my-component"), - // Type: to.Ptr("Microsoft.Insights/components"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), - // Location: to.Ptr("South Central US"), - // Tags: map[string]*string{ - // "ApplicationGatewayType": to.Ptr("Internal-Only"), - // "BillingEntity": to.Ptr("Self"), - // "Color": to.Ptr("AzureBlue"), - // "CustomField_01": to.Ptr("Custom text in some random field named randomly"), - // "NodeType": to.Ptr("Edge"), - // }, - // Kind: to.Ptr("web"), - // Properties: &armapplicationinsights.ComponentProperties{ - // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), - // ApplicationID: to.Ptr("my-component"), - // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), - // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), - // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.593Z"); return t}()), - // DisableIPMasking: to.Ptr(false), - // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), - // HockeyAppID: to.Ptr(""), - // HockeyAppToken: to.Ptr(""), - // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), - // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), - // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), - // SamplingPercentage: to.Ptr[float64](100), - // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), - // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsPurge.json +// Generated from example definition: 2020-02-02/ComponentsPurge.json func ExampleComponentsClient_Purge() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("00000000-0000-0000-0000-00000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -448,7 +431,8 @@ func ExampleComponentsClient_Purge() { Column: to.Ptr("TimeGenerated"), Operator: to.Ptr(">"), Value: "2017-09-01T00:00:00", - }}, + }, + }, Table: to.Ptr("Heartbeat"), }, nil) if err != nil { @@ -456,25 +440,66 @@ func ExampleComponentsClient_Purge() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsPurgeStatus.json -func ExampleComponentsClient_GetPurgeStatus() { +// Generated from example definition: 2020-02-02/ComponentsUpdateTagsOnly.json +func ExampleComponentsClient_UpdateTags() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewComponentsClient().GetPurgeStatus(ctx, "OIAutoRest5123", "aztest5048", "purge-970318e7-b859-4edb-8903-83b1b54d0b74", nil) + res, err := clientFactory.NewComponentsClient().UpdateTags(ctx, "my-resource-group", "my-component", armapplicationinsights.TagsResource{ + Tags: map[string]*string{ + "ApplicationGatewayType": to.Ptr("Internal-Only"), + "BillingEntity": to.Ptr("Self"), + "Color": to.Ptr("AzureBlue"), + "CustomField_01": to.Ptr("Custom text in some random field named randomly"), + "NodeType": to.Ptr("Edge"), + }, + }, 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.ComponentPurgeStatusResponse = armapplicationinsights.ComponentPurgeStatusResponse{ - // Status: to.Ptr(armapplicationinsights.PurgeStateCompleted), + // res = armapplicationinsights.ComponentsClientUpdateTagsResponse{ + // Component: armapplicationinsights.Component{ + // Name: to.Ptr("my-component"), + // Type: to.Ptr("Microsoft.Insights/components"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"), + // Kind: to.Ptr("web"), + // Location: to.Ptr("South Central US"), + // Properties: &armapplicationinsights.ComponentProperties{ + // AppID: to.Ptr("887f4bfd-b5fd-40d7-9fc3-123456789abc"), + // ApplicationID: to.Ptr("my-component"), + // ApplicationType: to.Ptr(armapplicationinsights.ApplicationTypeWeb), + // ConnectionString: to.Ptr("InstrumentationKey=bc095013-3cf2-45ac-ab47-123456789abc"), + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-24T01:05:38.5934061+00:00"); return t}()), + // DisableIPMasking: to.Ptr(false), + // FlowType: to.Ptr(armapplicationinsights.FlowTypeBluefield), + // HockeyAppID: to.Ptr(""), + // HockeyAppToken: to.Ptr(""), + // IngestionMode: to.Ptr(armapplicationinsights.IngestionModeLogAnalytics), + // InstrumentationKey: to.Ptr("bc095013-3cf2-45ac-ab47-123456789abc"), + // RequestSource: to.Ptr(armapplicationinsights.RequestSourceRest), + // SamplingPercentage: to.Ptr[float64](100), + // TenantID: to.Ptr("f438d567-7177-4fe1-a5e3-123456789abc"), + // WorkspaceResourceID: to.Ptr("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + // ProvisioningState: to.Ptr("Succeeded"), + // PublicNetworkAccessForIngestion: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // PublicNetworkAccessForQuery: to.Ptr(armapplicationinsights.PublicNetworkAccessTypeEnabled), + // }, + // Tags: map[string]*string{ + // "ApplicationGatewayType": to.Ptr("Internal-Only"), + // "BillingEntity": to.Ptr("Self"), + // "Color": to.Ptr("AzureBlue"), + // "CustomField_01": to.Ptr("Custom text in some random field named randomly"), + // "NodeType": to.Ptr("Edge"), + // }, + // }, // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/constants.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/constants.go index a7982a389f61..d9a2821f4e93 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/constants.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/constants.go @@ -1,21 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights const ( - moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights" - moduleVersion = "v2.0.0-beta.3" + version20150501 string = "2015-05-01" + version20200202 string = "2020-02-02" + version20200301Preview string = "2020-03-01-preview" + version20201120 string = "2020-11-20" + version20210308 string = "2021-03-08" + version20211014 string = "2021-10-14" + version20220615 string = "2022-06-15" + version20230601 string = "2023-06-01" + version20240201Preview string = "2024-02-01-preview" ) // ApplicationType - Type of application being monitored. type ApplicationType string const ( + // ApplicationTypeOther - other ApplicationTypeOther ApplicationType = "other" - ApplicationTypeWeb ApplicationType = "web" + // ApplicationTypeWeb - web + ApplicationTypeWeb ApplicationType = "web" ) // PossibleApplicationTypeValues returns the possible values for the ApplicationType const type. @@ -29,10 +37,14 @@ func PossibleApplicationTypeValues() []ApplicationType { type CategoryType string const ( + // CategoryTypePerformance - performance CategoryTypePerformance CategoryType = "performance" - CategoryTypeRetention CategoryType = "retention" - CategoryTypeTSG CategoryType = "TSG" - CategoryTypeWorkbook CategoryType = "workbook" + // CategoryTypeRetention - retention + CategoryTypeRetention CategoryType = "retention" + // CategoryTypeTSG - TSG + CategoryTypeTSG CategoryType = "TSG" + // CategoryTypeWorkbook - workbook + CategoryTypeWorkbook CategoryType = "workbook" ) // PossibleCategoryTypeValues returns the possible values for the CategoryType const type. @@ -45,14 +57,18 @@ func PossibleCategoryTypeValues() []CategoryType { } } -// CreatedByType - The type of identity that created the resource. +// CreatedByType - The kind of entity that created the resource. type CreatedByType string const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" ) // PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. @@ -68,14 +84,22 @@ func PossibleCreatedByTypeValues() []CreatedByType { type FavoriteSourceType string const ( - FavoriteSourceTypeEvents FavoriteSourceType = "events" - FavoriteSourceTypeFunnel FavoriteSourceType = "funnel" - FavoriteSourceTypeImpact FavoriteSourceType = "impact" - FavoriteSourceTypeNotebook FavoriteSourceType = "notebook" - FavoriteSourceTypeRetention FavoriteSourceType = "retention" + // FavoriteSourceTypeEvents - events + FavoriteSourceTypeEvents FavoriteSourceType = "events" + // FavoriteSourceTypeFunnel - funnel + FavoriteSourceTypeFunnel FavoriteSourceType = "funnel" + // FavoriteSourceTypeImpact - impact + FavoriteSourceTypeImpact FavoriteSourceType = "impact" + // FavoriteSourceTypeNotebook - notebook + FavoriteSourceTypeNotebook FavoriteSourceType = "notebook" + // FavoriteSourceTypeRetention - retention + FavoriteSourceTypeRetention FavoriteSourceType = "retention" + // FavoriteSourceTypeSegmentation - segmentation FavoriteSourceTypeSegmentation FavoriteSourceType = "segmentation" - FavoriteSourceTypeSessions FavoriteSourceType = "sessions" - FavoriteSourceTypeUserflows FavoriteSourceType = "userflows" + // FavoriteSourceTypeSessions - sessions + FavoriteSourceTypeSessions FavoriteSourceType = "sessions" + // FavoriteSourceTypeUserflows - userflows + FavoriteSourceTypeUserflows FavoriteSourceType = "userflows" ) // PossibleFavoriteSourceTypeValues returns the possible values for the FavoriteSourceType const type. @@ -97,8 +121,10 @@ func PossibleFavoriteSourceTypeValues() []FavoriteSourceType { type FavoriteType string const ( + // FavoriteTypeShared - shared FavoriteTypeShared FavoriteType = "shared" - FavoriteTypeUser FavoriteType = "user" + // FavoriteTypeUser - user + FavoriteTypeUser FavoriteType = "user" ) // PossibleFavoriteTypeValues returns the possible values for the FavoriteType const type. @@ -114,6 +140,7 @@ func PossibleFavoriteTypeValues() []FavoriteType { type FlowType string const ( + // FlowTypeBluefield - Bluefield FlowTypeBluefield FlowType = "Bluefield" ) @@ -128,9 +155,12 @@ func PossibleFlowTypeValues() []FlowType { type IngestionMode string const ( - IngestionModeApplicationInsights IngestionMode = "ApplicationInsights" + // IngestionModeApplicationInsights - ApplicationInsights + IngestionModeApplicationInsights IngestionMode = "ApplicationInsights" + // IngestionModeApplicationInsightsWithDiagnosticSettings - ApplicationInsightsWithDiagnosticSettings IngestionModeApplicationInsightsWithDiagnosticSettings IngestionMode = "ApplicationInsightsWithDiagnosticSettings" - IngestionModeLogAnalytics IngestionMode = "LogAnalytics" + // IngestionModeLogAnalytics - LogAnalytics + IngestionModeLogAnalytics IngestionMode = "LogAnalytics" ) // PossibleIngestionModeValues returns the possible values for the IngestionMode const type. @@ -147,8 +177,10 @@ func PossibleIngestionModeValues() []IngestionMode { type ItemScope string const ( + // ItemScopeShared - shared ItemScopeShared ItemScope = "shared" - ItemScopeUser ItemScope = "user" + // ItemScopeUser - user + ItemScopeUser ItemScope = "user" ) // PossibleItemScopeValues returns the possible values for the ItemScope const type. @@ -162,7 +194,9 @@ func PossibleItemScopeValues() []ItemScope { type ItemScopePath string const ( - ItemScopePathAnalyticsItems ItemScopePath = "analyticsItems" + // ItemScopePathAnalyticsItems - analyticsItems + ItemScopePathAnalyticsItems ItemScopePath = "analyticsItems" + // ItemScopePathMyanalyticsItems - myanalyticsItems ItemScopePathMyanalyticsItems ItemScopePath = "myanalyticsItems" ) @@ -178,10 +212,14 @@ func PossibleItemScopePathValues() []ItemScopePath { type ItemType string const ( + // ItemTypeFunction - function ItemTypeFunction ItemType = "function" - ItemTypeNone ItemType = "none" - ItemTypeQuery ItemType = "query" - ItemTypeRecent ItemType = "recent" + // ItemTypeNone - none + ItemTypeNone ItemType = "none" + // ItemTypeQuery - query + ItemTypeQuery ItemType = "query" + // ItemTypeRecent - recent + ItemTypeRecent ItemType = "recent" ) // PossibleItemTypeValues returns the possible values for the ItemType const type. @@ -197,11 +235,16 @@ func PossibleItemTypeValues() []ItemType { type ItemTypeParameter string const ( - ItemTypeParameterFolder ItemTypeParameter = "folder" + // ItemTypeParameterFolder - folder + ItemTypeParameterFolder ItemTypeParameter = "folder" + // ItemTypeParameterFunction - function ItemTypeParameterFunction ItemTypeParameter = "function" - ItemTypeParameterNone ItemTypeParameter = "none" - ItemTypeParameterQuery ItemTypeParameter = "query" - ItemTypeParameterRecent ItemTypeParameter = "recent" + // ItemTypeParameterNone - none + ItemTypeParameterNone ItemTypeParameter = "none" + // ItemTypeParameterQuery - query + ItemTypeParameterQuery ItemTypeParameter = "query" + // ItemTypeParameterRecent - recent + ItemTypeParameterRecent ItemTypeParameter = "recent" ) // PossibleItemTypeParameterValues returns the possible values for the ItemTypeParameter const type. @@ -219,10 +262,14 @@ func PossibleItemTypeParameterValues() []ItemTypeParameter { type ManagedServiceIdentityType string const ( - ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" - ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + // ManagedServiceIdentityTypeNone - No managed identity. + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + // ManagedServiceIdentityTypeSystemAssigned - System assigned managed identity. + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + // ManagedServiceIdentityTypeSystemAssignedUserAssigned - System and user assigned managed identity. ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" - ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" + // ManagedServiceIdentityTypeUserAssigned - User assigned managed identity. + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" ) // PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. @@ -258,8 +305,10 @@ func PossiblePublicNetworkAccessTypeValues() []PublicNetworkAccessType { type PurgeState string const ( + // PurgeStateCompleted - completed PurgeStateCompleted PurgeState = "completed" - PurgeStatePending PurgeState = "pending" + // PurgeStatePending - pending + PurgeStatePending PurgeState = "pending" ) // PossiblePurgeStateValues returns the possible values for the PurgeState const type. @@ -275,6 +324,7 @@ func PossiblePurgeStateValues() []PurgeState { type RequestSource string const ( + // RequestSourceRest - rest RequestSourceRest RequestSource = "rest" ) @@ -288,6 +338,7 @@ func PossibleRequestSourceValues() []RequestSource { type StorageType string const ( + // StorageTypeServiceProfiler - ServiceProfiler StorageTypeServiceProfiler StorageType = "ServiceProfiler" ) @@ -302,9 +353,12 @@ func PossibleStorageTypeValues() []StorageType { type WebTestKind string const ( + // WebTestKindMultistep - multistep WebTestKindMultistep WebTestKind = "multistep" - WebTestKindPing WebTestKind = "ping" - WebTestKindStandard WebTestKind = "standard" + // WebTestKindPing - ping + WebTestKindPing WebTestKind = "ping" + // WebTestKindStandard - standard + WebTestKindStandard WebTestKind = "standard" ) // PossibleWebTestKindValues returns the possible values for the WebTestKind const type. @@ -320,6 +374,7 @@ func PossibleWebTestKindValues() []WebTestKind { type WorkbookSharedTypeKind string const ( + // WorkbookSharedTypeKindShared - shared WorkbookSharedTypeKindShared WorkbookSharedTypeKind = "shared" ) @@ -334,6 +389,7 @@ func PossibleWorkbookSharedTypeKindValues() []WorkbookSharedTypeKind { type WorkbookUpdateSharedTypeKind string const ( + // WorkbookUpdateSharedTypeKindShared - shared WorkbookUpdateSharedTypeKindShared WorkbookUpdateSharedTypeKind = "shared" ) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/deletedworkbooks_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/deletedworkbooks_client.go index 54d87adefe9f..8da152b0b5c9 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/deletedworkbooks_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/deletedworkbooks_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // DeletedWorkbooksClient contains the methods for the DeletedWorkbooks group. // Don't use this type directly, use NewDeletedWorkbooksClient() instead. +// +// Generated from API version 2024-02-01-preview type DeletedWorkbooksClient struct { internal *arm.Client subscriptionID string } // NewDeletedWorkbooksClient creates a new instance of DeletedWorkbooksClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewDeletedWorkbooksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeletedWorkbooksClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -41,8 +42,6 @@ func NewDeletedWorkbooksClient(subscriptionID string, credential azcore.TokenCre } // NewListBySubscriptionPager - Get all recently deleted Workbooks in a specified subscription. -// -// Generated from API version 2024-02-01-preview // - options - DeletedWorkbooksClientListBySubscriptionOptions contains the optional parameters for the DeletedWorkbooksClient.NewListBySubscriptionPager // method. func (client *DeletedWorkbooksClient) NewListBySubscriptionPager(options *DeletedWorkbooksClientListBySubscriptionOptions) *runtime.Pager[DeletedWorkbooksClientListBySubscriptionResponse] { @@ -80,14 +79,14 @@ func (client *DeletedWorkbooksClient) listBySubscriptionCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-02-01-preview") + reqQP.Set("api-version", version20240201Preview) if options != nil && options.Category != nil { reqQP.Set("category", string(*options.Category)) } if options != nil && options.Tags != nil { reqQP.Set("tags", strings.Join(options.Tags, ",")) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/deletedworkbooks_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/deletedworkbooks_client_example_test.go index d3eb8a3a342d..856f3c3096d1 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/deletedworkbooks_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/deletedworkbooks_client_example_test.go @@ -1,33 +1,28 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2024-02-01-preview/examples/DeletedWorkbooksList.json +// Generated from example definition: 2024-02-01-preview/DeletedWorkbooksList.json func ExampleDeletedWorkbooksClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewDeletedWorkbooksClient().NewListBySubscriptionPager(&armapplicationinsights.DeletedWorkbooksClientListBySubscriptionOptions{Category: nil, - Tags: []string{}, - }) + pager := clientFactory.NewDeletedWorkbooksClient().NewListBySubscriptionPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -38,48 +33,55 @@ func ExampleDeletedWorkbooksClient_NewListBySubscriptionPager() { _ = 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.DeletedWorkbooksListResult = armapplicationinsights.DeletedWorkbooksListResult{ - // Value: []*armapplicationinsights.DeletedWorkbook{ - // { - // Name: to.Ptr("55555555-6666-7777-8888-999999999999"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/55555555-6666-7777-8888-999999999999"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ + // page = armapplicationinsights.DeletedWorkbooksClientListBySubscriptionResponse{ + // DeletedWorkbooksListResult: armapplicationinsights.DeletedWorkbooksListResult{ + // Value: []*armapplicationinsights.DeletedWorkbook{ + // { + // Name: to.Ptr("55555555-6666-7777-8888-999999999999"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/55555555-6666-7777-8888-999999999999"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.DeletedWorkbookProperties{ + // Description: to.Ptr("Sample workbook1"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("Workbook 1"), + // Revision: to.Ptr("12345678901234567890123456789010"), + // SerializedData: nil, + // SourceID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp1"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T09:07:00.123456Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // }, // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.DeletedWorkbookProperties{ - // Description: to.Ptr("Sample workbook1"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("Workbook 1"), - // Revision: to.Ptr("12345678901234567890123456789010"), - // SourceID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp1"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T09:07:00.123Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), + // { + // Name: to.Ptr("55555555-6666-7777-8888-999999999998"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/my-resource-group2/providers/Microsoft.Insights/workbooks/55555555-6666-7777-8888-999999999998"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.DeletedWorkbookProperties{ + // Description: to.Ptr("Sample workbook2"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("Workbook 2"), + // Revision: to.Ptr("12345678901234567890123456789011"), + // SerializedData: nil, + // SourceID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/my-resource-group2/providers/Microsoft.Web/sites/MyApp2"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-04T09:07:01.123456Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, // }, // }, - // { - // Name: to.Ptr("55555555-6666-7777-8888-999999999998"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/my-resource-group2/providers/Microsoft.Insights/workbooks/55555555-6666-7777-8888-999999999998"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.DeletedWorkbookProperties{ - // Description: to.Ptr("Sample workbook2"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("Workbook 2"), - // Revision: to.Ptr("12345678901234567890123456789011"), - // SourceID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/my-resource-group2/providers/Microsoft.Web/sites/MyApp2"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-04T09:07:01.123Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // }}, + // }, // } } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/exportconfigurations_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/exportconfigurations_client.go index 5b2eec7cbb9c..13c7ffb8fbf6 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/exportconfigurations_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/exportconfigurations_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // ExportConfigurationsClient contains the methods for the ExportConfigurations group. // Don't use this type directly, use NewExportConfigurationsClient() instead. +// +// Generated from API version 2015-05-01 type ExportConfigurationsClient struct { internal *arm.Client subscriptionID string } // NewExportConfigurationsClient creates a new instance of ExportConfigurationsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewExportConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExportConfigurationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,12 +43,9 @@ func NewExportConfigurationsClient(subscriptionID string, credential azcore.Toke // Create - Create a Continuous Export configuration of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. -// - exportProperties - Properties that need to be specified to create a Continuous Export configuration of a Application Insights -// component. +// - exportProperties - The request body // - options - ExportConfigurationsClientCreateOptions contains the optional parameters for the ExportConfigurationsClient.Create // method. func (client *ExportConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ComponentExportRequest, options *ExportConfigurationsClientCreateOptions) (ExportConfigurationsClientCreateResponse, error) { @@ -75,14 +73,14 @@ func (client *ExportConfigurationsClient) Create(ctx context.Context, resourceGr // createCreateRequest creates the Create request. func (client *ExportConfigurationsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ComponentExportRequest, _ *ExportConfigurationsClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -92,9 +90,10 @@ func (client *ExportConfigurationsClient) createCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, exportProperties); err != nil { return nil, err } @@ -112,8 +111,6 @@ func (client *ExportConfigurationsClient) createHandleResponse(resp *http.Respon // Delete - Delete a Continuous Export configuration of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - exportID - The Continuous Export configuration ID. This is unique within a Application Insights component. @@ -144,14 +141,14 @@ func (client *ExportConfigurationsClient) Delete(ctx context.Context, resourceGr // deleteCreateRequest creates the Delete request. func (client *ExportConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, exportID string, _ *ExportConfigurationsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -165,8 +162,8 @@ func (client *ExportConfigurationsClient) deleteCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -182,8 +179,6 @@ func (client *ExportConfigurationsClient) deleteHandleResponse(resp *http.Respon // Get - Get the Continuous Export configuration for this export id. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - exportID - The Continuous Export configuration ID. This is unique within a Application Insights component. @@ -214,14 +209,14 @@ func (client *ExportConfigurationsClient) Get(ctx context.Context, resourceGroup // getCreateRequest creates the Get request. func (client *ExportConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, exportID string, _ *ExportConfigurationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -235,8 +230,8 @@ func (client *ExportConfigurationsClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -252,8 +247,6 @@ func (client *ExportConfigurationsClient) getHandleResponse(resp *http.Response) // List - Gets a list of Continuous Export configuration of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - ExportConfigurationsClientListOptions contains the optional parameters for the ExportConfigurationsClient.List @@ -283,14 +276,14 @@ func (client *ExportConfigurationsClient) List(ctx context.Context, resourceGrou // listCreateRequest creates the List request. func (client *ExportConfigurationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ExportConfigurationsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -300,8 +293,8 @@ func (client *ExportConfigurationsClient) listCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -317,8 +310,6 @@ func (client *ExportConfigurationsClient) listHandleResponse(resp *http.Response // Update - Update the Continuous Export configuration for this export id. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - exportID - The Continuous Export configuration ID. This is unique within a Application Insights component. @@ -350,14 +341,14 @@ func (client *ExportConfigurationsClient) Update(ctx context.Context, resourceGr // updateCreateRequest creates the Update request. func (client *ExportConfigurationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties ComponentExportRequest, _ *ExportConfigurationsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -371,9 +362,10 @@ func (client *ExportConfigurationsClient) updateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, exportProperties); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/exportconfigurations_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/exportconfigurations_client_example_test.go index c06d6bf490ff..3b873b6cb1c0 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/exportconfigurations_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/exportconfigurations_client_example_test.go @@ -1,40 +1,92 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/ExportConfigurationsList.json -func ExampleExportConfigurationsClient_List() { +// Generated from example definition: 2015-05-01/ExportConfigurationsPost.json +func ExampleExportConfigurationsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewExportConfigurationsClient().List(ctx, "my-resource-group", "my-component", nil) + res, err := clientFactory.NewExportConfigurationsClient().Create(ctx, "my-resource-group", "my-component", armapplicationinsights.ComponentExportRequest{ + DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.ClassicStorage/storageAccounts/mystorageblob"), + DestinationAddress: to.Ptr("https://mystorageblob.blob.core.windows.net/testexport?sv=2015-04-05&sr=c&sig=token"), + DestinationStorageLocationID: to.Ptr("eastus"), + DestinationStorageSubscriptionID: to.Ptr("subid"), + DestinationType: to.Ptr("Blob"), + IsEnabled: to.Ptr("true"), + NotificationQueueEnabled: to.Ptr("false"), + NotificationQueueURI: to.Ptr(""), + RecordTypes: to.Ptr("Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability"), + }, 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 = armapplicationinsights.ExportConfigurationsClientCreateResponse{ + // ComponentExportConfigurationArray: []*armapplicationinsights.ComponentExportConfiguration{ + // { + // ApplicationName: to.Ptr("my-component"), + // ContainerName: to.Ptr("mystorageblob"), + // DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageblob"), + // DestinationStorageLocationID: to.Ptr("eastasia"), + // DestinationStorageSubscriptionID: to.Ptr("subidc"), + // DestinationType: to.Ptr("Blob"), + // ExportID: to.Ptr("uGOoki0jQsyEs3IdQ83Q4QsNr4="), + // ExportStatus: to.Ptr("Preparing"), + // InstrumentationKey: to.Ptr("8330b4a4-0b8e-40cf-a643-bbaf60d375c9"), + // IsUserEnabled: to.Ptr("False"), + // LastGapTime: to.Ptr("9999-12-31T23:59:59.999Z"), + // LastSuccessTime: to.Ptr("9999-12-31T23:59:59.999Z"), + // LastUserUpdate: to.Ptr("2017-06-05T06:34:26.957Z"), + // NotificationQueueEnabled: to.Ptr("False"), + // PermanentErrorReason: to.Ptr("None"), + // RecordTypes: to.Ptr("Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability"), + // ResourceGroup: to.Ptr("2"), + // StorageName: to.Ptr("mystorageblob"), + // SubscriptionID: to.Ptr("subid"), + // }, + // }, + // } +} + +// Generated from example definition: 2015-05-01/ExportConfigurationDelete.json +func ExampleExportConfigurationsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExportConfigurationsClient().Delete(ctx, "my-resource-group", "my-component", "uGOoki0jQsyEs3IdQ83Q4QsNr4=", 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.ComponentExportConfigurationArray = []*armapplicationinsights.ComponentExportConfiguration{ - // { + // res = armapplicationinsights.ExportConfigurationsClientDeleteResponse{ + // ComponentExportConfiguration: armapplicationinsights.ComponentExportConfiguration{ // ApplicationName: to.Ptr("my-component"), // ContainerName: to.Ptr("mystorageblob"), // DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageblob"), @@ -54,39 +106,30 @@ func ExampleExportConfigurationsClient_List() { // ResourceGroup: to.Ptr("2"), // StorageName: to.Ptr("mystorageblob"), // SubscriptionID: to.Ptr("subid"), - // }} + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/ExportConfigurationsPost.json -func ExampleExportConfigurationsClient_Create() { +// Generated from example definition: 2015-05-01/ExportConfigurationGet.json +func ExampleExportConfigurationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewExportConfigurationsClient().Create(ctx, "my-resource-group", "my-component", armapplicationinsights.ComponentExportRequest{ - DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.ClassicStorage/storageAccounts/mystorageblob"), - DestinationAddress: to.Ptr("https://mystorageblob.blob.core.windows.net/testexport?sv=2015-04-05&sr=c&sig=token"), - DestinationStorageLocationID: to.Ptr("eastus"), - DestinationStorageSubscriptionID: to.Ptr("subid"), - DestinationType: to.Ptr("Blob"), - IsEnabled: to.Ptr("true"), - NotificationQueueEnabled: to.Ptr("false"), - NotificationQueueURI: to.Ptr(""), - RecordTypes: to.Ptr("Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability"), - }, nil) + res, err := clientFactory.NewExportConfigurationsClient().Get(ctx, "my-resource-group", "my-component", "uGOoki0jQsyEs3IdQ83Q4QsNr4=", 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.ComponentExportConfigurationArray = []*armapplicationinsights.ComponentExportConfiguration{ - // { + // res = armapplicationinsights.ExportConfigurationsClientGetResponse{ + // ComponentExportConfiguration: armapplicationinsights.ComponentExportConfiguration{ // ApplicationName: to.Ptr("my-component"), // ContainerName: to.Ptr("mystorageblob"), // DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageblob"), @@ -106,99 +149,63 @@ func ExampleExportConfigurationsClient_Create() { // ResourceGroup: to.Ptr("2"), // StorageName: to.Ptr("mystorageblob"), // SubscriptionID: to.Ptr("subid"), - // }} -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/ExportConfigurationDelete.json -func ExampleExportConfigurationsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportConfigurationsClient().Delete(ctx, "my-resource-group", "my-component", "uGOoki0jQsyEs3IdQ83Q4QsNr4=", 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.ComponentExportConfiguration = armapplicationinsights.ComponentExportConfiguration{ - // ApplicationName: to.Ptr("my-component"), - // ContainerName: to.Ptr("mystorageblob"), - // DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageblob"), - // DestinationStorageLocationID: to.Ptr("eastasia"), - // DestinationStorageSubscriptionID: to.Ptr("subidc"), - // DestinationType: to.Ptr("Blob"), - // ExportID: to.Ptr("uGOoki0jQsyEs3IdQ83Q4QsNr4="), - // ExportStatus: to.Ptr("Preparing"), - // InstrumentationKey: to.Ptr("8330b4a4-0b8e-40cf-a643-bbaf60d375c9"), - // IsUserEnabled: to.Ptr("False"), - // LastGapTime: to.Ptr("9999-12-31T23:59:59.999Z"), - // LastSuccessTime: to.Ptr("9999-12-31T23:59:59.999Z"), - // LastUserUpdate: to.Ptr("2017-06-05T06:34:26.957Z"), - // NotificationQueueEnabled: to.Ptr("False"), - // PermanentErrorReason: to.Ptr("None"), - // RecordTypes: to.Ptr("Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability"), - // ResourceGroup: to.Ptr("2"), - // StorageName: to.Ptr("mystorageblob"), - // SubscriptionID: to.Ptr("subid"), + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/ExportConfigurationGet.json -func ExampleExportConfigurationsClient_Get() { +// Generated from example definition: 2015-05-01/ExportConfigurationsList.json +func ExampleExportConfigurationsClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewExportConfigurationsClient().Get(ctx, "my-resource-group", "my-component", "uGOoki0jQsyEs3IdQ83Q4QsNr4=", nil) + res, err := clientFactory.NewExportConfigurationsClient().List(ctx, "my-resource-group", "my-component", 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.ComponentExportConfiguration = armapplicationinsights.ComponentExportConfiguration{ - // ApplicationName: to.Ptr("my-component"), - // ContainerName: to.Ptr("mystorageblob"), - // DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageblob"), - // DestinationStorageLocationID: to.Ptr("eastasia"), - // DestinationStorageSubscriptionID: to.Ptr("subidc"), - // DestinationType: to.Ptr("Blob"), - // ExportID: to.Ptr("uGOoki0jQsyEs3IdQ83Q4QsNr4="), - // ExportStatus: to.Ptr("Preparing"), - // InstrumentationKey: to.Ptr("8330b4a4-0b8e-40cf-a643-bbaf60d375c9"), - // IsUserEnabled: to.Ptr("False"), - // LastGapTime: to.Ptr("9999-12-31T23:59:59.999Z"), - // LastSuccessTime: to.Ptr("9999-12-31T23:59:59.999Z"), - // LastUserUpdate: to.Ptr("2017-06-05T06:34:26.957Z"), - // NotificationQueueEnabled: to.Ptr("False"), - // PermanentErrorReason: to.Ptr("None"), - // RecordTypes: to.Ptr("Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability"), - // ResourceGroup: to.Ptr("2"), - // StorageName: to.Ptr("mystorageblob"), - // SubscriptionID: to.Ptr("subid"), + // res = armapplicationinsights.ExportConfigurationsClientListResponse{ + // ComponentExportConfigurationArray: []*armapplicationinsights.ComponentExportConfiguration{ + // { + // ApplicationName: to.Ptr("my-component"), + // ContainerName: to.Ptr("mystorageblob"), + // DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageblob"), + // DestinationStorageLocationID: to.Ptr("eastasia"), + // DestinationStorageSubscriptionID: to.Ptr("subidc"), + // DestinationType: to.Ptr("Blob"), + // ExportID: to.Ptr("uGOoki0jQsyEs3IdQ83Q4QsNr4="), + // ExportStatus: to.Ptr("Preparing"), + // InstrumentationKey: to.Ptr("8330b4a4-0b8e-40cf-a643-bbaf60d375c9"), + // IsUserEnabled: to.Ptr("False"), + // LastGapTime: to.Ptr("9999-12-31T23:59:59.999Z"), + // LastSuccessTime: to.Ptr("9999-12-31T23:59:59.999Z"), + // LastUserUpdate: to.Ptr("2017-06-05T06:34:26.957Z"), + // NotificationQueueEnabled: to.Ptr("False"), + // PermanentErrorReason: to.Ptr("None"), + // RecordTypes: to.Ptr("Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability"), + // ResourceGroup: to.Ptr("2"), + // StorageName: to.Ptr("mystorageblob"), + // SubscriptionID: to.Ptr("subid"), + // }, + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/ExportConfigurationUpdate.json +// Generated from example definition: 2015-05-01/ExportConfigurationUpdate.json func ExampleExportConfigurationsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -219,25 +226,27 @@ func ExampleExportConfigurationsClient_Update() { // 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.ComponentExportConfiguration = armapplicationinsights.ComponentExportConfiguration{ - // ApplicationName: to.Ptr("my-component"), - // ContainerName: to.Ptr("mystorageblob"), - // DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageblob"), - // DestinationStorageLocationID: to.Ptr("eastasia"), - // DestinationStorageSubscriptionID: to.Ptr("subidc"), - // DestinationType: to.Ptr("Blob"), - // ExportID: to.Ptr("uGOoki0jQsyEs3IdQ83Q4QsNr4="), - // ExportStatus: to.Ptr("Preparing"), - // InstrumentationKey: to.Ptr("8330b4a4-0b8e-40cf-a643-bbaf60d375c9"), - // IsUserEnabled: to.Ptr("False"), - // LastGapTime: to.Ptr("9999-12-31T23:59:59.999Z"), - // LastSuccessTime: to.Ptr("9999-12-31T23:59:59.999Z"), - // LastUserUpdate: to.Ptr("2017-06-05T06:34:26.957Z"), - // NotificationQueueEnabled: to.Ptr("False"), - // PermanentErrorReason: to.Ptr("None"), - // RecordTypes: to.Ptr("Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability"), - // ResourceGroup: to.Ptr("2"), - // StorageName: to.Ptr("mystorageblob"), - // SubscriptionID: to.Ptr("subid"), + // res = armapplicationinsights.ExportConfigurationsClientUpdateResponse{ + // ComponentExportConfiguration: armapplicationinsights.ComponentExportConfiguration{ + // ApplicationName: to.Ptr("my-component"), + // ContainerName: to.Ptr("mystorageblob"), + // DestinationAccountID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorageblob"), + // DestinationStorageLocationID: to.Ptr("eastasia"), + // DestinationStorageSubscriptionID: to.Ptr("subidc"), + // DestinationType: to.Ptr("Blob"), + // ExportID: to.Ptr("uGOoki0jQsyEs3IdQ83Q4QsNr4="), + // ExportStatus: to.Ptr("Preparing"), + // InstrumentationKey: to.Ptr("8330b4a4-0b8e-40cf-a643-bbaf60d375c9"), + // IsUserEnabled: to.Ptr("False"), + // LastGapTime: to.Ptr("9999-12-31T23:59:59.999Z"), + // LastSuccessTime: to.Ptr("9999-12-31T23:59:59.999Z"), + // LastUserUpdate: to.Ptr("2017-06-05T06:34:26.957Z"), + // NotificationQueueEnabled: to.Ptr("False"), + // PermanentErrorReason: to.Ptr("None"), + // RecordTypes: to.Ptr("Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability"), + // ResourceGroup: to.Ptr("2"), + // StorageName: to.Ptr("mystorageblob"), + // SubscriptionID: to.Ptr("subid"), + // }, // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/analyticsitems_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/analyticsitems_server.go index c09dbb296a02..a59dbf8cf0c1 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/analyticsitems_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/analyticsitems_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" "strconv" ) @@ -63,9 +63,7 @@ func (a *AnalyticsItemsServerTransport) Do(req *http.Request) (*http.Response, e } func (a *AnalyticsItemsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -87,10 +85,7 @@ func (a *AnalyticsItemsServerTransport) dispatchToMethodFake(req *http.Request, } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -108,7 +103,7 @@ func (a *AnalyticsItemsServerTransport) dispatchDelete(req *http.Request) (*http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/microsoft\.insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/item` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -130,16 +125,8 @@ func (a *AnalyticsItemsServerTransport) dispatchDelete(req *http.Request) (*http if err != nil { return nil, err } - iDUnescaped, err := url.QueryUnescape(qp.Get("id")) - if err != nil { - return nil, err - } - iDParam := getOptional(iDUnescaped) - nameUnescaped, err := url.QueryUnescape(qp.Get("name")) - if err != nil { - return nil, err - } - nameParam := getOptional(nameUnescaped) + iDParam := getOptional(qp.Get("id")) + nameParam := getOptional(qp.Get("name")) var options *armapplicationinsights.AnalyticsItemsClientDeleteOptions if iDParam != nil || nameParam != nil { options = &armapplicationinsights.AnalyticsItemsClientDeleteOptions{ @@ -152,7 +139,7 @@ func (a *AnalyticsItemsServerTransport) dispatchDelete(req *http.Request) (*http return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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) @@ -169,7 +156,7 @@ func (a *AnalyticsItemsServerTransport) dispatchGet(req *http.Request) (*http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/microsoft\.insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/item` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -191,16 +178,8 @@ func (a *AnalyticsItemsServerTransport) dispatchGet(req *http.Request) (*http.Re if err != nil { return nil, err } - iDUnescaped, err := url.QueryUnescape(qp.Get("id")) - if err != nil { - return nil, err - } - iDParam := getOptional(iDUnescaped) - nameUnescaped, err := url.QueryUnescape(qp.Get("name")) - if err != nil { - return nil, err - } - nameParam := getOptional(nameUnescaped) + iDParam := getOptional(qp.Get("id")) + nameParam := getOptional(qp.Get("name")) var options *armapplicationinsights.AnalyticsItemsClientGetOptions if iDParam != nil || nameParam != nil { options = &armapplicationinsights.AnalyticsItemsClientGetOptions{ @@ -213,7 +192,7 @@ func (a *AnalyticsItemsServerTransport) dispatchGet(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentAnalyticsItem, req) @@ -230,7 +209,7 @@ func (a *AnalyticsItemsServerTransport) dispatchList(req *http.Request) (*http.R const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/microsoft\.insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -252,21 +231,9 @@ func (a *AnalyticsItemsServerTransport) dispatchList(req *http.Request) (*http.R if err != nil { return nil, err } - scopeUnescaped, err := url.QueryUnescape(qp.Get("scope")) - if err != nil { - return nil, err - } - scopeParam := getOptional(armapplicationinsights.ItemScope(scopeUnescaped)) - typeUnescaped, err := url.QueryUnescape(qp.Get("type")) - if err != nil { - return nil, err - } - typeParam := getOptional(armapplicationinsights.ItemTypeParameter(typeUnescaped)) - includeContentUnescaped, err := url.QueryUnescape(qp.Get("includeContent")) - if err != nil { - return nil, err - } - includeContentParam, err := parseOptional(includeContentUnescaped, strconv.ParseBool) + scopeParam := getOptional(armapplicationinsights.ItemScope(qp.Get("scope"))) + typeParam := getOptional(armapplicationinsights.ItemTypeParameter(qp.Get("type"))) + includeContentParam, err := parseOptional(qp.Get("includeContent"), strconv.ParseBool) if err != nil { return nil, err } @@ -283,7 +250,7 @@ func (a *AnalyticsItemsServerTransport) dispatchList(req *http.Request) (*http.R return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentAnalyticsItemArray, req) @@ -300,7 +267,7 @@ func (a *AnalyticsItemsServerTransport) dispatchPut(req *http.Request) (*http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/microsoft\.insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/item` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -326,11 +293,7 @@ func (a *AnalyticsItemsServerTransport) dispatchPut(req *http.Request) (*http.Re if err != nil { return nil, err } - overrideItemUnescaped, err := url.QueryUnescape(qp.Get("overrideItem")) - if err != nil { - return nil, err - } - overrideItemParam, err := parseOptional(overrideItemUnescaped, strconv.ParseBool) + overrideItemParam, err := parseOptional(qp.Get("overrideItem"), strconv.ParseBool) if err != nil { return nil, err } @@ -345,7 +308,7 @@ func (a *AnalyticsItemsServerTransport) dispatchPut(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentAnalyticsItem, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/annotations_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/annotations_server.go index 37353b0d9455..67cc4b00a70c 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/annotations_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/annotations_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,10 +11,12 @@ import ( 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/applicationinsights/armapplicationinsights/v2" "net/http" "net/url" "regexp" + "slices" ) // AnnotationsServer is a fake server for instances of the armapplicationinsights.AnnotationsClient type. @@ -66,9 +67,7 @@ func (a *AnnotationsServerTransport) Do(req *http.Request) (*http.Response, erro } func (a *AnnotationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -90,10 +89,7 @@ func (a *AnnotationsServerTransport) dispatchToMethodFake(req *http.Request, met } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -111,7 +107,7 @@ func (a *AnnotationsServerTransport) dispatchCreate(req *http.Request) (*http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/Annotations` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.Annotation](req) @@ -131,7 +127,7 @@ func (a *AnnotationsServerTransport) dispatchCreate(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).AnnotationArray, req) @@ -148,7 +144,7 @@ func (a *AnnotationsServerTransport) dispatchDelete(req *http.Request) (*http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/Annotations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -168,7 +164,7 @@ func (a *AnnotationsServerTransport) dispatchDelete(req *http.Request) (*http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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) @@ -185,7 +181,7 @@ func (a *AnnotationsServerTransport) dispatchGet(req *http.Request) (*http.Respo const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/Annotations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -205,7 +201,7 @@ func (a *AnnotationsServerTransport) dispatchGet(req *http.Request) (*http.Respo return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).AnnotationArray, req) @@ -224,7 +220,7 @@ func (a *AnnotationsServerTransport) dispatchNewListPager(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/Annotations` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -236,23 +232,18 @@ func (a *AnnotationsServerTransport) dispatchNewListPager(req *http.Request) (*h if err != nil { return nil, err } - startParam, err := url.QueryUnescape(qp.Get("start")) - if err != nil { - return nil, err - } - endParam, err := url.QueryUnescape(qp.Get("end")) - if err != nil { - return nil, err - } - resp := a.srv.NewListPager(resourceGroupNameParam, resourceNameParam, startParam, endParam, nil) + resp := a.srv.NewListPager(resourceGroupNameParam, resourceNameParam, qp.Get("start"), qp.Get("end"), nil) newListPager = &resp a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armapplicationinsights.AnnotationsClientListResponse, 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) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { a.newListPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/apikeys_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/apikeys_server.go index 3df197242eab..1c6eface108a 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/apikeys_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/apikeys_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,10 +11,12 @@ import ( 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/applicationinsights/armapplicationinsights/v2" "net/http" "net/url" "regexp" + "slices" ) // APIKeysServer is a fake server for instances of the armapplicationinsights.APIKeysClient type. @@ -66,9 +67,7 @@ func (a *APIKeysServerTransport) Do(req *http.Request) (*http.Response, error) { } func (a *APIKeysServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -90,10 +89,7 @@ func (a *APIKeysServerTransport) dispatchToMethodFake(req *http.Request, method } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -111,7 +107,7 @@ func (a *APIKeysServerTransport) dispatchCreate(req *http.Request) (*http.Respon const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ApiKeys` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.APIKeyRequest](req) @@ -131,7 +127,7 @@ func (a *APIKeysServerTransport) dispatchCreate(req *http.Request) (*http.Respon return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentAPIKey, req) @@ -148,7 +144,7 @@ func (a *APIKeysServerTransport) dispatchDelete(req *http.Request) (*http.Respon const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/APIKeys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -168,7 +164,7 @@ func (a *APIKeysServerTransport) dispatchDelete(req *http.Request) (*http.Respon return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentAPIKey, req) @@ -185,7 +181,7 @@ func (a *APIKeysServerTransport) dispatchGet(req *http.Request) (*http.Response, const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/APIKeys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -205,7 +201,7 @@ func (a *APIKeysServerTransport) dispatchGet(req *http.Request) (*http.Response, return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentAPIKey, req) @@ -224,7 +220,7 @@ func (a *APIKeysServerTransport) dispatchNewListPager(req *http.Request) (*http. const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ApiKeys` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -238,12 +234,15 @@ func (a *APIKeysServerTransport) dispatchNewListPager(req *http.Request) (*http. resp := a.srv.NewListPager(resourceGroupNameParam, resourceNameParam, nil) newListPager = &resp a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armapplicationinsights.APIKeysClientListResponse, 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) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { a.newListPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentavailablefeatures_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentavailablefeatures_server.go index 0fae6c4bda3a..5b16db743770 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentavailablefeatures_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentavailablefeatures_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // ComponentAvailableFeaturesServer is a fake server for instances of the armapplicationinsights.ComponentAvailableFeaturesClient type. @@ -50,9 +50,7 @@ func (c *ComponentAvailableFeaturesServerTransport) Do(req *http.Request) (*http } func (c *ComponentAvailableFeaturesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -68,10 +66,7 @@ func (c *ComponentAvailableFeaturesServerTransport) dispatchToMethodFake(req *ht } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -89,7 +84,7 @@ func (c *ComponentAvailableFeaturesServerTransport) dispatchGet(req *http.Reques const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getavailablebillingfeatures` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -105,7 +100,7 @@ func (c *ComponentAvailableFeaturesServerTransport) dispatchGet(req *http.Reques return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentAvailableFeatures, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentcurrentbillingfeatures_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentcurrentbillingfeatures_server.go index 46386d0caf7e..3ccdd47cd467 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentcurrentbillingfeatures_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentcurrentbillingfeatures_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // ComponentCurrentBillingFeaturesServer is a fake server for instances of the armapplicationinsights.ComponentCurrentBillingFeaturesClient type. @@ -54,9 +54,7 @@ func (c *ComponentCurrentBillingFeaturesServerTransport) Do(req *http.Request) ( } func (c *ComponentCurrentBillingFeaturesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -74,10 +72,7 @@ func (c *ComponentCurrentBillingFeaturesServerTransport) dispatchToMethodFake(re } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -95,7 +90,7 @@ func (c *ComponentCurrentBillingFeaturesServerTransport) dispatchGet(req *http.R const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/currentbillingfeatures` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -111,7 +106,7 @@ func (c *ComponentCurrentBillingFeaturesServerTransport) dispatchGet(req *http.R return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentBillingFeatures, req) @@ -128,7 +123,7 @@ func (c *ComponentCurrentBillingFeaturesServerTransport) dispatchUpdate(req *htt const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/currentbillingfeatures` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentBillingFeatures](req) @@ -148,7 +143,7 @@ func (c *ComponentCurrentBillingFeaturesServerTransport) dispatchUpdate(req *htt return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentBillingFeatures, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentfeaturecapabilities_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentfeaturecapabilities_server.go index 95df1cb1f36a..2a66d9896cf7 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentfeaturecapabilities_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentfeaturecapabilities_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // ComponentFeatureCapabilitiesServer is a fake server for instances of the armapplicationinsights.ComponentFeatureCapabilitiesClient type. @@ -50,9 +50,7 @@ func (c *ComponentFeatureCapabilitiesServerTransport) Do(req *http.Request) (*ht } func (c *ComponentFeatureCapabilitiesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -68,10 +66,7 @@ func (c *ComponentFeatureCapabilitiesServerTransport) dispatchToMethodFake(req * } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -89,7 +84,7 @@ func (c *ComponentFeatureCapabilitiesServerTransport) dispatchGet(req *http.Requ const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/featurecapabilities` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -105,7 +100,7 @@ func (c *ComponentFeatureCapabilitiesServerTransport) dispatchGet(req *http.Requ return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentFeatureCapabilities, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentlinkedstorageaccounts_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentlinkedstorageaccounts_server.go index a8b10f705822..67baad6d6e47 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentlinkedstorageaccounts_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentlinkedstorageaccounts_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // ComponentLinkedStorageAccountsServer is a fake server for instances of the armapplicationinsights.ComponentLinkedStorageAccountsClient type. @@ -62,9 +62,7 @@ func (c *ComponentLinkedStorageAccountsServerTransport) Do(req *http.Request) (* } func (c *ComponentLinkedStorageAccountsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -86,10 +84,7 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchToMethodFake(req } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -104,10 +99,10 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchCreateAndUpdate( if c.srv.CreateAndUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method CreateAndUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/microsoft\.insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/linkedStorageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/linkedStorageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentLinkedStorageAccounts](req) @@ -137,7 +132,7 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchCreateAndUpdate( return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentLinkedStorageAccounts, req) @@ -151,10 +146,10 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchDelete(req *http if c.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\.insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/linkedStorageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/linkedStorageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -180,7 +175,7 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchDelete(req *http return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } resp, err := server.NewResponse(respContent, req, nil) @@ -194,10 +189,10 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchGet(req *http.Re if c.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\.insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/linkedStorageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/linkedStorageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -223,7 +218,7 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchGet(req *http.Re return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentLinkedStorageAccounts, req) @@ -237,10 +232,10 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchUpdate(req *http if c.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\.insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/linkedStorageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/linkedStorageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentLinkedStorageAccountsPatch](req) @@ -270,7 +265,7 @@ func (c *ComponentLinkedStorageAccountsServerTransport) dispatchUpdate(req *http return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentLinkedStorageAccounts, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentquotastatus_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentquotastatus_server.go index a65e5e9b515f..ef00aa470234 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentquotastatus_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/componentquotastatus_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // ComponentQuotaStatusServer is a fake server for instances of the armapplicationinsights.ComponentQuotaStatusClient type. @@ -50,9 +50,7 @@ func (c *ComponentQuotaStatusServerTransport) Do(req *http.Request) (*http.Respo } func (c *ComponentQuotaStatusServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -68,10 +66,7 @@ func (c *ComponentQuotaStatusServerTransport) dispatchToMethodFake(req *http.Req } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -89,7 +84,7 @@ func (c *ComponentQuotaStatusServerTransport) dispatchGet(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/quotastatus` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -105,7 +100,7 @@ func (c *ComponentQuotaStatusServerTransport) dispatchGet(req *http.Request) (*h return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentQuotaStatus, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/components_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/components_server.go index f45bc91f0bdd..4b40cf4e453f 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/components_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/components_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -17,6 +16,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // ComponentsServer is a fake server for instances of the armapplicationinsights.ComponentsClient type. @@ -85,9 +85,7 @@ func (c *ComponentsServerTransport) Do(req *http.Request) (*http.Response, error } func (c *ComponentsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -117,10 +115,7 @@ func (c *ComponentsServerTransport) dispatchToMethodFake(req *http.Request, meth } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -138,7 +133,7 @@ func (c *ComponentsServerTransport) dispatchCreateOrUpdate(req *http.Request) (* const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.Component](req) @@ -158,7 +153,7 @@ func (c *ComponentsServerTransport) dispatchCreateOrUpdate(req *http.Request) (* return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).Component, req) @@ -175,7 +170,7 @@ func (c *ComponentsServerTransport) dispatchDelete(req *http.Request) (*http.Res const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -191,7 +186,7 @@ func (c *ComponentsServerTransport) dispatchDelete(req *http.Request) (*http.Res return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } resp, err := server.NewResponse(respContent, req, nil) @@ -208,7 +203,7 @@ func (c *ComponentsServerTransport) dispatchGet(req *http.Request) (*http.Respon const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -224,7 +219,7 @@ func (c *ComponentsServerTransport) dispatchGet(req *http.Request) (*http.Respon return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).Component, req) @@ -241,7 +236,7 @@ func (c *ComponentsServerTransport) dispatchGetPurgeStatus(req *http.Request) (* const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -261,7 +256,7 @@ func (c *ComponentsServerTransport) dispatchGetPurgeStatus(req *http.Request) (* return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentPurgeStatusResponse, req) @@ -280,7 +275,7 @@ func (c *ComponentsServerTransport) dispatchNewListPager(req *http.Request) (*ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resp := c.srv.NewListPager(nil) @@ -294,7 +289,7 @@ func (c *ComponentsServerTransport) dispatchNewListPager(req *http.Request) (*ht if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.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)} } @@ -313,7 +308,7 @@ func (c *ComponentsServerTransport) dispatchNewListByResourceGroupPager(req *htt const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -331,7 +326,7 @@ func (c *ComponentsServerTransport) dispatchNewListByResourceGroupPager(req *htt if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { c.newListByResourceGroupPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -348,7 +343,7 @@ func (c *ComponentsServerTransport) dispatchPurge(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/purge` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentPurgeBody](req) @@ -368,7 +363,7 @@ func (c *ComponentsServerTransport) dispatchPurge(req *http.Request) (*http.Resp return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusAccepted}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusAccepted}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ComponentPurgeResponse, req) @@ -385,7 +380,7 @@ func (c *ComponentsServerTransport) dispatchUpdateTags(req *http.Request) (*http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.TagsResource](req) @@ -405,7 +400,7 @@ func (c *ComponentsServerTransport) dispatchUpdateTags(req *http.Request) (*http return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).Component, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/deletedworkbooks_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/deletedworkbooks_server.go index b1a96ff230c1..9253cc109be0 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/deletedworkbooks_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/deletedworkbooks_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -14,8 +13,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" "net/http" - "net/url" "regexp" + "slices" ) // DeletedWorkbooksServer is a fake server for instances of the armapplicationinsights.DeletedWorkbooksClient type. @@ -54,9 +53,7 @@ func (d *DeletedWorkbooksServerTransport) Do(req *http.Request) (*http.Response, } func (d *DeletedWorkbooksServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -72,10 +69,7 @@ func (d *DeletedWorkbooksServerTransport) dispatchToMethodFake(req *http.Request } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -95,20 +89,12 @@ func (d *DeletedWorkbooksServerTransport) dispatchNewListBySubscriptionPager(req const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/deletedWorkbooks` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() - categoryUnescaped, err := url.QueryUnescape(qp.Get("category")) - if err != nil { - return nil, err - } - categoryParam := getOptional(armapplicationinsights.CategoryType(categoryUnescaped)) - tagsUnescaped, err := url.QueryUnescape(qp.Get("tags")) - if err != nil { - return nil, err - } - tagsParam := splitHelper(tagsUnescaped, ",") + categoryParam := getOptional(armapplicationinsights.CategoryType(qp.Get("category"))) + tagsParam := splitHelper(qp.Get("tags"), ",") var options *armapplicationinsights.DeletedWorkbooksClientListBySubscriptionOptions if categoryParam != nil || len(tagsParam) > 0 { options = &armapplicationinsights.DeletedWorkbooksClientListBySubscriptionOptions{ @@ -127,7 +113,7 @@ func (d *DeletedWorkbooksServerTransport) dispatchNewListBySubscriptionPager(req if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { d.newListBySubscriptionPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/exportconfigurations_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/exportconfigurations_server.go index e16dd8614827..96dee6f2a352 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/exportconfigurations_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/exportconfigurations_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // ExportConfigurationsServer is a fake server for instances of the armapplicationinsights.ExportConfigurationsClient type. @@ -66,9 +66,7 @@ func (e *ExportConfigurationsServerTransport) Do(req *http.Request) (*http.Respo } func (e *ExportConfigurationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -92,10 +90,7 @@ func (e *ExportConfigurationsServerTransport) dispatchToMethodFake(req *http.Req } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -113,7 +108,7 @@ func (e *ExportConfigurationsServerTransport) dispatchCreate(req *http.Request) const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportconfiguration` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentExportRequest](req) @@ -133,7 +128,7 @@ func (e *ExportConfigurationsServerTransport) dispatchCreate(req *http.Request) return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentExportConfigurationArray, req) @@ -150,7 +145,7 @@ func (e *ExportConfigurationsServerTransport) dispatchDelete(req *http.Request) const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportconfiguration/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -170,7 +165,7 @@ func (e *ExportConfigurationsServerTransport) dispatchDelete(req *http.Request) return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentExportConfiguration, req) @@ -187,7 +182,7 @@ func (e *ExportConfigurationsServerTransport) dispatchGet(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportconfiguration/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -207,7 +202,7 @@ func (e *ExportConfigurationsServerTransport) dispatchGet(req *http.Request) (*h return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentExportConfiguration, req) @@ -224,7 +219,7 @@ func (e *ExportConfigurationsServerTransport) dispatchList(req *http.Request) (* const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportconfiguration` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -240,7 +235,7 @@ func (e *ExportConfigurationsServerTransport) dispatchList(req *http.Request) (* return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentExportConfigurationArray, req) @@ -257,7 +252,7 @@ func (e *ExportConfigurationsServerTransport) dispatchUpdate(req *http.Request) const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportconfiguration/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentExportRequest](req) @@ -281,7 +276,7 @@ func (e *ExportConfigurationsServerTransport) dispatchUpdate(req *http.Request) return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentExportConfiguration, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/favorites_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/favorites_server.go index bef594c3522f..397688da91d6 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/favorites_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/favorites_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" "strconv" ) @@ -67,9 +67,7 @@ func (f *FavoritesServerTransport) Do(req *http.Request) (*http.Response, error) } func (f *FavoritesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -93,10 +91,7 @@ func (f *FavoritesServerTransport) dispatchToMethodFake(req *http.Request, metho } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -114,7 +109,7 @@ func (f *FavoritesServerTransport) dispatchAdd(req *http.Request) (*http.Respons const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/favorites/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentFavorite](req) @@ -138,7 +133,7 @@ func (f *FavoritesServerTransport) dispatchAdd(req *http.Request) (*http.Respons return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentFavorite, req) @@ -155,7 +150,7 @@ func (f *FavoritesServerTransport) dispatchDelete(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/favorites/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -175,7 +170,7 @@ func (f *FavoritesServerTransport) dispatchDelete(req *http.Request) (*http.Resp return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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) @@ -192,7 +187,7 @@ func (f *FavoritesServerTransport) dispatchGet(req *http.Request) (*http.Respons const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/favorites/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -212,7 +207,7 @@ func (f *FavoritesServerTransport) dispatchGet(req *http.Request) (*http.Respons return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentFavorite, req) @@ -229,7 +224,7 @@ func (f *FavoritesServerTransport) dispatchList(req *http.Request) (*http.Respon const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/favorites` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -241,29 +236,13 @@ func (f *FavoritesServerTransport) dispatchList(req *http.Request) (*http.Respon if err != nil { return nil, err } - favoriteTypeUnescaped, err := url.QueryUnescape(qp.Get("favoriteType")) - if err != nil { - return nil, err - } - favoriteTypeParam := getOptional(armapplicationinsights.FavoriteType(favoriteTypeUnescaped)) - sourceTypeUnescaped, err := url.QueryUnescape(qp.Get("sourceType")) - if err != nil { - return nil, err - } - sourceTypeParam := getOptional(armapplicationinsights.FavoriteSourceType(sourceTypeUnescaped)) - canFetchContentUnescaped, err := url.QueryUnescape(qp.Get("canFetchContent")) - if err != nil { - return nil, err - } - canFetchContentParam, err := parseOptional(canFetchContentUnescaped, strconv.ParseBool) - if err != nil { - return nil, err - } - tagsUnescaped, err := url.QueryUnescape(qp.Get("tags")) + favoriteTypeParam := getOptional(armapplicationinsights.FavoriteType(qp.Get("favoriteType"))) + sourceTypeParam := getOptional(armapplicationinsights.FavoriteSourceType(qp.Get("sourceType"))) + canFetchContentParam, err := parseOptional(qp.Get("canFetchContent"), strconv.ParseBool) if err != nil { return nil, err } - tagsParam := splitHelper(tagsUnescaped, ",") + tagsParam := splitHelper(qp.Get("tags"), ",") var options *armapplicationinsights.FavoritesClientListOptions if favoriteTypeParam != nil || sourceTypeParam != nil || canFetchContentParam != nil || len(tagsParam) > 0 { options = &armapplicationinsights.FavoritesClientListOptions{ @@ -278,7 +257,7 @@ func (f *FavoritesServerTransport) dispatchList(req *http.Request) (*http.Respon return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentFavoriteArray, req) @@ -295,7 +274,7 @@ func (f *FavoritesServerTransport) dispatchUpdate(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/favorites/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentFavorite](req) @@ -319,7 +298,7 @@ func (f *FavoritesServerTransport) dispatchUpdate(req *http.Request) (*http.Resp return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentFavorite, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/internal.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/internal.go index 3d7ea552e2b2..f33deb1ead41 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/internal.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/internal.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -26,15 +25,6 @@ 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 @@ -42,6 +32,14 @@ func getOptional[T any](v T) *T { return &v } +func initServer[T any](mu *sync.Mutex, dst **T, src func() *T) { + mu.Lock() + if *dst == nil { + *dst = src() + } + mu.Unlock() +} + func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { if v == "" { return nil, nil @@ -50,7 +48,7 @@ func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) if err != nil { return nil, err } - return &t, err + return &t, nil } func parseWithCast[T any](v string, parse func(v string) (T, error)) (T, error) { diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/livetoken_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/livetoken_server.go index 328d99a2f1b6..db711e7192d4 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/livetoken_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/livetoken_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // LiveTokenServer is a fake server for instances of the armapplicationinsights.LiveTokenClient type. @@ -50,9 +50,7 @@ func (l *LiveTokenServerTransport) Do(req *http.Request) (*http.Response, error) } func (l *LiveTokenServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -68,10 +66,7 @@ func (l *LiveTokenServerTransport) dispatchToMethodFake(req *http.Request, metho } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -89,7 +84,7 @@ func (l *LiveTokenServerTransport) dispatchGet(req *http.Request) (*http.Respons const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/generatelivetoken` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) @@ -101,7 +96,7 @@ func (l *LiveTokenServerTransport) dispatchGet(req *http.Request) (*http.Respons return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).LiveTokenResponse, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/operations_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/operations_server.go index f14ae39a97f6..7b8f5540fc5e 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/operations_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/operations_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -14,6 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" "net/http" + "slices" ) // OperationsServer is a fake server for instances of the armapplicationinsights.OperationsClient type. @@ -52,9 +52,7 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error } func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -70,10 +68,7 @@ func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, meth } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -101,7 +96,7 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.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)} } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/proactivedetectionconfigurations_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/proactivedetectionconfigurations_server.go index 390c2c37d560..ec20d89f1585 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/proactivedetectionconfigurations_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/proactivedetectionconfigurations_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,6 +15,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // ProactiveDetectionConfigurationsServer is a fake server for instances of the armapplicationinsights.ProactiveDetectionConfigurationsClient type. @@ -58,9 +58,7 @@ func (p *ProactiveDetectionConfigurationsServerTransport) Do(req *http.Request) } func (p *ProactiveDetectionConfigurationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -80,10 +78,7 @@ func (p *ProactiveDetectionConfigurationsServerTransport) dispatchToMethodFake(r } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -101,7 +96,7 @@ func (p *ProactiveDetectionConfigurationsServerTransport) dispatchGet(req *http. const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ProactiveDetectionConfigs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -121,7 +116,7 @@ func (p *ProactiveDetectionConfigurationsServerTransport) dispatchGet(req *http. return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentProactiveDetectionConfiguration, req) @@ -138,7 +133,7 @@ func (p *ProactiveDetectionConfigurationsServerTransport) dispatchList(req *http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ProactiveDetectionConfigs` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -154,7 +149,7 @@ func (p *ProactiveDetectionConfigurationsServerTransport) dispatchList(req *http return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentProactiveDetectionConfigurationArray, req) @@ -171,7 +166,7 @@ func (p *ProactiveDetectionConfigurationsServerTransport) dispatchUpdate(req *ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ProactiveDetectionConfigs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.ComponentProactiveDetectionConfiguration](req) @@ -195,7 +190,7 @@ func (p *ProactiveDetectionConfigurationsServerTransport) dispatchUpdate(req *ht return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).ComponentProactiveDetectionConfiguration, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/server_factory.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/server_factory.go index 626260d35ad5..1ea40016b578 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/server_factory.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/server_factory.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -127,88 +126,88 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { switch client { case "APIKeysClient": - initServer(s, &s.trAPIKeysServer, func() *APIKeysServerTransport { return NewAPIKeysServerTransport(&s.srv.APIKeysServer) }) + initServer(&s.trMu, &s.trAPIKeysServer, func() *APIKeysServerTransport { return NewAPIKeysServerTransport(&s.srv.APIKeysServer) }) resp, err = s.trAPIKeysServer.Do(req) case "AnalyticsItemsClient": - initServer(s, &s.trAnalyticsItemsServer, func() *AnalyticsItemsServerTransport { + initServer(&s.trMu, &s.trAnalyticsItemsServer, func() *AnalyticsItemsServerTransport { return NewAnalyticsItemsServerTransport(&s.srv.AnalyticsItemsServer) }) resp, err = s.trAnalyticsItemsServer.Do(req) case "AnnotationsClient": - initServer(s, &s.trAnnotationsServer, func() *AnnotationsServerTransport { return NewAnnotationsServerTransport(&s.srv.AnnotationsServer) }) + initServer(&s.trMu, &s.trAnnotationsServer, func() *AnnotationsServerTransport { return NewAnnotationsServerTransport(&s.srv.AnnotationsServer) }) resp, err = s.trAnnotationsServer.Do(req) case "ComponentAvailableFeaturesClient": - initServer(s, &s.trComponentAvailableFeaturesServer, func() *ComponentAvailableFeaturesServerTransport { + initServer(&s.trMu, &s.trComponentAvailableFeaturesServer, func() *ComponentAvailableFeaturesServerTransport { return NewComponentAvailableFeaturesServerTransport(&s.srv.ComponentAvailableFeaturesServer) }) resp, err = s.trComponentAvailableFeaturesServer.Do(req) case "ComponentCurrentBillingFeaturesClient": - initServer(s, &s.trComponentCurrentBillingFeaturesServer, func() *ComponentCurrentBillingFeaturesServerTransport { + initServer(&s.trMu, &s.trComponentCurrentBillingFeaturesServer, func() *ComponentCurrentBillingFeaturesServerTransport { return NewComponentCurrentBillingFeaturesServerTransport(&s.srv.ComponentCurrentBillingFeaturesServer) }) resp, err = s.trComponentCurrentBillingFeaturesServer.Do(req) case "ComponentFeatureCapabilitiesClient": - initServer(s, &s.trComponentFeatureCapabilitiesServer, func() *ComponentFeatureCapabilitiesServerTransport { + initServer(&s.trMu, &s.trComponentFeatureCapabilitiesServer, func() *ComponentFeatureCapabilitiesServerTransport { return NewComponentFeatureCapabilitiesServerTransport(&s.srv.ComponentFeatureCapabilitiesServer) }) resp, err = s.trComponentFeatureCapabilitiesServer.Do(req) case "ComponentLinkedStorageAccountsClient": - initServer(s, &s.trComponentLinkedStorageAccountsServer, func() *ComponentLinkedStorageAccountsServerTransport { + initServer(&s.trMu, &s.trComponentLinkedStorageAccountsServer, func() *ComponentLinkedStorageAccountsServerTransport { return NewComponentLinkedStorageAccountsServerTransport(&s.srv.ComponentLinkedStorageAccountsServer) }) resp, err = s.trComponentLinkedStorageAccountsServer.Do(req) case "ComponentQuotaStatusClient": - initServer(s, &s.trComponentQuotaStatusServer, func() *ComponentQuotaStatusServerTransport { + initServer(&s.trMu, &s.trComponentQuotaStatusServer, func() *ComponentQuotaStatusServerTransport { return NewComponentQuotaStatusServerTransport(&s.srv.ComponentQuotaStatusServer) }) resp, err = s.trComponentQuotaStatusServer.Do(req) case "ComponentsClient": - initServer(s, &s.trComponentsServer, func() *ComponentsServerTransport { return NewComponentsServerTransport(&s.srv.ComponentsServer) }) + initServer(&s.trMu, &s.trComponentsServer, func() *ComponentsServerTransport { return NewComponentsServerTransport(&s.srv.ComponentsServer) }) resp, err = s.trComponentsServer.Do(req) case "DeletedWorkbooksClient": - initServer(s, &s.trDeletedWorkbooksServer, func() *DeletedWorkbooksServerTransport { + initServer(&s.trMu, &s.trDeletedWorkbooksServer, func() *DeletedWorkbooksServerTransport { return NewDeletedWorkbooksServerTransport(&s.srv.DeletedWorkbooksServer) }) resp, err = s.trDeletedWorkbooksServer.Do(req) case "ExportConfigurationsClient": - initServer(s, &s.trExportConfigurationsServer, func() *ExportConfigurationsServerTransport { + initServer(&s.trMu, &s.trExportConfigurationsServer, func() *ExportConfigurationsServerTransport { return NewExportConfigurationsServerTransport(&s.srv.ExportConfigurationsServer) }) resp, err = s.trExportConfigurationsServer.Do(req) case "FavoritesClient": - initServer(s, &s.trFavoritesServer, func() *FavoritesServerTransport { return NewFavoritesServerTransport(&s.srv.FavoritesServer) }) + initServer(&s.trMu, &s.trFavoritesServer, func() *FavoritesServerTransport { return NewFavoritesServerTransport(&s.srv.FavoritesServer) }) resp, err = s.trFavoritesServer.Do(req) case "LiveTokenClient": - initServer(s, &s.trLiveTokenServer, func() *LiveTokenServerTransport { return NewLiveTokenServerTransport(&s.srv.LiveTokenServer) }) + initServer(&s.trMu, &s.trLiveTokenServer, func() *LiveTokenServerTransport { return NewLiveTokenServerTransport(&s.srv.LiveTokenServer) }) resp, err = s.trLiveTokenServer.Do(req) case "OperationsClient": - initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + initServer(&s.trMu, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) case "ProactiveDetectionConfigurationsClient": - initServer(s, &s.trProactiveDetectionConfigurationsServer, func() *ProactiveDetectionConfigurationsServerTransport { + initServer(&s.trMu, &s.trProactiveDetectionConfigurationsServer, func() *ProactiveDetectionConfigurationsServerTransport { return NewProactiveDetectionConfigurationsServerTransport(&s.srv.ProactiveDetectionConfigurationsServer) }) resp, err = s.trProactiveDetectionConfigurationsServer.Do(req) case "WebTestLocationsClient": - initServer(s, &s.trWebTestLocationsServer, func() *WebTestLocationsServerTransport { + initServer(&s.trMu, &s.trWebTestLocationsServer, func() *WebTestLocationsServerTransport { return NewWebTestLocationsServerTransport(&s.srv.WebTestLocationsServer) }) resp, err = s.trWebTestLocationsServer.Do(req) case "WebTestsClient": - initServer(s, &s.trWebTestsServer, func() *WebTestsServerTransport { return NewWebTestsServerTransport(&s.srv.WebTestsServer) }) + initServer(&s.trMu, &s.trWebTestsServer, func() *WebTestsServerTransport { return NewWebTestsServerTransport(&s.srv.WebTestsServer) }) resp, err = s.trWebTestsServer.Do(req) case "WorkItemConfigurationsClient": - initServer(s, &s.trWorkItemConfigurationsServer, func() *WorkItemConfigurationsServerTransport { + initServer(&s.trMu, &s.trWorkItemConfigurationsServer, func() *WorkItemConfigurationsServerTransport { return NewWorkItemConfigurationsServerTransport(&s.srv.WorkItemConfigurationsServer) }) resp, err = s.trWorkItemConfigurationsServer.Do(req) case "WorkbookTemplatesClient": - initServer(s, &s.trWorkbookTemplatesServer, func() *WorkbookTemplatesServerTransport { + initServer(&s.trMu, &s.trWorkbookTemplatesServer, func() *WorkbookTemplatesServerTransport { return NewWorkbookTemplatesServerTransport(&s.srv.WorkbookTemplatesServer) }) resp, err = s.trWorkbookTemplatesServer.Do(req) case "WorkbooksClient": - initServer(s, &s.trWorkbooksServer, func() *WorkbooksServerTransport { return NewWorkbooksServerTransport(&s.srv.WorkbooksServer) }) + initServer(&s.trMu, &s.trWorkbooksServer, func() *WorkbooksServerTransport { return NewWorkbooksServerTransport(&s.srv.WorkbooksServer) }) resp, err = s.trWorkbooksServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) @@ -220,11 +219,3 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { 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/applicationinsights/armapplicationinsights/fake/time_rfc3339.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/time_rfc3339.go deleted file mode 100644 index 7691a451714b..000000000000 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/time_rfc3339.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -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 ( - utcDateTime = "2006-01-02T15:04:05.999999999" - utcDateTimeJSON = `"` + utcDateTime + `"` - utcDateTimeNoT = "2006-01-02 15:04:05.999999999" - utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` - dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` - dateTimeJSON = `"` + time.RFC3339Nano + `"` - dateTimeJSONNoT = `"` + dateTimeNoT + `"` -) - -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 { - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = dateTimeJSON - } else if tzOffset { - layout = dateTimeJSONNoT - } else if hasT { - layout = utcDateTimeJSON - } else { - layout = utcDateTimeJSONNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - if len(data) == 0 { - return nil - } - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = time.RFC3339Nano - } else if tzOffset { - layout = dateTimeNoT - } else if hasT { - layout = utcDateTime - } else { - layout = utcDateTimeNoT - } - 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 (t dateTimeRFC3339) String() string { - return time.Time(t).Format(time.RFC3339Nano) -} - -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 || 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/applicationinsights/armapplicationinsights/fake/webtestlocations_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/webtestlocations_server.go index 5e90a92b27d9..e629afceae74 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/webtestlocations_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/webtestlocations_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -11,10 +10,12 @@ import ( 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/applicationinsights/armapplicationinsights/v2" "net/http" "net/url" "regexp" + "slices" ) // WebTestLocationsServer is a fake server for instances of the armapplicationinsights.WebTestLocationsClient type. @@ -53,9 +54,7 @@ func (w *WebTestLocationsServerTransport) Do(req *http.Request) (*http.Response, } func (w *WebTestLocationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -71,10 +70,7 @@ func (w *WebTestLocationsServerTransport) dispatchToMethodFake(req *http.Request } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -94,7 +90,7 @@ func (w *WebTestLocationsServerTransport) dispatchNewListPager(req *http.Request const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/syntheticmonitorlocations` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -108,12 +104,15 @@ func (w *WebTestLocationsServerTransport) dispatchNewListPager(req *http.Request resp := w.srv.NewListPager(resourceGroupNameParam, resourceNameParam, nil) newListPager = &resp w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armapplicationinsights.WebTestLocationsClientListResponse, 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) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newListPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/webtests_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/webtests_server.go index 45b1bbcaed4c..fa50e1e92bfc 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/webtests_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/webtests_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -17,6 +16,7 @@ import ( "net/http" "net/url" "regexp" + "slices" ) // WebTestsServer is a fake server for instances of the armapplicationinsights.WebTestsClient type. @@ -83,9 +83,7 @@ func (w *WebTestsServerTransport) Do(req *http.Request) (*http.Response, error) } func (w *WebTestsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -113,10 +111,7 @@ func (w *WebTestsServerTransport) dispatchToMethodFake(req *http.Request, method } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -134,7 +129,7 @@ func (w *WebTestsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/webtests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.WebTest](req) @@ -154,7 +149,7 @@ func (w *WebTestsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*ht return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WebTest, req) @@ -171,7 +166,7 @@ func (w *WebTestsServerTransport) dispatchDelete(req *http.Request) (*http.Respo const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/webtests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -187,7 +182,7 @@ func (w *WebTestsServerTransport) dispatchDelete(req *http.Request) (*http.Respo return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } resp, err := server.NewResponse(respContent, req, nil) @@ -204,7 +199,7 @@ func (w *WebTestsServerTransport) dispatchGet(req *http.Request) (*http.Response const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/webtests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -220,7 +215,7 @@ func (w *WebTestsServerTransport) dispatchGet(req *http.Request) (*http.Response return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WebTest, req) @@ -239,7 +234,7 @@ func (w *WebTestsServerTransport) dispatchNewListPager(req *http.Request) (*http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/webtests` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resp := w.srv.NewListPager(nil) @@ -253,7 +248,7 @@ func (w *WebTestsServerTransport) dispatchNewListPager(req *http.Request) (*http if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newListPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -272,7 +267,7 @@ func (w *WebTestsServerTransport) dispatchNewListByComponentPager(req *http.Requ const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webtests` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } componentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("componentName")]) @@ -294,7 +289,7 @@ func (w *WebTestsServerTransport) dispatchNewListByComponentPager(req *http.Requ if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newListByComponentPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -313,7 +308,7 @@ func (w *WebTestsServerTransport) dispatchNewListByResourceGroupPager(req *http. const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/webtests` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -331,7 +326,7 @@ func (w *WebTestsServerTransport) dispatchNewListByResourceGroupPager(req *http. if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newListByResourceGroupPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -348,7 +343,7 @@ func (w *WebTestsServerTransport) dispatchUpdateTags(req *http.Request) (*http.R const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/webtests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.TagsResource](req) @@ -368,7 +363,7 @@ func (w *WebTestsServerTransport) dispatchUpdateTags(req *http.Request) (*http.R return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WebTest, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workbooks_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workbooks_server.go index d566b243397b..028697a7088d 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workbooks_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workbooks_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,8 +15,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" "net/http" "net/url" - "reflect" "regexp" + "slices" "strconv" ) @@ -53,7 +52,7 @@ type WorkbooksServer struct { // Update is the fake for method WorkbooksClient.Update // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - Update func(ctx context.Context, resourceGroupName string, resourceName string, options *armapplicationinsights.WorkbooksClientUpdateOptions) (resp azfake.Responder[armapplicationinsights.WorkbooksClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, resourceGroupName string, resourceName string, workbookUpdateParameters armapplicationinsights.WorkbookUpdateParameters, options *armapplicationinsights.WorkbooksClientUpdateOptions) (resp azfake.Responder[armapplicationinsights.WorkbooksClientUpdateResponse], errResp azfake.ErrorResponder) } // NewWorkbooksServerTransport creates a new instance of WorkbooksServerTransport with the provided implementation. @@ -89,9 +88,7 @@ func (w *WorkbooksServerTransport) Do(req *http.Request) (*http.Response, error) } func (w *WorkbooksServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -121,10 +118,7 @@ func (w *WorkbooksServerTransport) dispatchToMethodFake(req *http.Request, metho } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -142,7 +136,7 @@ func (w *WorkbooksServerTransport) dispatchCreateOrUpdate(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -158,11 +152,7 @@ func (w *WorkbooksServerTransport) dispatchCreateOrUpdate(req *http.Request) (*h if err != nil { return nil, err } - sourceIDUnescaped, err := url.QueryUnescape(qp.Get("sourceId")) - if err != nil { - return nil, err - } - sourceIDParam := getOptional(sourceIDUnescaped) + sourceIDParam := getOptional(qp.Get("sourceId")) var options *armapplicationinsights.WorkbooksClientCreateOrUpdateOptions if sourceIDParam != nil { options = &armapplicationinsights.WorkbooksClientCreateOrUpdateOptions{ @@ -174,7 +164,7 @@ func (w *WorkbooksServerTransport) dispatchCreateOrUpdate(req *http.Request) (*h return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Workbook, req) @@ -191,7 +181,7 @@ func (w *WorkbooksServerTransport) dispatchDelete(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -207,7 +197,7 @@ func (w *WorkbooksServerTransport) dispatchDelete(req *http.Request) (*http.Resp return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } resp, err := server.NewResponse(respContent, req, nil) @@ -224,7 +214,7 @@ func (w *WorkbooksServerTransport) dispatchGet(req *http.Request) (*http.Respons const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -236,11 +226,7 @@ func (w *WorkbooksServerTransport) dispatchGet(req *http.Request) (*http.Respons if err != nil { return nil, err } - canFetchContentUnescaped, err := url.QueryUnescape(qp.Get("canFetchContent")) - if err != nil { - return nil, err - } - canFetchContentParam, err := parseOptional(canFetchContentUnescaped, strconv.ParseBool) + canFetchContentParam, err := parseOptional(qp.Get("canFetchContent"), strconv.ParseBool) if err != nil { return nil, err } @@ -255,7 +241,7 @@ func (w *WorkbooksServerTransport) dispatchGet(req *http.Request) (*http.Respons return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).Workbook, req) @@ -274,7 +260,7 @@ func (w *WorkbooksServerTransport) dispatchNewListByResourceGroupPager(req *http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooks` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -282,31 +268,9 @@ func (w *WorkbooksServerTransport) dispatchNewListByResourceGroupPager(req *http if err != nil { return nil, err } - categoryParam, err := parseWithCast(qp.Get("category"), func(v string) (armapplicationinsights.CategoryType, error) { - p, unescapeErr := url.QueryUnescape(v) - if unescapeErr != nil { - return "", unescapeErr - } - return armapplicationinsights.CategoryType(p), nil - }) - if err != nil { - return nil, err - } - tagsUnescaped, err := url.QueryUnescape(qp.Get("tags")) - if err != nil { - return nil, err - } - tagsParam := splitHelper(tagsUnescaped, ",") - sourceIDUnescaped, err := url.QueryUnescape(qp.Get("sourceId")) - if err != nil { - return nil, err - } - sourceIDParam := getOptional(sourceIDUnescaped) - canFetchContentUnescaped, err := url.QueryUnescape(qp.Get("canFetchContent")) - if err != nil { - return nil, err - } - canFetchContentParam, err := parseOptional(canFetchContentUnescaped, strconv.ParseBool) + tagsParam := splitHelper(qp.Get("tags"), ",") + sourceIDParam := getOptional(qp.Get("sourceId")) + canFetchContentParam, err := parseOptional(qp.Get("canFetchContent"), strconv.ParseBool) if err != nil { return nil, err } @@ -318,7 +282,7 @@ func (w *WorkbooksServerTransport) dispatchNewListByResourceGroupPager(req *http CanFetchContent: canFetchContentParam, } } - resp := w.srv.NewListByResourceGroupPager(resourceGroupNameParam, categoryParam, options) + resp := w.srv.NewListByResourceGroupPager(resourceGroupNameParam, armapplicationinsights.CategoryType(qp.Get("category")), options) newListByResourceGroupPager = &resp w.newListByResourceGroupPager.add(req, newListByResourceGroupPager) server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armapplicationinsights.WorkbooksClientListByResourceGroupResponse, createLink func() string) { @@ -329,7 +293,7 @@ func (w *WorkbooksServerTransport) dispatchNewListByResourceGroupPager(req *http if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newListByResourceGroupPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -348,30 +312,12 @@ func (w *WorkbooksServerTransport) dispatchNewListBySubscriptionPager(req *http. const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooks` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() - categoryParam, err := parseWithCast(qp.Get("category"), func(v string) (armapplicationinsights.CategoryType, error) { - p, unescapeErr := url.QueryUnescape(v) - if unescapeErr != nil { - return "", unescapeErr - } - return armapplicationinsights.CategoryType(p), nil - }) - if err != nil { - return nil, err - } - tagsUnescaped, err := url.QueryUnescape(qp.Get("tags")) - if err != nil { - return nil, err - } - tagsParam := splitHelper(tagsUnescaped, ",") - canFetchContentUnescaped, err := url.QueryUnescape(qp.Get("canFetchContent")) - if err != nil { - return nil, err - } - canFetchContentParam, err := parseOptional(canFetchContentUnescaped, strconv.ParseBool) + tagsParam := splitHelper(qp.Get("tags"), ",") + canFetchContentParam, err := parseOptional(qp.Get("canFetchContent"), strconv.ParseBool) if err != nil { return nil, err } @@ -382,7 +328,7 @@ func (w *WorkbooksServerTransport) dispatchNewListBySubscriptionPager(req *http. CanFetchContent: canFetchContentParam, } } - resp := w.srv.NewListBySubscriptionPager(categoryParam, options) + resp := w.srv.NewListBySubscriptionPager(armapplicationinsights.CategoryType(qp.Get("category")), options) newListBySubscriptionPager = &resp w.newListBySubscriptionPager.add(req, newListBySubscriptionPager) server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armapplicationinsights.WorkbooksClientListBySubscriptionResponse, createLink func() string) { @@ -393,7 +339,7 @@ func (w *WorkbooksServerTransport) dispatchNewListBySubscriptionPager(req *http. if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newListBySubscriptionPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -410,7 +356,7 @@ func (w *WorkbooksServerTransport) dispatchRevisionGet(req *http.Request) (*http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/revisions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -430,7 +376,7 @@ func (w *WorkbooksServerTransport) dispatchRevisionGet(req *http.Request) (*http return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).Workbook, req) @@ -449,7 +395,7 @@ func (w *WorkbooksServerTransport) dispatchNewRevisionsListPager(req *http.Reque const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/revisions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -471,7 +417,7 @@ func (w *WorkbooksServerTransport) dispatchNewRevisionsListPager(req *http.Reque if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newRevisionsListPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -488,7 +434,7 @@ func (w *WorkbooksServerTransport) dispatchUpdate(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -504,24 +450,19 @@ func (w *WorkbooksServerTransport) dispatchUpdate(req *http.Request) (*http.Resp if err != nil { return nil, err } - sourceIDUnescaped, err := url.QueryUnescape(qp.Get("sourceId")) - if err != nil { - return nil, err - } - sourceIDParam := getOptional(sourceIDUnescaped) + sourceIDParam := getOptional(qp.Get("sourceId")) var options *armapplicationinsights.WorkbooksClientUpdateOptions - if sourceIDParam != nil || !reflect.ValueOf(body).IsZero() { + if sourceIDParam != nil { options = &armapplicationinsights.WorkbooksClientUpdateOptions{ - SourceID: sourceIDParam, - WorkbookUpdateParameters: &body, + SourceID: sourceIDParam, } } - respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, options) + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, body, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Workbook, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workbooktemplates_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workbooktemplates_server.go index fb2227586ea4..1196e9c8e549 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workbooktemplates_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workbooktemplates_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,11 +11,12 @@ import ( 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/applicationinsights/armapplicationinsights/v2" "net/http" "net/url" - "reflect" "regexp" + "slices" ) // WorkbookTemplatesServer is a fake server for instances of the armapplicationinsights.WorkbookTemplatesClient type. @@ -39,7 +39,7 @@ type WorkbookTemplatesServer struct { // Update is the fake for method WorkbookTemplatesClient.Update // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, resourceGroupName string, resourceName string, options *armapplicationinsights.WorkbookTemplatesClientUpdateOptions) (resp azfake.Responder[armapplicationinsights.WorkbookTemplatesClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, resourceGroupName string, resourceName string, workbookTemplateUpdateParameters armapplicationinsights.WorkbookTemplateUpdateParameters, options *armapplicationinsights.WorkbookTemplatesClientUpdateOptions) (resp azfake.Responder[armapplicationinsights.WorkbookTemplatesClientUpdateResponse], errResp azfake.ErrorResponder) } // NewWorkbookTemplatesServerTransport creates a new instance of WorkbookTemplatesServerTransport with the provided implementation. @@ -71,9 +71,7 @@ func (w *WorkbookTemplatesServerTransport) Do(req *http.Request) (*http.Response } func (w *WorkbookTemplatesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -97,10 +95,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchToMethodFake(req *http.Reques } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -118,7 +113,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchCreateOrUpdate(req *http.Requ const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooktemplates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.WorkbookTemplate](req) @@ -138,7 +133,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchCreateOrUpdate(req *http.Requ return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).WorkbookTemplate, req) @@ -155,7 +150,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchDelete(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooktemplates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -171,7 +166,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchDelete(req *http.Request) (*h return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + if !slices.Contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } resp, err := server.NewResponse(respContent, req, nil) @@ -188,7 +183,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchGet(req *http.Request) (*http const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooktemplates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -204,7 +199,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchGet(req *http.Request) (*http return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WorkbookTemplate, req) @@ -223,7 +218,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchNewListByResourceGroupPager(r const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooktemplates` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -233,12 +228,15 @@ func (w *WorkbookTemplatesServerTransport) dispatchNewListByResourceGroupPager(r resp := w.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) newListByResourceGroupPager = &resp w.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armapplicationinsights.WorkbookTemplatesClientListByResourceGroupResponse, 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) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newListByResourceGroupPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -255,7 +253,7 @@ func (w *WorkbookTemplatesServerTransport) dispatchUpdate(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/workbooktemplates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.WorkbookTemplateUpdateParameters](req) @@ -270,18 +268,12 @@ func (w *WorkbookTemplatesServerTransport) dispatchUpdate(req *http.Request) (*h if err != nil { return nil, err } - var options *armapplicationinsights.WorkbookTemplatesClientUpdateOptions - if !reflect.ValueOf(body).IsZero() { - options = &armapplicationinsights.WorkbookTemplatesClientUpdateOptions{ - WorkbookTemplateUpdateParameters: &body, - } - } - respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, options) + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WorkbookTemplate, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workitemconfigurations_server.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workitemconfigurations_server.go index dc774a3989ec..f4f04d19b498 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workitemconfigurations_server.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/fake/workitemconfigurations_server.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,10 +11,12 @@ import ( 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/applicationinsights/armapplicationinsights/v2" "net/http" "net/url" "regexp" + "slices" ) // WorkItemConfigurationsServer is a fake server for instances of the armapplicationinsights.WorkItemConfigurationsClient type. @@ -74,9 +75,7 @@ func (w *WorkItemConfigurationsServerTransport) Do(req *http.Request) (*http.Res } func (w *WorkItemConfigurationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - + resultChan := make(chan result, 1) go func() { var intercepted bool var res result @@ -102,10 +101,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchToMethodFake(req *http.R } } - select { - case resultChan <- res: - case <-req.Context().Done(): - } + resultChan <- res }() select { @@ -123,7 +119,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchCreate(req *http.Request const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/WorkItemConfigs` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.WorkItemCreateConfiguration](req) @@ -143,7 +139,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchCreate(req *http.Request return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WorkItemConfiguration, req) @@ -160,7 +156,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchDelete(req *http.Request const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/WorkItemConfigs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -180,7 +176,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchDelete(req *http.Request return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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) @@ -197,7 +193,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchGetDefault(req *http.Req const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/DefaultWorkItemConfig` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -213,7 +209,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchGetDefault(req *http.Req return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WorkItemConfiguration, req) @@ -230,7 +226,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchGetItem(req *http.Reques const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/WorkItemConfigs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -250,7 +246,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchGetItem(req *http.Reques return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WorkItemConfiguration, req) @@ -269,7 +265,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchNewListPager(req *http.R const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/WorkItemConfigs` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -283,12 +279,15 @@ func (w *WorkItemConfigurationsServerTransport) dispatchNewListPager(req *http.R resp := w.srv.NewListPager(resourceGroupNameParam, resourceNameParam, nil) newListPager = &resp w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armapplicationinsights.WorkItemConfigurationsClientListResponse, 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) { + if !slices.Contains([]int{http.StatusOK}, resp.StatusCode) { w.newListPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } @@ -305,7 +304,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchUpdateItem(req *http.Req const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Insights/components/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/WorkItemConfigs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapplicationinsights.WorkItemCreateConfiguration](req) @@ -329,7 +328,7 @@ func (w *WorkItemConfigurationsServerTransport) dispatchUpdateItem(req *http.Req return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + if !slices.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).WorkItemConfiguration, req) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/favorites_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/favorites_client.go index aea82eb34e85..fda3b7ed2216 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/favorites_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/favorites_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -20,15 +19,17 @@ import ( // FavoritesClient contains the methods for the Favorites group. // Don't use this type directly, use NewFavoritesClient() instead. +// +// Generated from API version 2015-05-01 type FavoritesClient struct { internal *arm.Client subscriptionID string } // NewFavoritesClient creates a new instance of FavoritesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewFavoritesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FavoritesClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -43,8 +44,6 @@ func NewFavoritesClient(subscriptionID string, credential azcore.TokenCredential // Add - Adds a new favorites to an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - favoriteID - The Id of a specific favorite defined in the Application Insights component @@ -76,14 +75,14 @@ func (client *FavoritesClient) Add(ctx context.Context, resourceGroupName string // addCreateRequest creates the Add request. func (client *FavoritesClient) addCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ComponentFavorite, _ *FavoritesClientAddOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -97,9 +96,10 @@ func (client *FavoritesClient) addCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, favoriteProperties); err != nil { return nil, err } @@ -117,8 +117,6 @@ func (client *FavoritesClient) addHandleResponse(resp *http.Response) (Favorites // Delete - Remove a favorite that is associated to an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - favoriteID - The Id of a specific favorite defined in the Application Insights component @@ -147,14 +145,14 @@ func (client *FavoritesClient) Delete(ctx context.Context, resourceGroupName str // deleteCreateRequest creates the Delete request. func (client *FavoritesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, _ *FavoritesClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -168,15 +166,13 @@ func (client *FavoritesClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // Get - Get a single favorite by its FavoriteId, defined within an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - favoriteID - The Id of a specific favorite defined in the Application Insights component @@ -206,14 +202,14 @@ func (client *FavoritesClient) Get(ctx context.Context, resourceGroupName string // getCreateRequest creates the Get request. func (client *FavoritesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, _ *FavoritesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -227,8 +223,8 @@ func (client *FavoritesClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -244,8 +240,6 @@ func (client *FavoritesClient) getHandleResponse(resp *http.Response) (Favorites // List - Gets a list of favorites defined within an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - FavoritesClientListOptions contains the optional parameters for the FavoritesClient.List method. @@ -274,14 +268,14 @@ func (client *FavoritesClient) List(ctx context.Context, resourceGroupName strin // listCreateRequest creates the List request. func (client *FavoritesClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *FavoritesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -291,7 +285,7 @@ func (client *FavoritesClient) listCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") + reqQP.Set("api-version", version20150501) if options != nil && options.CanFetchContent != nil { reqQP.Set("canFetchContent", strconv.FormatBool(*options.CanFetchContent)) } @@ -304,7 +298,7 @@ func (client *FavoritesClient) listCreateRequest(ctx context.Context, resourceGr if options != nil && options.Tags != nil { reqQP.Set("tags", strings.Join(options.Tags, ",")) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -320,8 +314,6 @@ func (client *FavoritesClient) listHandleResponse(resp *http.Response) (Favorite // Update - Updates a favorite that has already been added to an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - favoriteID - The Id of a specific favorite defined in the Application Insights component @@ -352,14 +344,14 @@ func (client *FavoritesClient) Update(ctx context.Context, resourceGroupName str // updateCreateRequest creates the Update request. func (client *FavoritesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ComponentFavorite, _ *FavoritesClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -373,9 +365,10 @@ func (client *FavoritesClient) updateCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, favoriteProperties); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/favorites_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/favorites_client_example_test.go index 1e90962fc465..ef4d24f5aca3 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/favorites_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/favorites_client_example_test.go @@ -1,76 +1,94 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/FavoritesList.json -func ExampleFavoritesClient_List() { +// Generated from example definition: 2015-05-01/FavoriteAdd.json +func ExampleFavoritesClient_Add() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewFavoritesClient().List(ctx, "my-resource-group", "my-ai-component", &armapplicationinsights.FavoritesClientListOptions{FavoriteType: nil, - SourceType: nil, - CanFetchContent: nil, - Tags: []string{}, - }) + res, err := clientFactory.NewFavoritesClient().Add(ctx, "my-resource-group", "my-ai-component", "deadb33f-8bee-4d3b-a059-9be8dac93960", armapplicationinsights.ComponentFavorite{ + Config: to.Ptr("{\"MEDataModelRawJSON\":\"{\\n \\\"version\\\": \\\"1.4.1\\\",\\n \\\"isCustomDataModel\\\": true,\\n \\\"items\\\": [\\n {\\n \\\"id\\\": \\\"90a7134d-9a38-4c25-88d3-a495209873eb\\\",\\n \\\"chartType\\\": \\\"Area\\\",\\n \\\"chartHeight\\\": 4,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Sum\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"fail\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"0c289098-88e8-4010-b212-546815cddf70\\\",\\n \\\"chartType\\\": \\\"Area\\\",\\n \\\"chartHeight\\\": 2,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/duration\\\",\\n \\\"metricAggregation\\\": \\\"Avg\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-j1\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Avg\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"greenHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"cbdaab6f-a808-4f71-aca5-b3976cbb7345\\\",\\n \\\"chartType\\\": \\\"Bar\\\",\\n \\\"chartHeight\\\": 4,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/duration\\\",\\n \\\"metricAggregation\\\": \\\"Avg\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Avg\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"magentaHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\\\",\\n \\\"grouping\\\": {\\n \\\"kind\\\": \\\"ByDimension\\\",\\n \\\"dimension\\\": \\\"context.application.version\\\"\\n },\\n \\\"chartType\\\": \\\"Grid\\\",\\n \\\"chartHeight\\\": 1,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"basicException.count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-g0\\\"\\n },\\n {\\n \\\"id\\\": \\\"requestFailed.count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-f0s2\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": true,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"blueHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n }\\n ],\\n \\\"currentFilter\\\": {\\n \\\"eventTypes\\\": [\\n 1,\\n 2\\n ],\\n \\\"typeFacets\\\": {},\\n \\\"isPermissive\\\": false\\n },\\n \\\"timeContext\\\": {\\n \\\"durationMs\\\": 75600000,\\n \\\"endTime\\\": \\\"2018-01-31T20:30:00.000Z\\\",\\n \\\"createdTime\\\": \\\"2018-01-31T23:54:26.280Z\\\",\\n \\\"isInitialTime\\\": false,\\n \\\"grain\\\": 1,\\n \\\"useDashboardTimeRange\\\": false\\n },\\n \\\"jsonUri\\\": \\\"Favorite_BlankChart\\\",\\n \\\"timeSource\\\": 0\\n}\"}"), + FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), + IsGeneratedFromTemplate: to.Ptr(false), + Name: to.Ptr("Blah Blah Blah"), + Tags: []*string{ + to.Ptr("TagSample01"), + to.Ptr("TagSample02"), + }, + Version: to.Ptr("ME"), + }, 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.ComponentFavoriteArray = []*armapplicationinsights.ComponentFavorite{ - // { - // Config: to.Ptr("blah blah"), - // FavoriteID: to.Ptr("c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), + // res = armapplicationinsights.FavoritesClientAddResponse{ + // ComponentFavorite: armapplicationinsights.ComponentFavorite{ + // Category: to.Ptr(""), + // Config: to.Ptr("{\"MEDataModelRawJSON\":{\n \"version\": \"1.4.1\",\n \"isCustomDataModel\": true,\n \"items\": [\n {\n \"id\": \"90a7134d-9a38-4c25-88d3-a495209873eb\",\n \"chartType\": \"Area\",\n \"chartHeight\": 4,\n \"metrics\": [\n {\n \"id\": \"preview/requests/count\",\n \"metricAggregation\": \"Sum\",\n \"color\": \"msportalfx-bgcolor-d0\"\n }\n],\n \"priorPeriod\": false,\n \"clickAction\": {\n \"defaultBlade\": \"SearchBlade\"\n },\n \"horizontalBars\": true,\n \"showOther\": true,\n \"aggregation\": \"Sum\",\n \"percentage\": false,\n \"palette\": \"fail\",\n \"yAxisOption\": 0,\n \"title\": \"\"\n },\n {\n \"id\": \"0c289098-88e8-4010-b212-546815cddf70\",\n \"chartType\": \"Area\",\n \"chartHeight\": 2,\n \"metrics\": [\n {\n \"id\": \"preview/requests/duration\",\n \"metricAggregation\": \"Avg\",\n \"color\": \"msportalfx-bgcolor-j1\"\n }\n ],\n \"priorPeriod\": false,\n \"clickAction\": {\n \"defaultBlade\": \"SearchBlade\"\n },\n \"horizontalBars\": true,\n \"showOther\": true,\n \"aggregation\": \"Avg\",\n \"percentage\": false,\n \"palette\": \"greenHues\",\n \"yAxisOption\": 0,\n \"title\": \"\"\n },\n {\n \"id\": \"cbdaab6f-a808-4f71-aca5-b3976cbb7345\",\n \"chartType\": \"Bar\",\n \"chartHeight\": 4,\n \"metrics\": [\n {\n \"id\": \"preview/requests/duration\",\n \"metricAggregation\": \"Avg\",\n \"color\": \"msportalfx-bgcolor-d0\"\n }\n ],\n \"priorPeriod\": false,\n \"clickAction\": {\n \"defaultBlade\": \"SearchBlade\"\n },\n \"horizontalBars\": true,\n \"showOther\": true,\n \"aggregation\": \"Avg\",\n \"percentage\": false,\n \"palette\": \"magentaHues\",\n \"yAxisOption\": 0,\n \"title\": \"\"\n },\n {\n \"id\": \"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\",\n \"grouping\": {\n \"kind\": \"ByDimension\",\n \"dimension\": \"context.application.version\"\n },\n \"chartType\": \"Grid\",\n \"chartHeight\": 1,\n \"metrics\": [\n {\n \"id\": \"basicException.count\",\n \"metricAggregation\": \"Sum\",\n \"color\": \"msportalfx-bgcolor-g0\"\n },\n {\n \"id\": \"requestFailed.count\",\n \"metricAggregation\": \"Sum\",\n \"color\": \"msportalfx-bgcolor-f0s2\"\n }\n ],\n \"priorPeriod\": true,\n \"clickAction\": {\n \"defaultBlade\": \"SearchBlade\"\n },\n \"horizontalBars\": true,\n \"showOther\": true,\n \"percentage\": false,\n \"palette\": \"blueHues\",\n \"yAxisOption\": 0,\n \"title\": \"\"\n }\n ],\n \"currentFilter\": {\n \"eventTypes\": [\n 1,\n 2\n ],\n \"typeFacets\": {},\n \"isPermissive\": false\n },\n \"timeContext\": {\n \"durationMs\": 75600000,\n \"endTime\": \"2018-01-31T20:30:00.000Z\",\n \"createdTime\": \"2018-01-31T23:54:26.280Z\",\n \"isInitialTime\": false,\n \"grain\": 1,\n \"useDashboardTimeRange\": false\n },\n \"jsonUri\": \"Favorite_BlankChart\",\n \"timeSource\": 0\n}\"}"), + // FavoriteID: to.Ptr("deadb33f-8bee-4d3b-a059-9be8dac93960"), // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), // IsGeneratedFromTemplate: to.Ptr(false), - // Name: to.Ptr("Example Metric Chart Favorite"), + // Name: to.Ptr("Blah Blah Blah"), + // SourceType: to.Ptr(""), // Tags: []*string{ + // to.Ptr("TagSample01"), + // to.Ptr("TagSample02"), // }, - // TimeModified: to.Ptr("2018-01-31T23:56:16.008902Z"), + // TimeModified: to.Ptr("2018-02-02T23:18:32.1850959Z"), // Version: to.Ptr("ME"), // }, - // { - // Config: to.Ptr("{\"TimeSelection\":{\"durationMs\":1800000,\"endTime\":\"2018-01-31T23:56:15.493Z\",\"createdTime\":\"Wed Jan 31 2018 15:58:36 GMT-0800 (Pacific Standard Time)\",\"isInitialTime\":false,\"grain\":1,\"useDashboardTimeRange\":false},\"SearchFilter\":{\"eventTypes\":[1,2],\"typeFacets\":{},\"isPermissive\":false},\"QueryText\":\"*\",\"partId\":\"99e33a16-1b00-4a7d-b98f-a3c1bb3a4df8\"}"), - // FavoriteID: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), - // IsGeneratedFromTemplate: to.Ptr(false), - // Name: to.Ptr("Example Search Blade Favorite"), - // Tags: []*string{ - // to.Ptr("SampleTag01"), - // to.Ptr("SampleTag2")}, - // TimeModified: to.Ptr("2018-01-31T23:59:25.4594264Z"), - // Version: to.Ptr("Search"), - // }} + // } +} + +// Generated from example definition: 2015-05-01/FavoriteDelete.json +func ExampleFavoritesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFavoritesClient().Delete(ctx, "my-resource-group", "my-ai-component", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", 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 = armapplicationinsights.FavoritesClientDeleteResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/FavoriteGet.json +// Generated from example definition: 2015-05-01/FavoriteGet.json func ExampleFavoritesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -81,87 +99,93 @@ func ExampleFavoritesClient_Get() { // 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.ComponentFavorite = armapplicationinsights.ComponentFavorite{ - // Config: to.Ptr("{\"TimeSelection\":{\"durationMs\":1800000,\"endTime\":\"2018-01-31T23:56:15.493Z\",\"createdTime\":\"Wed Jan 31 2018 15:58:36 GMT-0800 (Pacific Standard Time)\",\"isInitialTime\":false,\"grain\":1,\"useDashboardTimeRange\":false},\"SearchFilter\":{\"eventTypes\":[1,2],\"typeFacets\":{},\"isPermissive\":false},\"QueryText\":\"*\",\"partId\":\"99e33a16-1b00-4a7d-b98f-a3c1bb3a4df8\"}"), - // FavoriteID: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), - // IsGeneratedFromTemplate: to.Ptr(false), - // Name: to.Ptr("Example Search Blade Favorite"), - // Tags: []*string{ - // to.Ptr("SampleTag1"), - // to.Ptr("SampleTag2")}, + // res = armapplicationinsights.FavoritesClientGetResponse{ + // ComponentFavorite: armapplicationinsights.ComponentFavorite{ + // Config: to.Ptr("{\"TimeSelection\":{\"durationMs\":1800000,\"endTime\":\"2018-01-31T23:56:15.493Z\",\"createdTime\":\"Wed Jan 31 2018 15:58:36 GMT-0800 (Pacific Standard Time)\",\"isInitialTime\":false,\"grain\":1,\"useDashboardTimeRange\":false},\"SearchFilter\":{\"eventTypes\":[1,2],\"typeFacets\":{},\"isPermissive\":false},\"QueryText\":\"*\",\"partId\":\"99e33a16-1b00-4a7d-b98f-a3c1bb3a4df8\"}"), + // FavoriteID: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), + // IsGeneratedFromTemplate: to.Ptr(false), + // Name: to.Ptr("Example Search Blade Favorite"), + // Tags: []*string{ + // to.Ptr("SampleTag1"), + // to.Ptr("SampleTag2"), + // }, // TimeModified: to.Ptr("2018-01-31T23:59:25.4594264Z"), // Version: to.Ptr("Search"), - // } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/FavoriteAdd.json -func ExampleFavoritesClient_Add() { +// Generated from example definition: 2015-05-01/FavoritesList.json +func ExampleFavoritesClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewFavoritesClient().Add(ctx, "my-resource-group", "my-ai-component", "deadb33f-8bee-4d3b-a059-9be8dac93960", armapplicationinsights.ComponentFavorite{ - Config: to.Ptr("{\"MEDataModelRawJSON\":\"{\\n \\\"version\\\": \\\"1.4.1\\\",\\n \\\"isCustomDataModel\\\": true,\\n \\\"items\\\": [\\n {\\n \\\"id\\\": \\\"90a7134d-9a38-4c25-88d3-a495209873eb\\\",\\n \\\"chartType\\\": \\\"Area\\\",\\n \\\"chartHeight\\\": 4,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Sum\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"fail\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"0c289098-88e8-4010-b212-546815cddf70\\\",\\n \\\"chartType\\\": \\\"Area\\\",\\n \\\"chartHeight\\\": 2,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/duration\\\",\\n \\\"metricAggregation\\\": \\\"Avg\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-j1\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Avg\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"greenHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"cbdaab6f-a808-4f71-aca5-b3976cbb7345\\\",\\n \\\"chartType\\\": \\\"Bar\\\",\\n \\\"chartHeight\\\": 4,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/duration\\\",\\n \\\"metricAggregation\\\": \\\"Avg\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Avg\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"magentaHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\\\",\\n \\\"grouping\\\": {\\n \\\"kind\\\": \\\"ByDimension\\\",\\n \\\"dimension\\\": \\\"context.application.version\\\"\\n },\\n \\\"chartType\\\": \\\"Grid\\\",\\n \\\"chartHeight\\\": 1,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"basicException.count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-g0\\\"\\n },\\n {\\n \\\"id\\\": \\\"requestFailed.count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-f0s2\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": true,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"blueHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n }\\n ],\\n \\\"currentFilter\\\": {\\n \\\"eventTypes\\\": [\\n 1,\\n 2\\n ],\\n \\\"typeFacets\\\": {},\\n \\\"isPermissive\\\": false\\n },\\n \\\"timeContext\\\": {\\n \\\"durationMs\\\": 75600000,\\n \\\"endTime\\\": \\\"2018-01-31T20:30:00.000Z\\\",\\n \\\"createdTime\\\": \\\"2018-01-31T23:54:26.280Z\\\",\\n \\\"isInitialTime\\\": false,\\n \\\"grain\\\": 1,\\n \\\"useDashboardTimeRange\\\": false\\n },\\n \\\"jsonUri\\\": \\\"Favorite_BlankChart\\\",\\n \\\"timeSource\\\": 0\\n}\"}"), - FavoriteID: to.Ptr("deadb33f-8bee-4d3b-a059-9be8dac93960"), - FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), - IsGeneratedFromTemplate: to.Ptr(false), - Name: to.Ptr("Blah Blah Blah"), - Tags: []*string{ - to.Ptr("TagSample01"), - to.Ptr("TagSample02")}, - Version: to.Ptr("ME"), - }, nil) + res, err := clientFactory.NewFavoritesClient().List(ctx, "my-resource-group", "my-ai-component", 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.ComponentFavorite = armapplicationinsights.ComponentFavorite{ - // Category: to.Ptr(""), - // Config: to.Ptr("{\"MEDataModelRawJSON\":{\n \"version\": \"1.4.1\",\n \"isCustomDataModel\": true,\n \"items\": [\n {\n \"id\": \"90a7134d-9a38-4c25-88d3-a495209873eb\",\n \"chartType\": \"Area\",\n \"chartHeight\": 4,\n \"metrics\": [\n {\n \"id\": \"preview/requests/count\",\n \"metricAggregation\": \"Sum\",\n \"color\": \"msportalfx-bgcolor-d0\"\n }\n],\n \"priorPeriod\": false,\n \"clickAction\": {\n \"defaultBlade\": \"SearchBlade\"\n },\n \"horizontalBars\": true,\n \"showOther\": true,\n \"aggregation\": \"Sum\",\n \"percentage\": false,\n \"palette\": \"fail\",\n \"yAxisOption\": 0,\n \"title\": \"\"\n },\n {\n \"id\": \"0c289098-88e8-4010-b212-546815cddf70\",\n \"chartType\": \"Area\",\n \"chartHeight\": 2,\n \"metrics\": [\n {\n \"id\": \"preview/requests/duration\",\n \"metricAggregation\": \"Avg\",\n \"color\": \"msportalfx-bgcolor-j1\"\n }\n ],\n \"priorPeriod\": false,\n \"clickAction\": {\n \"defaultBlade\": \"SearchBlade\"\n },\n \"horizontalBars\": true,\n \"showOther\": true,\n \"aggregation\": \"Avg\",\n \"percentage\": false,\n \"palette\": \"greenHues\",\n \"yAxisOption\": 0,\n \"title\": \"\"\n },\n {\n \"id\": \"cbdaab6f-a808-4f71-aca5-b3976cbb7345\",\n \"chartType\": \"Bar\",\n \"chartHeight\": 4,\n \"metrics\": [\n {\n \"id\": \"preview/requests/duration\",\n \"metricAggregation\": \"Avg\",\n \"color\": \"msportalfx-bgcolor-d0\"\n }\n ],\n \"priorPeriod\": false,\n \"clickAction\": {\n \"defaultBlade\": \"SearchBlade\"\n },\n \"horizontalBars\": true,\n \"showOther\": true,\n \"aggregation\": \"Avg\",\n \"percentage\": false,\n \"palette\": \"magentaHues\",\n \"yAxisOption\": 0,\n \"title\": \"\"\n },\n {\n \"id\": \"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\",\n \"grouping\": {\n \"kind\": \"ByDimension\",\n \"dimension\": \"context.application.version\"\n },\n \"chartType\": \"Grid\",\n \"chartHeight\": 1,\n \"metrics\": [\n {\n \"id\": \"basicException.count\",\n \"metricAggregation\": \"Sum\",\n \"color\": \"msportalfx-bgcolor-g0\"\n },\n {\n \"id\": \"requestFailed.count\",\n \"metricAggregation\": \"Sum\",\n \"color\": \"msportalfx-bgcolor-f0s2\"\n }\n ],\n \"priorPeriod\": true,\n \"clickAction\": {\n \"defaultBlade\": \"SearchBlade\"\n },\n \"horizontalBars\": true,\n \"showOther\": true,\n \"percentage\": false,\n \"palette\": \"blueHues\",\n \"yAxisOption\": 0,\n \"title\": \"\"\n }\n ],\n \"currentFilter\": {\n \"eventTypes\": [\n 1,\n 2\n ],\n \"typeFacets\": {},\n \"isPermissive\": false\n },\n \"timeContext\": {\n \"durationMs\": 75600000,\n \"endTime\": \"2018-01-31T20:30:00.000Z\",\n \"createdTime\": \"2018-01-31T23:54:26.280Z\",\n \"isInitialTime\": false,\n \"grain\": 1,\n \"useDashboardTimeRange\": false\n },\n \"jsonUri\": \"Favorite_BlankChart\",\n \"timeSource\": 0\n}\"}"), - // FavoriteID: to.Ptr("deadb33f-8bee-4d3b-a059-9be8dac93960"), - // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), - // IsGeneratedFromTemplate: to.Ptr(false), - // Name: to.Ptr("Blah Blah Blah"), - // SourceType: to.Ptr(""), - // Tags: []*string{ - // to.Ptr("TagSample01"), - // to.Ptr("TagSample02")}, - // TimeModified: to.Ptr("2018-02-02T23:18:32.1850959Z"), - // Version: to.Ptr("ME"), - // } + // res = armapplicationinsights.FavoritesClientListResponse{ + // ComponentFavoriteArray: []*armapplicationinsights.ComponentFavorite{ + // { + // Config: to.Ptr("blah blah"), + // FavoriteID: to.Ptr("c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), + // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), + // IsGeneratedFromTemplate: to.Ptr(false), + // Name: to.Ptr("Example Metric Chart Favorite"), + // Tags: []*string{ + // }, + // TimeModified: to.Ptr("2018-01-31T23:56:16.008902Z"), + // Version: to.Ptr("ME"), + // }, + // { + // Config: to.Ptr("{\"TimeSelection\":{\"durationMs\":1800000,\"endTime\":\"2018-01-31T23:56:15.493Z\",\"createdTime\":\"Wed Jan 31 2018 15:58:36 GMT-0800 (Pacific Standard Time)\",\"isInitialTime\":false,\"grain\":1,\"useDashboardTimeRange\":false},\"SearchFilter\":{\"eventTypes\":[1,2],\"typeFacets\":{},\"isPermissive\":false},\"QueryText\":\"*\",\"partId\":\"99e33a16-1b00-4a7d-b98f-a3c1bb3a4df8\"}"), + // FavoriteID: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), + // IsGeneratedFromTemplate: to.Ptr(false), + // Name: to.Ptr("Example Search Blade Favorite"), + // Tags: []*string{ + // to.Ptr("SampleTag01"), + // to.Ptr("SampleTag2"), + // }, + // TimeModified: to.Ptr("2018-01-31T23:59:25.4594264Z"), + // Version: to.Ptr("Search"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/FavoriteUpdate.json +// Generated from example definition: 2015-05-01/FavoriteUpdate.json func ExampleFavoritesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewFavoritesClient().Update(ctx, "my-resource-group", "my-ai-component", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", armapplicationinsights.ComponentFavorite{ Config: to.Ptr("{\"MEDataModelRawJSON\":\"{\\\"version\\\": \\\"1.4.1\\\",\\\"isCustomDataModel\\\": true,\\\"items\\\": [{\\\"id\\\": \\\"90a7134d-9a38-4c25-88d3-a495209873eb\\\",\\\"chartType\\\": \\\"Area\\\",\\\"chartHeight\\\": 4,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Sum\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"fail\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"0c289098-88e8-4010-b212-546815cddf70\\\",\\\"chartType\\\": \\\"Area\\\",\\\"chartHeight\\\": 2,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/duration\\\",\\\"metricAggregation\\\": \\\"Avg\\\",\\\"color\\\": \\\"msportalfx-bgcolor-j1\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Avg\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"greenHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"cbdaab6f-a808-4f71-aca5-b3976cbb7345\\\",\\\"chartType\\\": \\\"Bar\\\",\\\"chartHeight\\\": 4,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/duration\\\",\\\"metricAggregation\\\": \\\"Avg\\\",\\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Avg\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"magentaHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\\\",\\\"grouping\\\": {\\\"kind\\\": \\\"ByDimension\\\",\\\"dimension\\\": \\\"context.application.version\\\"},\\\"chartType\\\": \\\"Grid\\\",\\\"chartHeight\\\": 1,\\\"metrics\\\": [{\\\"id\\\": \\\"basicException.count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-g0\\\"},{\\\"id\\\": \\\"requestFailed.count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-f0s2\\\"}],\\\"priorPeriod\\\": true,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"percentage\\\": false,\\\"palette\\\": \\\"blueHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"}],\\\"currentFilter\\\": {\\\"eventTypes\\\": [1,2],\\\"typeFacets\\\": {},\\\"isPermissive\\\": false},\\\"timeContext\\\": {\\\"durationMs\\\": 75600000,\\\"endTime\\\": \\\"2018-01-31T20:30:00.000Z\\\",\\\"createdTime\\\": \\\"2018-01-31T23:54:26.280Z\\\",\\\"isInitialTime\\\": false,\\\"grain\\\": 1,\\\"useDashboardTimeRange\\\": false},\\\"jsonUri\\\": \\\"Favorite_BlankChart\\\",\\\"timeSource\\\": 0}\"}"), - FavoriteID: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), IsGeneratedFromTemplate: to.Ptr(false), Name: to.Ptr("Derek Changed This"), Tags: []*string{ to.Ptr("TagSample01"), to.Ptr("TagSample02"), - to.Ptr("TagSample03")}, - TimeModified: to.Ptr("2018-02-02T18:39:11.6569686Z"), - Version: to.Ptr("ME"), + to.Ptr("TagSample03"), + }, + Version: to.Ptr("ME"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -169,34 +193,20 @@ func ExampleFavoritesClient_Update() { // 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.ComponentFavorite = armapplicationinsights.ComponentFavorite{ - // Config: to.Ptr("{\"MEDataModelRawJSON\":\"{\\\"version\\\": \\\"1.4.1\\\",\\\"isCustomDataModel\\\": true,\\\"items\\\": [{\\\"id\\\": \\\"90a7134d-9a38-4c25-88d3-a495209873eb\\\",\\\"chartType\\\": \\\"Area\\\",\\\"chartHeight\\\": 4,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Sum\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"fail\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"0c289098-88e8-4010-b212-546815cddf70\\\",\\\"chartType\\\": \\\"Area\\\",\\\"chartHeight\\\": 2,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/duration\\\",\\\"metricAggregation\\\": \\\"Avg\\\",\\\"color\\\": \\\"msportalfx-bgcolor-j1\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Avg\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"greenHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"cbdaab6f-a808-4f71-aca5-b3976cbb7345\\\",\\\"chartType\\\": \\\"Bar\\\",\\\"chartHeight\\\": 4,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/duration\\\",\\\"metricAggregation\\\": \\\"Avg\\\",\\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Avg\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"magentaHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\\\",\\\"grouping\\\": {\\\"kind\\\": \\\"ByDimension\\\",\\\"dimension\\\": \\\"context.application.version\\\"},\\\"chartType\\\": \\\"Grid\\\",\\\"chartHeight\\\": 1,\\\"metrics\\\": [{\\\"id\\\": \\\"basicException.count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-g0\\\"},{\\\"id\\\": \\\"requestFailed.count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-f0s2\\\"}],\\\"priorPeriod\\\": true,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"percentage\\\": false,\\\"palette\\\": \\\"blueHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"}],\\\"currentFilter\\\": {\\\"eventTypes\\\": [1,2],\\\"typeFacets\\\": {},\\\"isPermissive\\\": false},\\\"timeContext\\\": {\\\"durationMs\\\": 75600000,\\\"endTime\\\": \\\"2018-01-31T20:30:00.000Z\\\",\\\"createdTime\\\": \\\"2018-01-31T23:54:26.280Z\\\",\\\"isInitialTime\\\": false,\\\"grain\\\": 1,\\\"useDashboardTimeRange\\\": false},\\\"jsonUri\\\": \\\"Favorite_BlankChart\\\",\\\"timeSource\\\": 0}\"}"), - // FavoriteID: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), - // IsGeneratedFromTemplate: to.Ptr(false), - // Name: to.Ptr("Derek Changed This"), - // Tags: []*string{ - // to.Ptr("TagSample01"), - // to.Ptr("TagSample02"), - // to.Ptr("TagSample03")}, + // res = armapplicationinsights.FavoritesClientUpdateResponse{ + // ComponentFavorite: armapplicationinsights.ComponentFavorite{ + // Config: to.Ptr("{\"MEDataModelRawJSON\":\"{\\\"version\\\": \\\"1.4.1\\\",\\\"isCustomDataModel\\\": true,\\\"items\\\": [{\\\"id\\\": \\\"90a7134d-9a38-4c25-88d3-a495209873eb\\\",\\\"chartType\\\": \\\"Area\\\",\\\"chartHeight\\\": 4,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Sum\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"fail\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"0c289098-88e8-4010-b212-546815cddf70\\\",\\\"chartType\\\": \\\"Area\\\",\\\"chartHeight\\\": 2,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/duration\\\",\\\"metricAggregation\\\": \\\"Avg\\\",\\\"color\\\": \\\"msportalfx-bgcolor-j1\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Avg\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"greenHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"cbdaab6f-a808-4f71-aca5-b3976cbb7345\\\",\\\"chartType\\\": \\\"Bar\\\",\\\"chartHeight\\\": 4,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/duration\\\",\\\"metricAggregation\\\": \\\"Avg\\\",\\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Avg\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"magentaHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\\\",\\\"grouping\\\": {\\\"kind\\\": \\\"ByDimension\\\",\\\"dimension\\\": \\\"context.application.version\\\"},\\\"chartType\\\": \\\"Grid\\\",\\\"chartHeight\\\": 1,\\\"metrics\\\": [{\\\"id\\\": \\\"basicException.count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-g0\\\"},{\\\"id\\\": \\\"requestFailed.count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-f0s2\\\"}],\\\"priorPeriod\\\": true,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"percentage\\\": false,\\\"palette\\\": \\\"blueHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"}],\\\"currentFilter\\\": {\\\"eventTypes\\\": [1,2],\\\"typeFacets\\\": {},\\\"isPermissive\\\": false},\\\"timeContext\\\": {\\\"durationMs\\\": 75600000,\\\"endTime\\\": \\\"2018-01-31T20:30:00.000Z\\\",\\\"createdTime\\\": \\\"2018-01-31T23:54:26.280Z\\\",\\\"isInitialTime\\\": false,\\\"grain\\\": 1,\\\"useDashboardTimeRange\\\": false},\\\"jsonUri\\\": \\\"Favorite_BlankChart\\\",\\\"timeSource\\\": 0}\"}"), + // FavoriteID: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // FavoriteType: to.Ptr(armapplicationinsights.FavoriteTypeShared), + // IsGeneratedFromTemplate: to.Ptr(false), + // Name: to.Ptr("Derek Changed This"), + // Tags: []*string{ + // to.Ptr("TagSample01"), + // to.Ptr("TagSample02"), + // to.Ptr("TagSample03"), + // }, // TimeModified: to.Ptr("2018-02-02T18:39:11.6569686Z"), // Version: to.Ptr("ME"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/FavoriteDelete.json -func ExampleFavoritesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewFavoritesClient().Delete(ctx, "my-resource-group", "my-ai-component", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } + // }, + // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/go.mod b/sdk/resourcemanager/applicationinsights/armapplicationinsights/go.mod index 9db01919fa42..4f2eff7bfee7 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/go.mod +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights go 1.25.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.7.0 // indirect github.com/golang-jwt/jwt/v5 v5.3.1 // indirect github.com/google/uuid v1.6.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.49.0 // indirect - golang.org/x/net v0.52.0 // indirect - golang.org/x/sys v0.42.0 // indirect - golang.org/x/text v0.35.0 // indirect + golang.org/x/crypto v0.50.0 // indirect + golang.org/x/net v0.53.0 // indirect + golang.org/x/sys v0.43.0 // indirect + golang.org/x/text v0.36.0 // indirect ) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/go.sum b/sdk/resourcemanager/applicationinsights/armapplicationinsights/go.sum index 39dc1cef1d34..8811f5b1cf99 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/go.sum +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/go.sum @@ -1,11 +1,11 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 h1:fou+2+WFTib47nS+nz/ozhEBnvU96bKHy6LjRsY4E28= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0/go.mod h1:t76Ruy8AHvUAC8GfMWJMa0ElSbuIcO03NLpynfbgsPA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1 h1:jHb/wfvRikGdxMXYV3QG/SzUOPYN9KEUUuC0Yd0/vC0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1/go.mod h1:pzBXCYn05zvYIrwLgtK8Ap8QcjRg+0i76tMQdWN6wOk= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 h1:Hk5QBxZQC1jb2Fwj6mpzme37xbCDdNTxU7O9eb5+LB4= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1/go.mod h1:IYus9qsFobWIc2YVwe/WPjcnyCkPKtnHAqUYeebc8z0= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 h1:fhqpLE3UEXi9lPaBRpQ6XuRW0nU7hgg4zlmZZa+a9q4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0/go.mod h1:7dCRMLwisfRH3dBupKeNCioWYUZ4SS09Z14H+7i8ZoY= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= github.com/AzureAD/microsoft-authentication-library-for-go v1.7.0 h1:4iB+IesclUXdP0ICgAabvq2FYLXrJWKx1fJQ+GxSo3Y= @@ -26,14 +26,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4= -golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA= -golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0= -golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw= +golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI= +golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= +golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA= +golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= -golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8= -golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA= +golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= +golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= +golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/livetoken_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/livetoken_client.go index 03c86ddd10a0..12f56cf69990 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/livetoken_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/livetoken_client.go @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights 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" @@ -17,13 +17,15 @@ import ( // LiveTokenClient contains the methods for the LiveToken group. // Don't use this type directly, use NewLiveTokenClient() instead. +// +// Generated from API version 2021-10-14 type LiveTokenClient struct { internal *arm.Client } // NewLiveTokenClient creates a new instance of LiveTokenClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewLiveTokenClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*LiveTokenClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -35,11 +37,9 @@ func NewLiveTokenClient(credential azcore.TokenCredential, options *arm.ClientOp return client, nil } -// Get - Gets an access token for live metrics stream data. +// Get - **Gets an access token for live metrics stream data.** // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-10-14 -// - resourceURI - The identifier of the resource. +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. // - options - LiveTokenClientGetOptions contains the optional parameters for the LiveTokenClient.Get method. func (client *LiveTokenClient) Get(ctx context.Context, resourceURI string, options *LiveTokenClientGetOptions) (LiveTokenClientGetResponse, error) { var err error @@ -66,14 +66,17 @@ func (client *LiveTokenClient) Get(ctx context.Context, resourceURI string, opti // getCreateRequest creates the Get request. func (client *LiveTokenClient) getCreateRequest(ctx context.Context, resourceURI string, _ *LiveTokenClientGetOptions) (*policy.Request, error) { urlPath := "/{resourceUri}/providers/Microsoft.Insights/generatelivetoken" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) 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", "2021-10-14") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20211014) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/livetoken_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/livetoken_client_example_test.go index 2c20e1913a31..2f24f7008c14 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/livetoken_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/livetoken_client_example_test.go @@ -1,27 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2021-10-14/examples/LiveTokenGet.json +// Generated from example definition: 2021-10-14/LiveTokenGet.json func ExampleLiveTokenClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -32,7 +29,9 @@ func ExampleLiveTokenClient_Get() { // 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.LiveTokenResponse = armapplicationinsights.LiveTokenResponse{ - // LiveToken: to.Ptr("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"), + // res = armapplicationinsights.LiveTokenClientGetResponse{ + // LiveTokenResponse: armapplicationinsights.LiveTokenResponse{ + // LiveToken: to.Ptr("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"), + // }, // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/models.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/models.go index 141c7cede935..d5771c3826cc 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/models.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/models.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -40,20 +39,11 @@ type Annotation struct { RelatedAnnotation *string } -// AnnotationError - Error associated with trying to create annotation with Id that already exist -type AnnotationError struct { - // Error detail code and explanation - Code *string - - // Inner error - Innererror *InnerError - - // Error message - Message *string -} - // AnnotationsListResult - Annotations list result. type AnnotationsListResult struct { + // The url to the next page of results. + NextLink *string + // READ-ONLY; An array of annotations. Value []*Annotation } @@ -112,6 +102,9 @@ type ComponentAPIKey struct { type ComponentAPIKeyListResult struct { // REQUIRED; List of API Key definitions. Value []*ComponentAPIKey + + // The url to the next page of results. + NextLink *string } // ComponentAnalyticsItem - Properties that define an Analytics item that is associated to an Application Insights component. @@ -195,8 +188,7 @@ type ComponentExportConfiguration struct { NotificationQueueEnabled *string // This comma separated list of document types that will be exported. The possible values include 'Requests', 'Event', 'Exceptions', - // 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', - // 'PerformanceCounters', 'Availability', 'Messages'. + // 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. RecordTypes *string // READ-ONLY; The name of the Application Insights component. @@ -282,8 +274,7 @@ type ComponentExportRequest struct { NotificationQueueURI *string // The document types to be exported, as comma separated values. Allowed values include 'Requests', 'Event', 'Exceptions', - // 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', - // 'Availability', 'Messages'. + // 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. RecordTypes *string } @@ -439,6 +430,9 @@ type ComponentLinkedStorageAccounts struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -449,13 +443,12 @@ type ComponentLinkedStorageAccountsPatch struct { Properties *LinkedStorageAccountsProperties } -// ComponentListResult - Describes the list of Application Insights Resources. +// ComponentListResult - The response of a ApplicationInsightsComponent list operation. type ComponentListResult struct { - // REQUIRED; List of Application Insights component definitions. + // REQUIRED; The ApplicationInsightsComponent items on this page Value []*Component - // The URI to get the next set of Application Insights component definitions if too many components where returned in the - // result set. + // The link to the next page of items NextLink *string } @@ -552,8 +545,7 @@ type ComponentProperties struct { SamplingPercentage *float64 // Resource Id of the log analytics workspace which the data will be ingested to. This property is required to create an application - // with this API version. Applications from older versions will not have - // this property. + // with this API version. Applications from older versions will not have this property. WorkspaceResourceID *string // READ-ONLY; Application Insights Unique ID for your Application. @@ -572,8 +564,8 @@ type ComponentProperties struct { HockeyAppToken *string // READ-ONLY; Application Insights Instrumentation key. A read-only value that applications can use to identify the destination - // for all telemetry sent to Azure Application Insights. This value will be supplied upon - // construction of each new Application Insights component. + // for all telemetry sent to Azure Application Insights. This value will be supplied upon construction of each new Application + // Insights component. InstrumentationKey *string // READ-ONLY; The date which the component got migrated to LA, in ISO 8601 format. @@ -586,8 +578,7 @@ type ComponentProperties struct { PrivateLinkScopedResources []*PrivateLinkScopedResource // READ-ONLY; Current state of this component: whether or not is has been provisioned within the resource group it is defined. - // Users cannot change this value but are able to read from it. Values will include - // Succeeded, Deploying, Canceled, and Failed. + // Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. ProvisioningState *string // READ-ONLY; Azure Tenant Id. @@ -653,24 +644,6 @@ type ComponentWebTestLocation struct { Tag *string } -// ComponentsResource - An azure resource object -type ComponentsResource struct { - // REQUIRED; Resource location - Location *string - - // Resource tags - Tags map[string]*string - - // READ-ONLY; Azure resource Id - ID *string - - // READ-ONLY; Azure resource name - Name *string - - // READ-ONLY; Azure resource type - Type *string -} - // DeletedWorkbook - A workbook definition. type DeletedWorkbook struct { // REQUIRED; The geo-location where the resource lives @@ -688,7 +661,7 @@ type DeletedWorkbook struct { // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string // READ-ONLY; The name of the resource @@ -701,30 +674,6 @@ type DeletedWorkbook struct { Type *string } -// DeletedWorkbookError - Error response. -type DeletedWorkbookError struct { - // The error details. - Error *DeletedWorkbookErrorDefinition -} - -// DeletedWorkbookErrorDefinition - Error definition. -type DeletedWorkbookErrorDefinition struct { - // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. - Code *string - - // READ-ONLY; Internal error details. - Innererror *DeletedWorkbookInnerErrorTrace - - // READ-ONLY; Description of the error. - Message *string -} - -// DeletedWorkbookInnerErrorTrace - Error details -type DeletedWorkbookInnerErrorTrace struct { - // READ-ONLY; detailed error trace - Trace []*string -} - // DeletedWorkbookProperties - Properties that contain a workbook. type DeletedWorkbookProperties struct { // REQUIRED; Workbook category, as defined by the user at creation time. @@ -761,98 +710,15 @@ type DeletedWorkbookProperties struct { UserID *string } -// DeletedWorkbookResource - An azure resource object -type DeletedWorkbookResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string - - // Resource etag - Etag *string - - // The kind of workbook. Only valid value is shared. - Kind *WorkbookSharedTypeKind - - // Resource tags. - Tags map[string]*string - - // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - // DeletedWorkbooksListResult - Workbook list result. type DeletedWorkbooksListResult struct { + // The link to the next page of results. NextLink *string // READ-ONLY; An array of workbooks. Value []*DeletedWorkbook } -// ErrorFieldContract - Error Field contract. -type ErrorFieldContract struct { - // Property level error code. - Code *string - - // Human-readable representation of property-level error. - Message *string - - // Property name. - Target *string -} - -// ErrorResponse - Error response indicates Insights service is not able to process the incoming request. The reason is provided -// in the error message. -type ErrorResponse struct { - // Error code. - Code *string - - // The list of invalid fields send in request, in case of validation error. - Details []*ErrorFieldContract - - // Error message indicating why the operation failed. - Message *string -} - -type ErrorResponseComponents struct { - // Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error - // message. - Error *ErrorResponseComponentsError -} - -// ErrorResponseComponentsError - Error response indicates Insights service is not able to process the incoming request. The -// reason is provided in the error message. -type ErrorResponseComponentsError struct { - // READ-ONLY; Error code. - Code *string - - // READ-ONLY; Error message indicating why the operation failed. - Message *string -} - -type ErrorResponseLinkedStorage struct { - // Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error - // message. - Error *ErrorResponseLinkedStorageError -} - -// ErrorResponseLinkedStorageError - Error response indicates Insights service is not able to process the incoming request. -// The reason is provided in the error message. -type ErrorResponseLinkedStorageError struct { - // READ-ONLY; Error code. - Code *string - - // READ-ONLY; Error message indicating why the operation failed. - Message *string -} - // HeaderField - A header to add to the WebTest. type HeaderField struct { // The name of the header. @@ -862,15 +728,6 @@ type HeaderField struct { HeaderFieldValue *string } -// InnerError - Inner error -type InnerError struct { - // Provides correlation for request - Diagnosticcontext *string - - // Request time - Time *time.Time -} - // LinkedStorageAccountsProperties - An Application Insights component linked storage account type LinkedStorageAccountsProperties struct { // Linked storage account resource ID @@ -883,26 +740,6 @@ type LiveTokenResponse struct { LiveToken *string } -// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) -type ManagedServiceIdentity struct { - // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). - Type *ManagedServiceIdentityType - - // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM - // resource ids in the form: - // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - // The dictionary values can be empty objects ({}) in - // requests. - UserAssignedIdentities map[string]*UserAssignedIdentity - - // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned - // identity. - PrincipalID *string - - // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. - TenantID *string -} - // Operation - Azure Workbooks REST API operation type Operation struct { // The object that represents the operation. @@ -924,23 +761,8 @@ type OperationDisplay struct { Resource *string } -// OperationInfo - Information about an operation -type OperationInfo struct { - // Description of the operation - Description *string - - // Name of the operation - Operation *string - - // Name of the provider - Provider *string - - // Name of the resource type - Resource *string -} - -// OperationListResult - Result of the request to list Azure Workbooks operations. It contains a list of operations and a -// URL link to get the next set of results. +// OperationListResult - Result of the request to list Azure Workbooks operations. +// It contains a list of operations and a URL link to get the next set of results. type OperationListResult struct { // URL to get the next set of operation list results if there are any. NextLink *string @@ -949,33 +771,6 @@ type OperationListResult struct { Value []*Operation } -// OperationLive - Represents an operation returned by the GetOperations request -type OperationLive struct { - // Display name of the operation - Display *OperationInfo - - // Indicates whether the operation is a data action - IsDataAction *bool - - // Name of the operation - Name *string - - // Origin of the operation - Origin *string - - // Properties of the operation - Properties any -} - -// OperationsListResult - Result of the List Operations operation -type OperationsListResult struct { - // URL to get the next set of operation list results if there are any. - NextLink *string - - // A collection of operations - Value []*OperationLive -} - // PrivateLinkScopedResource - The private link scope resource reference. type PrivateLinkScopedResource struct { // The full resource Id of the private link scope resource. @@ -985,46 +780,6 @@ type PrivateLinkScopedResource struct { ScopeID *string } -// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a -// location -type ProxyResource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - -// Resource - Common fields that are returned in the response for all Azure Resource Manager resources -type Resource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - -// ResourceAutoGenerated - Common fields that are returned in the response for all Azure Resource Manager resources -type ResourceAutoGenerated struct { - // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -1052,47 +807,6 @@ type TagsResource struct { Tags map[string]*string } -// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' -// and a 'location' -type TrackedResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string - - // Resource tags. - Tags map[string]*string - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - -// TrackedResourceAutoGenerated - The resource model definition for an Azure Resource Manager tracked top level resource which -// has 'tags' and a 'location' -type TrackedResourceAutoGenerated struct { - // REQUIRED; The geo-location where the resource lives - Location *string - - // Resource tags. - Tags map[string]*string - - // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - // UserAssignedIdentity - User assigned identity properties type UserAssignedIdentity struct { // READ-ONLY; The client ID of the assigned identity. @@ -1133,13 +847,12 @@ type WebTestGeolocation struct { Location *string } -// WebTestListResult - A list of 0 or more Application Insights WebTest definitions. +// WebTestListResult - Paged collection of WebTest items type WebTestListResult struct { - // REQUIRED; Set of Application Insights WebTest definitions. + // REQUIRED; The WebTest items on this page Value []*WebTest - // The link to get the next part of the returned list of WebTest, should the return set be too large for a single request. - // May be null. + // The link to the next page of items NextLink *string } @@ -1147,6 +860,9 @@ type WebTestListResult struct { type WebTestLocationsListResult struct { // REQUIRED; List of web test locations. Value []*ComponentWebTestLocation + + // The URL to the next page of results + NextLink *string } // WebTestProperties - Metadata describing a web test for an Azure resource. @@ -1188,8 +904,7 @@ type WebTestProperties struct { ValidationRules *WebTestPropertiesValidationRules // READ-ONLY; Current state of this component, whether or not is has been provisioned within the resource group it is defined. - // Users cannot change this value but are able to read from it. Values will include - // Succeeded, Deploying, Canceled, and Failed. + // Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. ProvisioningState *string } @@ -1252,24 +967,6 @@ type WebTestPropertiesValidationRulesContentValidation struct { PassIfTextFound *bool } -// WebtestsResource - An azure resource object -type WebtestsResource struct { - // REQUIRED; Resource location - Location *string - - // Resource tags - Tags map[string]*string - - // READ-ONLY; Azure resource Id - ID *string - - // READ-ONLY; Azure resource name - Name *string - - // READ-ONLY; Azure resource type - Type *string -} - // WorkItemConfiguration - Work item configuration associated with an application insights resource. type WorkItemConfiguration struct { // Configuration friendly name @@ -1288,20 +985,11 @@ type WorkItemConfiguration struct { IsDefault *bool } -// WorkItemConfigurationError - Error associated with trying to get work item configuration or configurations -type WorkItemConfigurationError struct { - // Error detail code and explanation - Code *string - - // Inner error - Innererror *InnerError - - // Error message - Message *string -} - // WorkItemConfigurationsListResult - Work item configuration list result. type WorkItemConfigurationsListResult struct { + // The url to the next page of results. + NextLink *string + // READ-ONLY; An array of work item configurations. Value []*WorkItemConfiguration } @@ -1347,37 +1035,13 @@ type Workbook struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// WorkbookError - Error response. -type WorkbookError struct { - // The error details. - Error *WorkbookErrorDefinition -} - -// WorkbookErrorDefinition - Error definition. -type WorkbookErrorDefinition struct { - // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. - Code *string - - // READ-ONLY; Internal error details. - Innererror *WorkbookInnerErrorTrace - - // READ-ONLY; Description of the error. - Message *string -} - -// WorkbookInnerErrorTrace - Error details -type WorkbookInnerErrorTrace struct { - // READ-ONLY; detailed error trace - Trace []*string -} - // WorkbookProperties - Properties that contain a workbook. type WorkbookProperties struct { // REQUIRED; Workbook category, as defined by the user at creation time. @@ -1435,43 +1099,12 @@ type WorkbookPropertiesUpdateParameters struct { Tags []*string } -// WorkbookResource - An azure resource object -type WorkbookResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string - - // Resource etag - Etag *string - - // Identity used for BYOS - Identity *WorkbookResourceIdentity - - // The kind of workbook. Only valid value is shared. - Kind *WorkbookSharedTypeKind - - // Resource tags. - Tags map[string]*string - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string -} - // WorkbookResourceIdentity - Identity used for BYOS type WorkbookResourceIdentity struct { - // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + // REQUIRED; The type of managed identity assigned to this resource. Type *ManagedServiceIdentityType - // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM - // resource ids in the form: - // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - // The dictionary values can be empty objects ({}) in - // requests. + // The identities assigned to this resource by the user. UserAssignedIdentities map[string]*UserAssignedIdentity // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned @@ -1484,53 +1117,26 @@ type WorkbookResourceIdentity struct { // WorkbookTemplate - An Application Insights workbook template definition. type WorkbookTemplate struct { - // REQUIRED; Resource location + // REQUIRED; The geo-location where the resource lives Location *string // Metadata describing a workbook template for an Azure resource. Properties *WorkbookTemplateProperties - // Resource tags + // Resource tags. Tags map[string]*string - // READ-ONLY; Azure resource Id + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; Azure resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Azure resource type - Type *string -} - -// WorkbookTemplateError - Error message that will indicate why the operation failed. -type WorkbookTemplateError struct { - // Error message object that will indicate why the operation failed. - Error *WorkbookTemplateErrorBody -} - -// WorkbookTemplateErrorBody - Error message body that will indicate why the operation failed. -type WorkbookTemplateErrorBody struct { - // Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - Code *string - - // The list of invalid fields send in request, in case of validation error. - Details []*WorkbookTemplateErrorFieldContract - - // Human-readable representation of the error. - Message *string -} - -// WorkbookTemplateErrorFieldContract - Error Field contract. -type WorkbookTemplateErrorFieldContract struct { - // Property level error code. - Code *string - - // Human-readable representation of property-level error. - Message *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // Property name. - Target *string + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } // WorkbookTemplateGallery - Gallery information for a workbook template. @@ -1578,24 +1184,6 @@ type WorkbookTemplateProperties struct { Priority *int32 } -// WorkbookTemplateResource - An azure resource object -type WorkbookTemplateResource struct { - // REQUIRED; Resource location - Location *string - - // Resource tags - Tags map[string]*string - - // READ-ONLY; Azure resource Id - ID *string - - // READ-ONLY; Azure resource name. - Name *string - - // READ-ONLY; Azure resource type - Type *string -} - // WorkbookTemplateUpdateParameters - The parameters that can be provided when updating workbook template. type WorkbookTemplateUpdateParameters struct { // Metadata describing a workbook for an Azure resource. @@ -1607,6 +1195,9 @@ type WorkbookTemplateUpdateParameters struct { // WorkbookTemplatesListResult - WorkbookTemplate list result. type WorkbookTemplatesListResult struct { + // The URL to get the next page of results. + NextLink *string + // An array of workbook templates. Value []*WorkbookTemplate } @@ -1625,6 +1216,7 @@ type WorkbookUpdateParameters struct { // WorkbooksListResult - Workbook list result. type WorkbooksListResult struct { + // The link to the next page of results. NextLink *string // READ-ONLY; An array of workbooks. diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/models_serde.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/models_serde.go index 8279f53e9a48..92cb2e745499 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/models_serde.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/models_serde.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -9,7 +8,9 @@ import ( "encoding/json" "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime" "reflect" + "time" ) // MarshalJSON implements the json.Marshaller interface for type APIKeyRequest. @@ -52,7 +53,7 @@ func (a Annotation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "AnnotationName", a.AnnotationName) populate(objectMap, "Category", a.Category) - populateDateTimeRFC3339(objectMap, "EventTime", a.EventTime) + populateTime[datetime.RFC3339](objectMap, "EventTime", a.EventTime) populate(objectMap, "Id", a.ID) populate(objectMap, "Properties", a.Properties) populate(objectMap, "RelatedAnnotation", a.RelatedAnnotation) @@ -75,7 +76,7 @@ func (a *Annotation) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Category", &a.Category) delete(rawMsg, key) case "EventTime": - err = unpopulateDateTimeRFC3339(val, "EventTime", &a.EventTime) + err = unpopulateTime[datetime.RFC3339](val, "EventTime", &a.EventTime) delete(rawMsg, key) case "Id": err = unpopulate(val, "ID", &a.ID) @@ -94,44 +95,10 @@ func (a *Annotation) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AnnotationError. -func (a AnnotationError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", a.Code) - populate(objectMap, "innererror", a.Innererror) - populate(objectMap, "message", a.Message) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AnnotationError. -func (a *AnnotationError) 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", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "code": - err = unpopulate(val, "Code", &a.Code) - delete(rawMsg, key) - case "innererror": - err = unpopulate(val, "Innererror", &a.Innererror) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &a.Message) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type AnnotationsListResult. func (a AnnotationsListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } @@ -145,6 +112,9 @@ func (a *AnnotationsListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) @@ -261,6 +231,7 @@ func (c *ComponentAPIKey) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ComponentAPIKeyListResult. func (c ComponentAPIKeyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) } @@ -274,6 +245,9 @@ func (c *ComponentAPIKeyListResult) UnmarshalJSON(data []byte) error { 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) @@ -900,6 +874,7 @@ func (c ComponentLinkedStorageAccounts) MarshalJSON() ([]byte, error) { populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) populate(objectMap, "type", c.Type) return json.Marshal(objectMap) } @@ -922,6 +897,9 @@ func (c *ComponentLinkedStorageAccounts) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &c.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) @@ -1100,7 +1078,7 @@ func (c ComponentProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "ApplicationId", c.ApplicationID) populate(objectMap, "Application_Type", c.ApplicationType) populate(objectMap, "ConnectionString", c.ConnectionString) - populateDateTimeRFC3339(objectMap, "CreationDate", c.CreationDate) + populateTime[datetime.RFC3339](objectMap, "CreationDate", c.CreationDate) populate(objectMap, "DisableIpMasking", c.DisableIPMasking) populate(objectMap, "DisableLocalAuth", c.DisableLocalAuth) populate(objectMap, "Flow_Type", c.FlowType) @@ -1110,7 +1088,7 @@ func (c ComponentProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "ImmediatePurgeDataOn30Days", c.ImmediatePurgeDataOn30Days) populate(objectMap, "IngestionMode", c.IngestionMode) populate(objectMap, "InstrumentationKey", c.InstrumentationKey) - populateDateTimeRFC3339(objectMap, "LaMigrationDate", c.LaMigrationDate) + populateTime[datetime.RFC3339](objectMap, "LaMigrationDate", c.LaMigrationDate) populate(objectMap, "Name", c.Name) populate(objectMap, "PrivateLinkScopedResources", c.PrivateLinkScopedResources) populate(objectMap, "provisioningState", c.ProvisioningState) @@ -1146,7 +1124,7 @@ func (c *ComponentProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ConnectionString", &c.ConnectionString) delete(rawMsg, key) case "CreationDate": - err = unpopulateDateTimeRFC3339(val, "CreationDate", &c.CreationDate) + err = unpopulateTime[datetime.RFC3339](val, "CreationDate", &c.CreationDate) delete(rawMsg, key) case "DisableIpMasking": err = unpopulate(val, "DisableIPMasking", &c.DisableIPMasking) @@ -1176,7 +1154,7 @@ func (c *ComponentProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "InstrumentationKey", &c.InstrumentationKey) delete(rawMsg, key) case "LaMigrationDate": - err = unpopulateDateTimeRFC3339(val, "LaMigrationDate", &c.LaMigrationDate) + err = unpopulateTime[datetime.RFC3339](val, "LaMigrationDate", &c.LaMigrationDate) delete(rawMsg, key) case "Name": err = unpopulate(val, "Name", &c.Name) @@ -1406,49 +1384,6 @@ func (c *ComponentWebTestLocation) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ComponentsResource. -func (c ComponentsResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", c.ID) - populate(objectMap, "location", c.Location) - populate(objectMap, "name", c.Name) - populate(objectMap, "tags", c.Tags) - populate(objectMap, "type", c.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentsResource. -func (c *ComponentsResource) 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 "id": - err = unpopulate(val, "ID", &c.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &c.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &c.Name) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &c.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &c.Type) - 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 DeletedWorkbook. func (d DeletedWorkbook) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1508,95 +1443,6 @@ func (d *DeletedWorkbook) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DeletedWorkbookError. -func (d DeletedWorkbookError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", d.Error) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeletedWorkbookError. -func (d *DeletedWorkbookError) 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", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &d.Error) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DeletedWorkbookErrorDefinition. -func (d DeletedWorkbookErrorDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", d.Code) - populate(objectMap, "innererror", d.Innererror) - populate(objectMap, "message", d.Message) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeletedWorkbookErrorDefinition. -func (d *DeletedWorkbookErrorDefinition) 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", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "code": - err = unpopulate(val, "Code", &d.Code) - delete(rawMsg, key) - case "innererror": - err = unpopulate(val, "Innererror", &d.Innererror) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &d.Message) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DeletedWorkbookInnerErrorTrace. -func (d DeletedWorkbookInnerErrorTrace) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "trace", d.Trace) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeletedWorkbookInnerErrorTrace. -func (d *DeletedWorkbookInnerErrorTrace) 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", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "trace": - err = unpopulate(val, "Trace", &d.Trace) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type DeletedWorkbookProperties. func (d DeletedWorkbookProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1608,7 +1454,7 @@ func (d DeletedWorkbookProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "sourceId", d.SourceID) populate(objectMap, "storageUri", d.StorageURI) populate(objectMap, "tags", d.Tags) - populateDateTimeRFC3339(objectMap, "timeModified", d.TimeModified) + populateTime[datetime.RFC3339](objectMap, "timeModified", d.TimeModified) populate(objectMap, "userId", d.UserID) populate(objectMap, "version", d.Version) return json.Marshal(objectMap) @@ -1648,7 +1494,7 @@ func (d *DeletedWorkbookProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Tags", &d.Tags) delete(rawMsg, key) case "timeModified": - err = unpopulateDateTimeRFC3339(val, "TimeModified", &d.TimeModified) + err = unpopulateTime[datetime.RFC3339](val, "TimeModified", &d.TimeModified) delete(rawMsg, key) case "userId": err = unpopulate(val, "UserID", &d.UserID) @@ -1664,61 +1510,6 @@ func (d *DeletedWorkbookProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DeletedWorkbookResource. -func (d DeletedWorkbookResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "etag", d.Etag) - populate(objectMap, "id", d.ID) - populate(objectMap, "kind", d.Kind) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "systemData", d.SystemData) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeletedWorkbookResource. -func (d *DeletedWorkbookResource) 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", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "etag": - err = unpopulate(val, "Etag", &d.Etag) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &d.Kind) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &d.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &d.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type DeletedWorkbooksListResult. func (d DeletedWorkbooksListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1750,552 +1541,183 @@ func (d *DeletedWorkbooksListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorFieldContract. -func (e ErrorFieldContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type HeaderField. +func (h HeaderField) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", e.Code) - populate(objectMap, "message", e.Message) - populate(objectMap, "target", e.Target) + populate(objectMap, "key", h.HeaderFieldName) + populate(objectMap, "value", h.HeaderFieldValue) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorFieldContract. -func (e *ErrorFieldContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type HeaderField. +func (h *HeaderField) 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", e, err) + return fmt.Errorf("unmarshalling type %T: %v", h, err) } for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) + case "key": + err = unpopulate(val, "HeaderFieldName", &h.HeaderFieldName) delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &e.Target) + case "value": + err = unpopulate(val, "HeaderFieldValue", &h.HeaderFieldValue) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", h, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. -func (e ErrorResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type LinkedStorageAccountsProperties. +func (l LinkedStorageAccountsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", e.Code) - populate(objectMap, "details", e.Details) - populate(objectMap, "message", e.Message) + populate(objectMap, "linkedStorageAccount", l.LinkedStorageAccount) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. -func (e *ErrorResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkedStorageAccountsProperties. +func (l *LinkedStorageAccountsProperties) 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", e, err) + return fmt.Errorf("unmarshalling type %T: %v", l, err) } for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) + case "linkedStorageAccount": + err = unpopulate(val, "LinkedStorageAccount", &l.LinkedStorageAccount) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", l, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponseComponents. -func (e ErrorResponseComponents) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type LiveTokenResponse. +func (l LiveTokenResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "error", e.Error) + populate(objectMap, "liveToken", l.LiveToken) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseComponents. -func (e *ErrorResponseComponents) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type LiveTokenResponse. +func (l *LiveTokenResponse) 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", e, err) + return fmt.Errorf("unmarshalling type %T: %v", l, err) } for key, val := range rawMsg { var err error switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) + case "liveToken": + err = unpopulate(val, "LiveToken", &l.LiveToken) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", l, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponseComponentsError. -func (e ErrorResponseComponentsError) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", e.Code) - populate(objectMap, "message", e.Message) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseComponentsError. -func (e *ErrorResponseComponentsError) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) 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", e, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &e.Code) + case "display": + err = unpopulate(val, "Display", &o.Display) delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) + case "name": + err = unpopulate(val, "Name", &o.Name) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponseLinkedStorage. -func (e ErrorResponseLinkedStorage) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "error", e.Error) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseLinkedStorage. -func (e *ErrorResponseLinkedStorage) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) 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", e, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponseLinkedStorageError. -func (e ErrorResponseLinkedStorageError) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "code", e.Code) - populate(objectMap, "message", e.Message) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseLinkedStorageError. -func (e *ErrorResponseLinkedStorageError) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) 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", e, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &e.Code) + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) + case "value": + err = unpopulate(val, "Value", &o.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type HeaderField. -func (h HeaderField) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "key", h.HeaderFieldName) - populate(objectMap, "value", h.HeaderFieldValue) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type HeaderField. -func (h *HeaderField) 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", h, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "key": - err = unpopulate(val, "HeaderFieldName", &h.HeaderFieldName) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "HeaderFieldValue", &h.HeaderFieldValue) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", h, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type InnerError. -func (i InnerError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "diagnosticcontext", i.Diagnosticcontext) - populateDateTimeRFC3339(objectMap, "time", i.Time) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type InnerError. -func (i *InnerError) 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", i, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "diagnosticcontext": - err = unpopulate(val, "Diagnosticcontext", &i.Diagnosticcontext) - delete(rawMsg, key) - case "time": - err = unpopulateDateTimeRFC3339(val, "Time", &i.Time) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type LinkedStorageAccountsProperties. -func (l LinkedStorageAccountsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "linkedStorageAccount", l.LinkedStorageAccount) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LinkedStorageAccountsProperties. -func (l *LinkedStorageAccountsProperties) 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", l, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "linkedStorageAccount": - err = unpopulate(val, "LinkedStorageAccount", &l.LinkedStorageAccount) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", l, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type LiveTokenResponse. -func (l LiveTokenResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "liveToken", l.LiveToken) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LiveTokenResponse. -func (l *LiveTokenResponse) 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", l, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "liveToken": - err = unpopulate(val, "LiveToken", &l.LiveToken) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", l, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. -func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "principalId", m.PrincipalID) - populate(objectMap, "tenantId", m.TenantID) - populate(objectMap, "type", m.Type) - populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. -func (m *ManagedServiceIdentity) 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", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "principalId": - err = unpopulate(val, "PrincipalID", &m.PrincipalID) - delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, "TenantID", &m.TenantID) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &m.Type) - delete(rawMsg, key) - case "userAssignedIdentities": - err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Operation. -func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "display", o.Display) - populate(objectMap, "name", o.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. -func (o *Operation) 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 "display": - err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - 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 OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "operation", o.Operation) - populate(objectMap, "provider", o.Provider) - populate(objectMap, "resource", o.Resource) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. -func (o *OperationDisplay) 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 "operation": - err = unpopulate(val, "Operation", &o.Operation) - delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) - delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) - 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 OperationInfo. -func (o OperationInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "description", o.Description) - populate(objectMap, "operation", o.Operation) - populate(objectMap, "provider", o.Provider) - populate(objectMap, "resource", o.Resource) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationInfo. -func (o *OperationInfo) 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 "description": - err = unpopulate(val, "Description", &o.Description) - delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &o.Operation) - delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) - delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) - 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 OperationListResult. -func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. -func (o *OperationListResult) 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 "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &o.Value) - 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 OperationLive. -func (o OperationLive) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "display", o.Display) - populate(objectMap, "isDataAction", o.IsDataAction) - populate(objectMap, "name", o.Name) - populate(objectMap, "origin", o.Origin) - populateAny(objectMap, "properties", o.Properties) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationLive. -func (o *OperationLive) 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 "display": - err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) - case "isDataAction": - err = unpopulate(val, "IsDataAction", &o.IsDataAction) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - case "origin": - err = unpopulate(val, "Origin", &o.Origin) - delete(rawMsg, 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 OperationsListResult. -func (o OperationsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationsListResult. -func (o *OperationsListResult) 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 "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &o.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil @@ -2332,122 +1754,13 @@ func (p *PrivateLinkScopedResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ProxyResource. -func (p ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. -func (p *ProxyResource) 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 "type": - err = unpopulate(val, "Type", &p.Type) - 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 Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ResourceAutoGenerated. -func (r ResourceAutoGenerated) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "systemData", r.SystemData) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceAutoGenerated. -func (r *ResourceAutoGenerated) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateTime[datetime.RFC3339](objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateTime[datetime.RFC3339](objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -2463,7 +1776,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateTime[datetime.RFC3339](val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -2472,7 +1785,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateTime[datetime.RFC3339](val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) @@ -2515,96 +1828,6 @@ func (t *TagsResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. -func (t *TrackedResource) 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", t, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &t.Name) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &t.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &t.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResourceAutoGenerated. -func (t TrackedResourceAutoGenerated) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "systemData", t.SystemData) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResourceAutoGenerated. -func (t *TrackedResourceAutoGenerated) 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", t, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &t.Name) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &t.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &t.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &t.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2748,6 +1971,7 @@ func (w *WebTestListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WebTestLocationsListResult. func (w WebTestLocationsListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) populate(objectMap, "value", w.Value) return json.Marshal(objectMap) } @@ -2761,6 +1985,9 @@ func (w *WebTestLocationsListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &w.Value) delete(rawMsg, key) @@ -2999,49 +2226,6 @@ func (w *WebTestPropertiesValidationRulesContentValidation) UnmarshalJSON(data [ return nil } -// MarshalJSON implements the json.Marshaller interface for type WebtestsResource. -func (w WebtestsResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", w.ID) - populate(objectMap, "location", w.Location) - populate(objectMap, "name", w.Name) - populate(objectMap, "tags", w.Tags) - populate(objectMap, "type", w.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WebtestsResource. -func (w *WebtestsResource) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &w.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &w.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &w.Name) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &w.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &w.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type WorkItemConfiguration. func (w WorkItemConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3054,48 +2238,7 @@ func (w WorkItemConfiguration) MarshalJSON() ([]byte, error) { } // UnmarshalJSON implements the json.Unmarshaller interface for type WorkItemConfiguration. -func (w *WorkItemConfiguration) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "ConfigDisplayName": - err = unpopulate(val, "ConfigDisplayName", &w.ConfigDisplayName) - delete(rawMsg, key) - case "ConfigProperties": - err = unpopulate(val, "ConfigProperties", &w.ConfigProperties) - delete(rawMsg, key) - case "ConnectorId": - err = unpopulate(val, "ConnectorID", &w.ConnectorID) - delete(rawMsg, key) - case "Id": - err = unpopulate(val, "ID", &w.ID) - delete(rawMsg, key) - case "IsDefault": - err = unpopulate(val, "IsDefault", &w.IsDefault) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WorkItemConfigurationError. -func (w WorkItemConfigurationError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", w.Code) - populate(objectMap, "innererror", w.Innererror) - populate(objectMap, "message", w.Message) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkItemConfigurationError. -func (w *WorkItemConfigurationError) UnmarshalJSON(data []byte) error { +func (w *WorkItemConfiguration) 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", w, err) @@ -3103,14 +2246,20 @@ func (w *WorkItemConfigurationError) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "code": - err = unpopulate(val, "Code", &w.Code) + case "ConfigDisplayName": + err = unpopulate(val, "ConfigDisplayName", &w.ConfigDisplayName) + delete(rawMsg, key) + case "ConfigProperties": + err = unpopulate(val, "ConfigProperties", &w.ConfigProperties) + delete(rawMsg, key) + case "ConnectorId": + err = unpopulate(val, "ConnectorID", &w.ConnectorID) delete(rawMsg, key) - case "innererror": - err = unpopulate(val, "Innererror", &w.Innererror) + case "Id": + err = unpopulate(val, "ID", &w.ID) delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &w.Message) + case "IsDefault": + err = unpopulate(val, "IsDefault", &w.IsDefault) delete(rawMsg, key) } if err != nil { @@ -3123,6 +2272,7 @@ func (w *WorkItemConfigurationError) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkItemConfigurationsListResult. func (w WorkItemConfigurationsListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) populate(objectMap, "value", w.Value) return json.Marshal(objectMap) } @@ -3136,6 +2286,9 @@ func (w *WorkItemConfigurationsListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &w.Value) delete(rawMsg, key) @@ -3249,95 +2402,6 @@ func (w *Workbook) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type WorkbookError. -func (w WorkbookError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", w.Error) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkbookError. -func (w *WorkbookError) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &w.Error) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WorkbookErrorDefinition. -func (w WorkbookErrorDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", w.Code) - populate(objectMap, "innererror", w.Innererror) - populate(objectMap, "message", w.Message) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkbookErrorDefinition. -func (w *WorkbookErrorDefinition) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "code": - err = unpopulate(val, "Code", &w.Code) - delete(rawMsg, key) - case "innererror": - err = unpopulate(val, "Innererror", &w.Innererror) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &w.Message) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WorkbookInnerErrorTrace. -func (w WorkbookInnerErrorTrace) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "trace", w.Trace) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkbookInnerErrorTrace. -func (w *WorkbookInnerErrorTrace) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "trace": - err = unpopulate(val, "Trace", &w.Trace) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type WorkbookProperties. func (w WorkbookProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3349,7 +2413,7 @@ func (w WorkbookProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "sourceId", w.SourceID) populate(objectMap, "storageUri", w.StorageURI) populate(objectMap, "tags", w.Tags) - populateDateTimeRFC3339(objectMap, "timeModified", w.TimeModified) + populateTime[datetime.RFC3339](objectMap, "timeModified", w.TimeModified) populate(objectMap, "userId", w.UserID) populate(objectMap, "version", w.Version) return json.Marshal(objectMap) @@ -3389,7 +2453,7 @@ func (w *WorkbookProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Tags", &w.Tags) delete(rawMsg, key) case "timeModified": - err = unpopulateDateTimeRFC3339(val, "TimeModified", &w.TimeModified) + err = unpopulateTime[datetime.RFC3339](val, "TimeModified", &w.TimeModified) delete(rawMsg, key) case "userId": err = unpopulate(val, "UserID", &w.UserID) @@ -3452,61 +2516,6 @@ func (w *WorkbookPropertiesUpdateParameters) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type WorkbookResource. -func (w WorkbookResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "etag", w.Etag) - populate(objectMap, "id", w.ID) - populate(objectMap, "identity", w.Identity) - populate(objectMap, "kind", w.Kind) - populate(objectMap, "location", w.Location) - populate(objectMap, "name", w.Name) - populate(objectMap, "tags", w.Tags) - populate(objectMap, "type", w.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkbookResource. -func (w *WorkbookResource) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "etag": - err = unpopulate(val, "Etag", &w.Etag) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &w.ID) - delete(rawMsg, key) - case "identity": - err = unpopulate(val, "Identity", &w.Identity) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &w.Kind) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &w.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &w.Name) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &w.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &w.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type WorkbookResourceIdentity. func (w WorkbookResourceIdentity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3553,6 +2562,7 @@ func (w WorkbookTemplate) MarshalJSON() ([]byte, error) { populate(objectMap, "location", w.Location) populate(objectMap, "name", w.Name) populate(objectMap, "properties", w.Properties) + populate(objectMap, "systemData", w.SystemData) populate(objectMap, "tags", w.Tags) populate(objectMap, "type", w.Type) return json.Marshal(objectMap) @@ -3579,6 +2589,9 @@ func (w *WorkbookTemplate) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &w.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &w.SystemData) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &w.Tags) delete(rawMsg, key) @@ -3593,103 +2606,6 @@ func (w *WorkbookTemplate) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type WorkbookTemplateError. -func (w WorkbookTemplateError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", w.Error) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkbookTemplateError. -func (w *WorkbookTemplateError) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &w.Error) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WorkbookTemplateErrorBody. -func (w WorkbookTemplateErrorBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", w.Code) - populate(objectMap, "details", w.Details) - populate(objectMap, "message", w.Message) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkbookTemplateErrorBody. -func (w *WorkbookTemplateErrorBody) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "code": - err = unpopulate(val, "Code", &w.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &w.Details) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &w.Message) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WorkbookTemplateErrorFieldContract. -func (w WorkbookTemplateErrorFieldContract) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", w.Code) - populate(objectMap, "message", w.Message) - populate(objectMap, "target", w.Target) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkbookTemplateErrorFieldContract. -func (w *WorkbookTemplateErrorFieldContract) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "code": - err = unpopulate(val, "Code", &w.Code) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &w.Message) - delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &w.Target) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type WorkbookTemplateGallery. func (w WorkbookTemplateGallery) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3807,49 +2723,6 @@ func (w *WorkbookTemplateProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type WorkbookTemplateResource. -func (w WorkbookTemplateResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", w.ID) - populate(objectMap, "location", w.Location) - populate(objectMap, "name", w.Name) - populate(objectMap, "tags", w.Tags) - populate(objectMap, "type", w.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WorkbookTemplateResource. -func (w *WorkbookTemplateResource) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &w.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &w.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &w.Name) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &w.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &w.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type WorkbookTemplateUpdateParameters. func (w WorkbookTemplateUpdateParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3884,6 +2757,7 @@ func (w *WorkbookTemplateUpdateParameters) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkbookTemplatesListResult. func (w WorkbookTemplatesListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) populate(objectMap, "value", w.Value) return json.Marshal(objectMap) } @@ -3897,6 +2771,9 @@ func (w *WorkbookTemplatesListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &w.Value) delete(rawMsg, key) @@ -3984,6 +2861,17 @@ func populate(m map[string]any, k string, v any) { } } +func populateTime[T dateTimeConstraints](m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + } else if !reflect.ValueOf(t).IsNil() { + newTime := T(*t) + m[k] = (*T)(&newTime) + } +} + func populateAny(m map[string]any, k string, v any) { if v == nil { return @@ -4003,3 +2891,20 @@ func unpopulate(data json.RawMessage, fn string, v any) error { } return nil } + +func unpopulateTime[T dateTimeConstraints](data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux T + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + newTime := time.Time(aux) + *t = &newTime + return nil +} + +type dateTimeConstraints interface { + datetime.PlainDate | datetime.PlainTime | datetime.RFC1123 | datetime.RFC3339 | datetime.Unix +} diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/operations_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/operations_client.go index 7d97bf8cfa67..38edce909b70 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/operations_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/operations_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -12,17 +11,20 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" + "strings" ) // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. +// +// Generated from API version 2021-03-08 type OperationsClient struct { internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -34,9 +36,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - Lists all of the available insights REST API operations. -// -// Generated from API version 2021-03-08 +// NewListPager - List the operations for the provider // - 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]{ @@ -69,8 +69,8 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *Operat return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-03-08") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20210308) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/options.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/options.go index 4ec36a27c90d..c28fd64d989d 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/options.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/options.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -376,8 +375,7 @@ type WorkbookTemplatesClientListByResourceGroupOptions struct { // WorkbookTemplatesClientUpdateOptions contains the optional parameters for the WorkbookTemplatesClient.Update method. type WorkbookTemplatesClientUpdateOptions struct { - // Properties that need to be specified to patch a workbook template. - WorkbookTemplateUpdateParameters *WorkbookTemplateUpdateParameters + // placeholder for future optional parameters } // WorkbooksClientCreateOrUpdateOptions contains the optional parameters for the WorkbooksClient.CreateOrUpdate method. @@ -437,7 +435,4 @@ type WorkbooksClientRevisionsListOptions struct { type WorkbooksClientUpdateOptions struct { // Azure Resource Id that will fetch all linked workbooks. SourceID *string - - // Properties that need to be specified to create a new workbook. - WorkbookUpdateParameters *WorkbookUpdateParameters } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/proactivedetectionconfigurations_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/proactivedetectionconfigurations_client.go index bdb49cafe68a..33c58fb755f6 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/proactivedetectionconfigurations_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/proactivedetectionconfigurations_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // ProactiveDetectionConfigurationsClient contains the methods for the ProactiveDetectionConfigurations group. // Don't use this type directly, use NewProactiveDetectionConfigurationsClient() instead. +// +// Generated from API version 2015-05-01 type ProactiveDetectionConfigurationsClient struct { internal *arm.Client subscriptionID string } // NewProactiveDetectionConfigurationsClient creates a new instance of ProactiveDetectionConfigurationsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewProactiveDetectionConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProactiveDetectionConfigurationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewProactiveDetectionConfigurationsClient(subscriptionID string, credential // Get - Get the ProactiveDetection configuration for this configuration id. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - configurationID - The ProactiveDetection configuration ID. This is unique within a Application Insights component. @@ -74,14 +73,14 @@ func (client *ProactiveDetectionConfigurationsClient) Get(ctx context.Context, r // getCreateRequest creates the Get request. func (client *ProactiveDetectionConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, _ *ProactiveDetectionConfigurationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -95,8 +94,8 @@ func (client *ProactiveDetectionConfigurationsClient) getCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -112,8 +111,6 @@ func (client *ProactiveDetectionConfigurationsClient) getHandleResponse(resp *ht // List - Gets a list of ProactiveDetection configurations of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - ProactiveDetectionConfigurationsClientListOptions contains the optional parameters for the ProactiveDetectionConfigurationsClient.List @@ -143,14 +140,14 @@ func (client *ProactiveDetectionConfigurationsClient) List(ctx context.Context, // listCreateRequest creates the List request. func (client *ProactiveDetectionConfigurationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ProactiveDetectionConfigurationsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -160,8 +157,8 @@ func (client *ProactiveDetectionConfigurationsClient) listCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -177,8 +174,6 @@ func (client *ProactiveDetectionConfigurationsClient) listHandleResponse(resp *h // Update - Update the ProactiveDetection configuration for this configuration id. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - configurationID - The ProactiveDetection configuration ID. This is unique within a Application Insights component. @@ -210,14 +205,14 @@ func (client *ProactiveDetectionConfigurationsClient) Update(ctx context.Context // updateCreateRequest creates the Update request. func (client *ProactiveDetectionConfigurationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ComponentProactiveDetectionConfiguration, _ *ProactiveDetectionConfigurationsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -231,9 +226,10 @@ func (client *ProactiveDetectionConfigurationsClient) updateCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, proactiveDetectionProperties); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/proactivedetectionconfigurations_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/proactivedetectionconfigurations_client_example_test.go index d4dfae039cfc..da54b1d262cb 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/proactivedetectionconfigurations_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/proactivedetectionconfigurations_client_example_test.go @@ -1,44 +1,84 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/ProactiveDetectionConfigurationsList.json -func ExampleProactiveDetectionConfigurationsClient_List() { +// Generated from example definition: 2015-05-01/ProactiveDetectionConfigurationGet.json +func ExampleProactiveDetectionConfigurationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewProactiveDetectionConfigurationsClient().List(ctx, "my-resource-group", "my-component", nil) + res, err := clientFactory.NewProactiveDetectionConfigurationsClient().Get(ctx, "my-resource-group", "my-component", "slowpageloadtime", 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.ComponentProactiveDetectionConfigurationArray = []*armapplicationinsights.ComponentProactiveDetectionConfiguration{ - // { + // res = armapplicationinsights.ProactiveDetectionConfigurationsClientGetResponse{ + // ComponentProactiveDetectionConfiguration: armapplicationinsights.ComponentProactiveDetectionConfiguration{ // Name: to.Ptr("slowpageloadtime"), // CustomEmails: []*string{ // to.Ptr("foo@microsoft.com"), - // to.Ptr("foo2@microsoft.com")}, + // to.Ptr("foo2@microsoft.com"), + // }, + // Enabled: to.Ptr(true), + // RuleDefinitions: &armapplicationinsights.ComponentProactiveDetectionConfigurationRuleDefinitions{ + // Description: to.Ptr("Smart Detection rules notify you of performance anomaly issues."), + // DisplayName: to.Ptr("Slow page load time"), + // HelpURL: to.Ptr("https://docs.microsoft.com/en-us/azure/application-insights/app-insights-proactive-performance-diagnostics"), + // IsEnabledByDefault: to.Ptr(true), + // IsHidden: to.Ptr(false), + // IsInPreview: to.Ptr(false), + // Name: to.Ptr("slowpageloadtime"), + // SupportsEmailNotifications: to.Ptr(true), + // }, + // SendEmailsToSubscriptionOwners: to.Ptr(true), + // }, + // } +} + +// Generated from example definition: 2015-05-01/ProactiveDetectionConfigurationsList.json +func ExampleProactiveDetectionConfigurationsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProactiveDetectionConfigurationsClient().List(ctx, "my-resource-group", "my-component", 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 = armapplicationinsights.ProactiveDetectionConfigurationsClientListResponse{ + // ComponentProactiveDetectionConfigurationArray: []*armapplicationinsights.ComponentProactiveDetectionConfiguration{ + // { + // Name: to.Ptr("slowpageloadtime"), + // CustomEmails: []*string{ + // to.Ptr("foo@microsoft.com"), + // to.Ptr("foo2@microsoft.com"), + // }, // Enabled: to.Ptr(true), // RuleDefinitions: &armapplicationinsights.ComponentProactiveDetectionConfigurationRuleDefinitions{ // Description: to.Ptr("Smart Detection rules notify you of performance anomaly issues."), @@ -68,55 +108,19 @@ func ExampleProactiveDetectionConfigurationsClient_List() { // SupportsEmailNotifications: to.Ptr(true), // }, // SendEmailsToSubscriptionOwners: to.Ptr(true), - // }} -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/ProactiveDetectionConfigurationGet.json -func ExampleProactiveDetectionConfigurationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProactiveDetectionConfigurationsClient().Get(ctx, "my-resource-group", "my-component", "slowpageloadtime", 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.ComponentProactiveDetectionConfiguration = armapplicationinsights.ComponentProactiveDetectionConfiguration{ - // Name: to.Ptr("slowpageloadtime"), - // CustomEmails: []*string{ - // to.Ptr("foo@microsoft.com"), - // to.Ptr("foo2@microsoft.com")}, - // Enabled: to.Ptr(true), - // RuleDefinitions: &armapplicationinsights.ComponentProactiveDetectionConfigurationRuleDefinitions{ - // Description: to.Ptr("Smart Detection rules notify you of performance anomaly issues."), - // DisplayName: to.Ptr("Slow page load time"), - // HelpURL: to.Ptr("https://docs.microsoft.com/en-us/azure/application-insights/app-insights-proactive-performance-diagnostics"), - // IsEnabledByDefault: to.Ptr(true), - // IsHidden: to.Ptr(false), - // IsInPreview: to.Ptr(false), - // Name: to.Ptr("slowpageloadtime"), - // SupportsEmailNotifications: to.Ptr(true), // }, - // SendEmailsToSubscriptionOwners: to.Ptr(true), - // } + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/ProactiveDetectionConfigurationUpdate.json +// Generated from example definition: 2015-05-01/ProactiveDetectionConfigurationUpdate.json func ExampleProactiveDetectionConfigurationsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -124,7 +128,8 @@ func ExampleProactiveDetectionConfigurationsClient_Update() { Name: to.Ptr("slowpageloadtime"), CustomEmails: []*string{ to.Ptr("foo@microsoft.com"), - to.Ptr("foo2@microsoft.com")}, + to.Ptr("foo2@microsoft.com"), + }, Enabled: to.Ptr(true), RuleDefinitions: &armapplicationinsights.ComponentProactiveDetectionConfigurationRuleDefinitions{ Description: to.Ptr("Smart Detection rules notify you of performance anomaly issues."), @@ -144,11 +149,13 @@ func ExampleProactiveDetectionConfigurationsClient_Update() { // 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.ComponentProactiveDetectionConfiguration = armapplicationinsights.ComponentProactiveDetectionConfiguration{ - // Name: to.Ptr("slowpageloadtime"), - // CustomEmails: []*string{ - // to.Ptr("foo@microsoft.com"), - // to.Ptr("foo2@microsoft.com")}, + // res = armapplicationinsights.ProactiveDetectionConfigurationsClientUpdateResponse{ + // ComponentProactiveDetectionConfiguration: armapplicationinsights.ComponentProactiveDetectionConfiguration{ + // Name: to.Ptr("slowpageloadtime"), + // CustomEmails: []*string{ + // to.Ptr("foo@microsoft.com"), + // to.Ptr("foo2@microsoft.com"), + // }, // Enabled: to.Ptr(true), // RuleDefinitions: &armapplicationinsights.ComponentProactiveDetectionConfigurationRuleDefinitions{ // Description: to.Ptr("Smart Detection rules notify you of performance anomaly issues."), @@ -161,5 +168,6 @@ func ExampleProactiveDetectionConfigurationsClient_Update() { // SupportsEmailNotifications: to.Ptr(true), // }, // SendEmailsToSubscriptionOwners: to.Ptr(true), - // } + // }, + // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/responses.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/responses.go index 13f143022aed..efd209acce0c 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/responses.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/responses.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -42,7 +41,6 @@ type AnalyticsItemsClientGetResponse struct { // AnalyticsItemsClientListResponse contains the response from method AnalyticsItemsClient.List. type AnalyticsItemsClientListResponse struct { - // Array of ApplicationInsightsComponentAnalyticsItem ComponentAnalyticsItemArray []*ComponentAnalyticsItem } @@ -54,7 +52,6 @@ type AnalyticsItemsClientPutResponse struct { // AnnotationsClientCreateResponse contains the response from method AnnotationsClient.Create. type AnnotationsClientCreateResponse struct { - // Array of Annotation AnnotationArray []*Annotation } @@ -65,7 +62,6 @@ type AnnotationsClientDeleteResponse struct { // AnnotationsClientGetResponse contains the response from method AnnotationsClient.Get. type AnnotationsClientGetResponse struct { - // Array of Annotation AnnotationArray []*Annotation } @@ -153,13 +149,13 @@ type ComponentsClientGetResponse struct { // ComponentsClientListByResourceGroupResponse contains the response from method ComponentsClient.NewListByResourceGroupPager. type ComponentsClientListByResourceGroupResponse struct { - // Describes the list of Application Insights Resources. + // The response of a ApplicationInsightsComponent list operation. ComponentListResult } // ComponentsClientListResponse contains the response from method ComponentsClient.NewListPager. type ComponentsClientListResponse struct { - // Describes the list of Application Insights Resources. + // The response of a ApplicationInsightsComponent list operation. ComponentListResult } @@ -183,7 +179,6 @@ type DeletedWorkbooksClientListBySubscriptionResponse struct { // ExportConfigurationsClientCreateResponse contains the response from method ExportConfigurationsClient.Create. type ExportConfigurationsClientCreateResponse struct { - // A list of Continuous Export configurations. ComponentExportConfigurationArray []*ComponentExportConfiguration } @@ -201,7 +196,6 @@ type ExportConfigurationsClientGetResponse struct { // ExportConfigurationsClientListResponse contains the response from method ExportConfigurationsClient.List. type ExportConfigurationsClientListResponse struct { - // A list of Continuous Export configurations. ComponentExportConfigurationArray []*ComponentExportConfiguration } @@ -230,7 +224,6 @@ type FavoritesClientGetResponse struct { // FavoritesClientListResponse contains the response from method FavoritesClient.List. type FavoritesClientListResponse struct { - // Array of ApplicationInsightsComponentFavorite ComponentFavoriteArray []*ComponentFavorite } @@ -248,8 +241,8 @@ type LiveTokenClientGetResponse struct { // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { - // Result of the request to list Azure Workbooks operations. It contains a list of operations and a URL link to get the next - // set of results. + // Result of the request to list Azure Workbooks operations. + // It contains a list of operations and a URL link to get the next set of results. OperationListResult } @@ -261,7 +254,6 @@ type ProactiveDetectionConfigurationsClientGetResponse struct { // ProactiveDetectionConfigurationsClientListResponse contains the response from method ProactiveDetectionConfigurationsClient.List. type ProactiveDetectionConfigurationsClientListResponse struct { - // A list of ProactiveDetection configurations. ComponentProactiveDetectionConfigurationArray []*ComponentProactiveDetectionConfiguration } @@ -296,19 +288,19 @@ type WebTestsClientGetResponse struct { // WebTestsClientListByComponentResponse contains the response from method WebTestsClient.NewListByComponentPager. type WebTestsClientListByComponentResponse struct { - // A list of 0 or more Application Insights WebTest definitions. + // Paged collection of WebTest items WebTestListResult } // WebTestsClientListByResourceGroupResponse contains the response from method WebTestsClient.NewListByResourceGroupPager. type WebTestsClientListByResourceGroupResponse struct { - // A list of 0 or more Application Insights WebTest definitions. + // Paged collection of WebTest items WebTestListResult } // WebTestsClientListResponse contains the response from method WebTestsClient.NewListPager. type WebTestsClientListResponse struct { - // A list of 0 or more Application Insights WebTest definitions. + // Paged collection of WebTest items WebTestListResult } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/testdata/_metadata.json b/sdk/resourcemanager/applicationinsights/armapplicationinsights/testdata/_metadata.json new file mode 100644 index 000000000000..05e6acf40b1f --- /dev/null +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/testdata/_metadata.json @@ -0,0 +1,17 @@ +{ + "apiVersions": { + "AnalyticsItems": "2015-05-01", + "ComponentAPIs": "2015-05-01", + "ComponentLinkedStorageAccountApi": "2020-03-01-preview", + "Components": "2020-02-02", + "DeletedWorkbookApi": "2024-02-01-preview", + "Favorites": "2015-05-01", + "LiveTokenApi": "2021-10-14", + "WebTestLocation": "2015-05-01", + "WebTestsApi": "2022-06-15", + "WorkBookOperations": "2021-03-08", + "WorkbooksApi": "2023-06-01", + "WorkbookTemplatesApi": "2020-11-20" + }, + "emitterVersion": "0.14.0" +} diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/time_rfc3339.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/time_rfc3339.go deleted file mode 100644 index 1fa213792892..000000000000 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/time_rfc3339.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armapplicationinsights - -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 ( - utcDateTime = "2006-01-02T15:04:05.999999999" - utcDateTimeJSON = `"` + utcDateTime + `"` - utcDateTimeNoT = "2006-01-02 15:04:05.999999999" - utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` - dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` - dateTimeJSON = `"` + time.RFC3339Nano + `"` - dateTimeJSONNoT = `"` + dateTimeNoT + `"` -) - -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 { - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = dateTimeJSON - } else if tzOffset { - layout = dateTimeJSONNoT - } else if hasT { - layout = utcDateTimeJSON - } else { - layout = utcDateTimeJSONNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - if len(data) == 0 { - return nil - } - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = time.RFC3339Nano - } else if tzOffset { - layout = dateTimeNoT - } else if hasT { - layout = utcDateTime - } else { - layout = utcDateTimeNoT - } - 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 (t dateTimeRFC3339) String() string { - return time.Time(t).Format(time.RFC3339Nano) -} - -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 || 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/applicationinsights/armapplicationinsights/tsp-location.yaml b/sdk/resourcemanager/applicationinsights/armapplicationinsights/tsp-location.yaml new file mode 100644 index 000000000000..5e4608b21c30 --- /dev/null +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/applicationinsights/resource-manager/Microsoft.Insights/ApplicationInsights +commit: b26c3c253cff26dd05361e882dbcf1b324f27dfd +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/version.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/version.go new file mode 100644 index 000000000000..708258fc932e --- /dev/null +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/version.go @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. + +package armapplicationinsights + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights" + moduleVersion = "v2.0.0" +) diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtestlocations_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtestlocations_client.go index 5773dcb87321..7988928fe2bf 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtestlocations_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtestlocations_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // WebTestLocationsClient contains the methods for the WebTestLocations group. // Don't use this type directly, use NewWebTestLocationsClient() instead. +// +// Generated from API version 2015-05-01 type WebTestLocationsClient struct { internal *arm.Client subscriptionID string } // NewWebTestLocationsClient creates a new instance of WebTestLocationsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewWebTestLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WebTestLocationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -41,8 +42,6 @@ func NewWebTestLocationsClient(subscriptionID string, credential azcore.TokenCre } // NewListPager - Gets a list of web test locations available to this Application Insights component. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - WebTestLocationsClientListOptions contains the optional parameters for the WebTestLocationsClient.NewListPager @@ -50,21 +49,20 @@ func NewWebTestLocationsClient(subscriptionID string, credential azcore.TokenCre func (client *WebTestLocationsClient) NewListPager(resourceGroupName string, resourceName string, options *WebTestLocationsClientListOptions) *runtime.Pager[WebTestLocationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[WebTestLocationsClientListResponse]{ More: func(page WebTestLocationsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WebTestLocationsClientListResponse) (WebTestLocationsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WebTestLocationsClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, options) - if err != nil { - return WebTestLocationsClientListResponse{}, err + 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.listCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) if err != nil { return WebTestLocationsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WebTestLocationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -74,14 +72,14 @@ func (client *WebTestLocationsClient) NewListPager(resourceGroupName string, res // listCreateRequest creates the List request. func (client *WebTestLocationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *WebTestLocationsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/syntheticmonitorlocations" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -91,8 +89,8 @@ func (client *WebTestLocationsClient) listCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtestlocations_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtestlocations_client_example_test.go index 5e78f0b629a1..5d1c98e69a9e 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtestlocations_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtestlocations_client_example_test.go @@ -1,27 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/WebTestLocationsList.json +// Generated from example definition: 2015-05-01/WebTestLocationsList.json func ExampleWebTestLocationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -36,7 +33,75 @@ func ExampleWebTestLocationsClient_NewListPager() { _ = 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.WebTestLocationsListResult = armapplicationinsights.WebTestLocationsListResult{ + // page = armapplicationinsights.WebTestLocationsClientListResponse{ + // WebTestLocationsListResult: armapplicationinsights.WebTestLocationsListResult{ + // Value: []*armapplicationinsights.ComponentWebTestLocation{ + // { + // DisplayName: to.Ptr("US : IL-Chicago"), + // Tag: to.Ptr("us-il-ch1-azr"), + // }, + // { + // DisplayName: to.Ptr("NL : Amsterdam"), + // Tag: to.Ptr("emea-nl-ams-azr"), + // }, + // { + // DisplayName: to.Ptr("SG : Singapore"), + // Tag: to.Ptr("apac-sg-sin-azr"), + // }, + // { + // DisplayName: to.Ptr("US : CA-San Jose"), + // Tag: to.Ptr("us-ca-sjc-azr"), + // }, + // { + // DisplayName: to.Ptr("US : TX-San Antonio"), + // Tag: to.Ptr("us-tx-sn1-azr"), + // }, + // { + // DisplayName: to.Ptr("US : VA-Ashburn"), + // Tag: to.Ptr("us-va-ash-azr"), + // }, + // { + // DisplayName: to.Ptr("HK : Hong Kong Special Administrative Region"), + // Tag: to.Ptr("apac-hk-hkn-azr"), + // }, + // { + // DisplayName: to.Ptr("IE : Dublin"), + // Tag: to.Ptr("emea-gb-db3-azr"), + // }, + // { + // DisplayName: to.Ptr("JP : Kawaguchi"), + // Tag: to.Ptr("apac-jp-kaw-edge"), + // }, + // { + // DisplayName: to.Ptr("AU : Sydney"), + // Tag: to.Ptr("emea-au-syd-edge"), + // }, + // { + // DisplayName: to.Ptr("CH : Zurich"), + // Tag: to.Ptr("emea-ch-zrh-edge"), + // }, + // { + // DisplayName: to.Ptr("FR : Paris"), + // Tag: to.Ptr("emea-fr-pra-edge"), + // }, + // { + // DisplayName: to.Ptr("RU : Moscow"), + // Tag: to.Ptr("emea-ru-msa-edge"), + // }, + // { + // DisplayName: to.Ptr("SE : Stockholm"), + // Tag: to.Ptr("emea-se-sto-edge"), + // }, + // { + // DisplayName: to.Ptr("BR : Sao Paulo"), + // Tag: to.Ptr("latam-br-gru-edge"), + // }, + // { + // DisplayName: to.Ptr("US : FL-Miami"), + // Tag: to.Ptr("us-fl-mia-edge"), + // }, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtests_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtests_client.go index 971758d8c801..c75cf9470e53 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtests_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtests_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // WebTestsClient contains the methods for the WebTests group. // Don't use this type directly, use NewWebTestsClient() instead. +// +// Generated from API version 2022-06-15 type WebTestsClient struct { internal *arm.Client subscriptionID string } // NewWebTestsClient creates a new instance of WebTestsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewWebTestsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WebTestsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewWebTestsClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Creates or updates an Application Insights web test definition. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-06-15 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - webTestName - The name of the Application Insights WebTest resource. // - webTestDefinition - Properties that need to be specified to create or update an Application Insights web test definition. @@ -73,14 +72,14 @@ func (client *WebTestsClient) CreateOrUpdate(ctx context.Context, resourceGroupN // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *WebTestsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, webTestName string, webTestDefinition WebTest, _ *WebTestsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 webTestName == "" { return nil, errors.New("parameter webTestName cannot be empty") } @@ -90,9 +89,10 @@ func (client *WebTestsClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-15") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20220615) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, webTestDefinition); err != nil { return nil, err } @@ -110,8 +110,6 @@ func (client *WebTestsClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes an Application Insights web test. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-06-15 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - webTestName - The name of the Application Insights WebTest resource. // - options - WebTestsClientDeleteOptions contains the optional parameters for the WebTestsClient.Delete method. @@ -156,15 +154,13 @@ func (client *WebTestsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-15") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20220615) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // Get - Get a specific Application Insights web test definition. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-06-15 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - webTestName - The name of the Application Insights WebTest resource. // - options - WebTestsClientGetOptions contains the optional parameters for the WebTestsClient.Get method. @@ -193,14 +189,14 @@ func (client *WebTestsClient) Get(ctx context.Context, resourceGroupName string, // getCreateRequest creates the Get request. func (client *WebTestsClient) getCreateRequest(ctx context.Context, resourceGroupName string, webTestName string, _ *WebTestsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 webTestName == "" { return nil, errors.New("parameter webTestName cannot be empty") } @@ -210,8 +206,8 @@ func (client *WebTestsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-15") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20220615) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -226,8 +222,6 @@ func (client *WebTestsClient) getHandleResponse(resp *http.Response) (WebTestsCl } // NewListPager - Get all Application Insights web test definitions for the specified subscription. -// -// Generated from API version 2022-06-15 // - options - WebTestsClientListOptions contains the optional parameters for the WebTestsClient.NewListPager method. func (client *WebTestsClient) NewListPager(options *WebTestsClientListOptions) *runtime.Pager[WebTestsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[WebTestsClientListResponse]{ @@ -264,8 +258,8 @@ func (client *WebTestsClient) listCreateRequest(ctx context.Context, _ *WebTests return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-15") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20220615) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -280,8 +274,6 @@ func (client *WebTestsClient) listHandleResponse(resp *http.Response) (WebTestsC } // NewListByComponentPager - Get all Application Insights web tests defined for the specified component. -// -// Generated from API version 2022-06-15 // - componentName - The name of the Application Insights component resource. // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - WebTestsClientListByComponentOptions contains the optional parameters for the WebTestsClient.NewListByComponentPager @@ -312,6 +304,10 @@ func (client *WebTestsClient) NewListByComponentPager(componentName string, reso // listByComponentCreateRequest creates the ListByComponent request. func (client *WebTestsClient) listByComponentCreateRequest(ctx context.Context, componentName string, resourceGroupName string, _ *WebTestsClientListByComponentOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if componentName == "" { return nil, errors.New("parameter componentName cannot be empty") } @@ -320,17 +316,13 @@ func (client *WebTestsClient) listByComponentCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - 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.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-15") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20220615) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -345,8 +337,6 @@ func (client *WebTestsClient) listByComponentHandleResponse(resp *http.Response) } // NewListByResourceGroupPager - Get all Application Insights web tests defined for the specified resource group. -// -// Generated from API version 2022-06-15 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - WebTestsClientListByResourceGroupOptions contains the optional parameters for the WebTestsClient.NewListByResourceGroupPager // method. @@ -376,21 +366,21 @@ func (client *WebTestsClient) NewListByResourceGroupPager(resourceGroupName stri // listByResourceGroupCreateRequest creates the ListByResourceGroup request. func (client *WebTestsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *WebTestsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-15") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20220615) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -406,8 +396,6 @@ func (client *WebTestsClient) listByResourceGroupHandleResponse(resp *http.Respo // UpdateTags - Updates the tags associated with an Application Insights web test. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-06-15 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - webTestName - The name of the Application Insights WebTest resource. // - webTestTags - Updated tag information to associate with the web test resource. @@ -437,14 +425,14 @@ func (client *WebTestsClient) UpdateTags(ctx context.Context, resourceGroupName // updateTagsCreateRequest creates the UpdateTags request. func (client *WebTestsClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, webTestName string, webTestTags TagsResource, _ *WebTestsClientUpdateTagsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 webTestName == "" { return nil, errors.New("parameter webTestName cannot be empty") } @@ -454,9 +442,10 @@ func (client *WebTestsClient) updateTagsCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-15") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20220615) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, webTestTags); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtests_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtests_client_example_test.go index 9109127fcdc7..5b5a08afab51 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtests_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/webtests_client_example_test.go @@ -1,170 +1,31 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestListByResourceGroup.json -func ExampleWebTestsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewWebTestsClient().NewListByResourceGroupPager("my-resource-group", 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.WebTestListResult = armapplicationinsights.WebTestListResult{ - // Value: []*armapplicationinsights.WebTest{ - // { - // Name: to.Ptr("my-webtest-my-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), - // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), - // }, - // Description: to.Ptr(""), - // Enabled: to.Ptr(false), - // Frequency: to.Ptr[int32](900), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ - // { - // Location: to.Ptr("apac-hk-hkn-azr"), - // }}, - // WebTestName: to.Ptr("my-webtest"), - // RetryEnabled: to.Ptr(true), - // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), - // Timeout: to.Ptr[int32](120), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // }, - // { - // Name: to.Ptr("my-webtest-my-other-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-other-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "Test": to.Ptr("You can delete this synthetic monitor anytime"), - // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-other-component": to.Ptr("Resource"), - // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), - // }, - // Description: to.Ptr(""), - // Enabled: to.Ptr(false), - // Frequency: to.Ptr[int32](300), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ - // { - // Location: to.Ptr("us-fl-mia-edge"), - // }}, - // WebTestName: to.Ptr("342bccf4-722f-496d-b064-123456789abc"), - // RetryEnabled: to.Ptr(false), - // SyntheticMonitorID: to.Ptr("my-webtest-my-other-component"), - // Timeout: to.Ptr[int32](90), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestGet.json -func ExampleWebTestsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewWebTestsClient().Get(ctx, "my-resource-group", "my-webtest-01-mywebservice", 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.WebTest = armapplicationinsights.WebTest{ - // Name: to.Ptr("my-webtest-01-mywebservice"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-test-resources/providers/Microsoft.Insights/webtests/my-webtest-01-mywebservice"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "hidden-link:/subscriptions/subid/resourceGroups/my-test-resources/providers/Microsoft.Insights/components/mytester": to.Ptr("Resource"), - // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), - // }, - // Description: to.Ptr(""), - // Enabled: to.Ptr(false), - // Frequency: to.Ptr[int32](900), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ - // { - // Location: to.Ptr("us-fl-mia-edge"), - // }, - // { - // Location: to.Ptr("apac-hk-hkn-azr"), - // }}, - // WebTestName: to.Ptr("mytest-webtest-01"), - // RetryEnabled: to.Ptr(true), - // SyntheticMonitorID: to.Ptr("my-webtest-01-mywebservice"), - // Timeout: to.Ptr[int32](30), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestCreate.json +// Generated from example definition: 2022-06-15/WebTestCreate.json func ExampleWebTestsClient_CreateOrUpdate_webTestCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewWebTestsClient().CreateOrUpdate(ctx, "my-resource-group", "my-webtest-my-component", armapplicationinsights.WebTest{ - Location: to.Ptr("South Central US"), Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + Location: to.Ptr("South Central US"), Properties: &armapplicationinsights.WebTestProperties{ Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ WebTest: to.Ptr(""), @@ -176,7 +37,8 @@ func ExampleWebTestsClient_CreateOrUpdate_webTestCreate() { Locations: []*armapplicationinsights.WebTestGeolocation{ { Location: to.Ptr("us-fl-mia-edge"), - }}, + }, + }, WebTestName: to.Ptr("my-webtest-my-component"), RetryEnabled: to.Ptr(true), SyntheticMonitorID: to.Ptr("my-webtest-my-component"), @@ -189,44 +51,47 @@ func ExampleWebTestsClient_CreateOrUpdate_webTestCreate() { // 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.WebTest = armapplicationinsights.WebTest{ - // Name: to.Ptr("my-webtest-my-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), - // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), + // res = armapplicationinsights.WebTestsClientCreateOrUpdateResponse{ + // WebTest: armapplicationinsights.WebTest{ + // Name: to.Ptr("my-webtest-my-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr("Ping web test alert for mytestwebapp"), + // Enabled: to.Ptr(true), + // Frequency: to.Ptr[int32](900), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // { + // Location: to.Ptr("us-fl-mia-edge"), + // }, + // }, + // WebTestName: to.Ptr("my-webtest-my-component"), + // RetryEnabled: to.Ptr(true), + // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), + // Timeout: to.Ptr[int32](120), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // Tags: map[string]*string{ + // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), // }, - // Description: to.Ptr("Ping web test alert for mytestwebapp"), - // Enabled: to.Ptr(true), - // Frequency: to.Ptr[int32](900), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ - // { - // Location: to.Ptr("us-fl-mia-edge"), - // }}, - // WebTestName: to.Ptr("my-webtest-my-component"), - // RetryEnabled: to.Ptr(true), - // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), - // Timeout: to.Ptr[int32](120), - // ProvisioningState: to.Ptr("Succeeded"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestCreateStandard.json +// Generated from example definition: 2022-06-15/WebTestCreateStandard.json func ExampleWebTestsClient_CreateOrUpdate_webTestCreateStandard() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -240,7 +105,8 @@ func ExampleWebTestsClient_CreateOrUpdate_webTestCreateStandard() { Locations: []*armapplicationinsights.WebTestGeolocation{ { Location: to.Ptr("us-fl-mia-edge"), - }}, + }, + }, WebTestName: to.Ptr("my-webtest-my-component"), Request: &armapplicationinsights.WebTestPropertiesRequest{ Headers: []*armapplicationinsights.HeaderField{ @@ -251,7 +117,8 @@ func ExampleWebTestsClient_CreateOrUpdate_webTestCreateStandard() { { HeaderFieldName: to.Ptr("Accept-Language"), HeaderFieldValue: to.Ptr("de-DE"), - }}, + }, + }, HTTPVerb: to.Ptr("POST"), RequestBody: to.Ptr("SGVsbG8gd29ybGQ="), RequestURL: to.Ptr("https://bing.com"), @@ -271,64 +138,68 @@ func ExampleWebTestsClient_CreateOrUpdate_webTestCreateStandard() { // 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.WebTest = armapplicationinsights.WebTest{ - // Name: to.Ptr("my-webtest-my-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), - // }, - // Properties: &armapplicationinsights.WebTestProperties{ - // Description: to.Ptr("Ping web test alert for mytestwebapp"), - // Enabled: to.Ptr(true), - // Frequency: to.Ptr[int32](900), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindStandard), - // Locations: []*armapplicationinsights.WebTestGeolocation{ - // { - // Location: to.Ptr("us-fl-mia-edge"), - // }}, - // WebTestName: to.Ptr("my-webtest-my-component"), - // Request: &armapplicationinsights.WebTestPropertiesRequest{ - // Headers: []*armapplicationinsights.HeaderField{ + // res = armapplicationinsights.WebTestsClientCreateOrUpdateResponse{ + // WebTest: armapplicationinsights.WebTest{ + // Name: to.Ptr("my-webtest-my-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Description: to.Ptr("Ping web test alert for mytestwebapp"), + // Enabled: to.Ptr(true), + // Frequency: to.Ptr[int32](900), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindStandard), + // Locations: []*armapplicationinsights.WebTestGeolocation{ // { - // HeaderFieldName: to.Ptr("Content-Language"), - // HeaderFieldValue: to.Ptr("de-DE"), + // Location: to.Ptr("us-fl-mia-edge"), // }, - // { - // HeaderFieldName: to.Ptr("Accept-Language"), - // HeaderFieldValue: to.Ptr("de-DE"), - // }}, - // HTTPVerb: to.Ptr("POST"), - // RequestBody: to.Ptr("SGVsbG8gd29ybGQ="), - // RequestURL: to.Ptr("https://bing.com"), + // }, + // WebTestName: to.Ptr("my-webtest-my-component"), + // Request: &armapplicationinsights.WebTestPropertiesRequest{ + // Headers: []*armapplicationinsights.HeaderField{ + // { + // HeaderFieldName: to.Ptr("Content-Language"), + // HeaderFieldValue: to.Ptr("de-DE"), + // }, + // { + // HeaderFieldName: to.Ptr("Accept-Language"), + // HeaderFieldValue: to.Ptr("de-DE"), + // }, + // }, + // HTTPVerb: to.Ptr("POST"), + // RequestBody: to.Ptr("SGVsbG8gd29ybGQ="), + // RequestURL: to.Ptr("https://bing.com"), + // }, + // RetryEnabled: to.Ptr(true), + // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), + // Timeout: to.Ptr[int32](120), + // ValidationRules: &armapplicationinsights.WebTestPropertiesValidationRules{ + // SSLCertRemainingLifetimeCheck: to.Ptr[int32](100), + // SSLCheck: to.Ptr(true), + // }, + // ProvisioningState: to.Ptr("Succeeded"), // }, - // RetryEnabled: to.Ptr(true), - // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), - // Timeout: to.Ptr[int32](120), - // ValidationRules: &armapplicationinsights.WebTestPropertiesValidationRules{ - // SSLCertRemainingLifetimeCheck: to.Ptr[int32](100), - // SSLCheck: to.Ptr(true), + // Tags: map[string]*string{ + // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), // }, - // ProvisioningState: to.Ptr("Succeeded"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestUpdate.json +// Generated from example definition: 2022-06-15/WebTestUpdate.json func ExampleWebTestsClient_CreateOrUpdate_webTestUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewWebTestsClient().CreateOrUpdate(ctx, "my-resource-group", "my-webtest-my-component", armapplicationinsights.WebTest{ - Location: to.Ptr("South Central US"), Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + Location: to.Ptr("South Central US"), Properties: &armapplicationinsights.WebTestProperties{ Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ WebTest: to.Ptr(""), @@ -341,7 +212,8 @@ func ExampleWebTestsClient_CreateOrUpdate_webTestUpdate() { }, { Location: to.Ptr("apac-hk-hkn-azr"), - }}, + }, + }, WebTestName: to.Ptr("my-webtest-my-component"), SyntheticMonitorID: to.Ptr("my-webtest-my-component"), Timeout: to.Ptr[int32](30), @@ -353,125 +225,126 @@ func ExampleWebTestsClient_CreateOrUpdate_webTestUpdate() { // 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.WebTest = armapplicationinsights.WebTest{ - // Name: to.Ptr("my-webtest-my-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), - // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), - // }, - // Description: to.Ptr("Ping web test alert for mytestwebapp"), - // Enabled: to.Ptr(true), - // Frequency: to.Ptr[int32](600), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ - // { - // Location: to.Ptr("us-fl-mia-edge"), + // res = armapplicationinsights.WebTestsClientCreateOrUpdateResponse{ + // WebTest: armapplicationinsights.WebTest{ + // Name: to.Ptr("my-webtest-my-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr("Ping web test alert for mytestwebapp"), + // Enabled: to.Ptr(true), + // Frequency: to.Ptr[int32](600), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // { + // Location: to.Ptr("us-fl-mia-edge"), + // }, + // { + // Location: to.Ptr("apac-hk-hkn-azr"), + // }, // }, - // { - // Location: to.Ptr("apac-hk-hkn-azr"), - // }}, - // WebTestName: to.Ptr("my-webtest-my-component"), - // RetryEnabled: to.Ptr(true), - // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), - // Timeout: to.Ptr[int32](30), - // ProvisioningState: to.Ptr("Succeeded"), + // WebTestName: to.Ptr("my-webtest-my-component"), + // RetryEnabled: to.Ptr(true), + // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), + // Timeout: to.Ptr[int32](30), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // Tags: map[string]*string{ + // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestUpdateTagsOnly.json -func ExampleWebTestsClient_UpdateTags() { +// Generated from example definition: 2022-06-15/WebTestDelete.json +func ExampleWebTestsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWebTestsClient().UpdateTags(ctx, "my-resource-group", "my-webtest-my-component", armapplicationinsights.TagsResource{ - Tags: map[string]*string{ - "Color": to.Ptr("AzureBlue"), - "CustomField-01": to.Ptr("This is a random value"), - "SystemType": to.Ptr("A08"), - "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), - }, - }, nil) + res, err := clientFactory.NewWebTestsClient().Delete(ctx, "my-resource-group", "my-webtest-01-mywebservice", 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.WebTest = armapplicationinsights.WebTest{ - // Name: to.Ptr("my-webtest-my-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "Color": to.Ptr("AzureBlue"), - // "CustomField-01": to.Ptr("This is a random value"), - // "SystemType": to.Ptr("A08"), - // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), - // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), - // }, - // Description: to.Ptr("Ping web test alert for mytestwebapp"), - // Enabled: to.Ptr(true), - // Frequency: to.Ptr[int32](600), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ - // { - // Location: to.Ptr("us-fl-mia-edge"), - // }, - // { - // Location: to.Ptr("apac-hk-hkn-azr"), - // }}, - // WebTestName: to.Ptr("my-webtest-my-component"), - // RetryEnabled: to.Ptr(true), - // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), - // Timeout: to.Ptr[int32](30), - // ProvisioningState: to.Ptr("Succeeded"), - // }, + // res = armapplicationinsights.WebTestsClientDeleteResponse{ // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestDelete.json -func ExampleWebTestsClient_Delete() { +// Generated from example definition: 2022-06-15/WebTestGet.json +func ExampleWebTestsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewWebTestsClient().Delete(ctx, "my-resource-group", "my-webtest-01-mywebservice", nil) + res, err := clientFactory.NewWebTestsClient().Get(ctx, "my-resource-group", "my-webtest-01-mywebservice", 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 = armapplicationinsights.WebTestsClientGetResponse{ + // WebTest: armapplicationinsights.WebTest{ + // Name: to.Ptr("my-webtest-01-mywebservice"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-test-resources/providers/Microsoft.Insights/webtests/my-webtest-01-mywebservice"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr(""), + // Enabled: to.Ptr(false), + // Frequency: to.Ptr[int32](900), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // { + // Location: to.Ptr("us-fl-mia-edge"), + // }, + // { + // Location: to.Ptr("apac-hk-hkn-azr"), + // }, + // }, + // WebTestName: to.Ptr("mytest-webtest-01"), + // RetryEnabled: to.Ptr(true), + // SyntheticMonitorID: to.Ptr("my-webtest-01-mywebservice"), + // Timeout: to.Ptr[int32](30), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // Tags: map[string]*string{ + // "hidden-link:/subscriptions/subid/resourceGroups/my-test-resources/providers/Microsoft.Insights/components/mytester": to.Ptr("Resource"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestList.json +// Generated from example definition: 2022-06-15/WebTestList.json func ExampleWebTestsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -486,73 +359,76 @@ func ExampleWebTestsClient_NewListPager() { _ = 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.WebTestListResult = armapplicationinsights.WebTestListResult{ - // Value: []*armapplicationinsights.WebTest{ - // { - // Name: to.Ptr("my-webtest-my-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), - // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), + // page = armapplicationinsights.WebTestsClientListResponse{ + // WebTestListResult: armapplicationinsights.WebTestListResult{ + // Value: []*armapplicationinsights.WebTest{ + // { + // Name: to.Ptr("my-webtest-my-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr(""), + // Enabled: to.Ptr(false), + // Frequency: to.Ptr[int32](900), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // }, + // WebTestName: to.Ptr("my-webtest"), + // RetryEnabled: to.Ptr(true), + // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), + // Timeout: to.Ptr[int32](120), + // ProvisioningState: to.Ptr("Succeeded"), // }, - // Description: to.Ptr(""), - // Enabled: to.Ptr(false), - // Frequency: to.Ptr[int32](900), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ + // Tags: map[string]*string{ + // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), // }, - // WebTestName: to.Ptr("my-webtest"), - // RetryEnabled: to.Ptr(true), - // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), - // Timeout: to.Ptr[int32](120), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // }, - // { - // Name: to.Ptr("my-webtest-my-other-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-other-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-other-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "Test": to.Ptr("You can delete this synthetic monitor anytime"), - // "hidden-link:/subscriptions/subid/resourceGroups/my-other-resource-group/providers/Microsoft.Insights/components/my-other-component": to.Ptr("Resource"), // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), + // { + // Name: to.Ptr("my-webtest-my-other-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-other-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-other-component"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr(""), + // Enabled: to.Ptr(false), + // Frequency: to.Ptr[int32](900), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // }, + // WebTestName: to.Ptr("342bccf4-722f-496d-b064-123456789abc"), + // RetryEnabled: to.Ptr(false), + // SyntheticMonitorID: to.Ptr("my-webtest-my-other-component"), + // Timeout: to.Ptr[int32](120), + // ProvisioningState: to.Ptr("Succeeded"), // }, - // Description: to.Ptr(""), - // Enabled: to.Ptr(false), - // Frequency: to.Ptr[int32](900), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ + // Tags: map[string]*string{ + // "Test": to.Ptr("You can delete this synthetic monitor anytime"), + // "hidden-link:/subscriptions/subid/resourceGroups/my-other-resource-group/providers/Microsoft.Insights/components/my-other-component": to.Ptr("Resource"), // }, - // WebTestName: to.Ptr("342bccf4-722f-496d-b064-123456789abc"), - // RetryEnabled: to.Ptr(false), - // SyntheticMonitorID: to.Ptr("my-webtest-my-other-component"), - // Timeout: to.Ptr[int32](120), - // ProvisioningState: to.Ptr("Succeeded"), // }, - // }}, + // }, + // }, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestListByComponent.json +// Generated from example definition: 2022-06-15/WebTestListByComponent.json func ExampleWebTestsClient_NewListByComponentPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -567,36 +443,194 @@ func ExampleWebTestsClient_NewListByComponentPager() { _ = 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.WebTestListResult = armapplicationinsights.WebTestListResult{ - // Value: []*armapplicationinsights.WebTest{ - // { - // Name: to.Ptr("my-webtest-my-component"), - // Type: to.Ptr("Microsoft.Insights/webtests"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), - // Location: to.Ptr("southcentralus"), - // Tags: map[string]*string{ - // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), + // page = armapplicationinsights.WebTestsClientListByComponentResponse{ + // WebTestListResult: armapplicationinsights.WebTestListResult{ + // Value: []*armapplicationinsights.WebTest{ + // { + // Name: to.Ptr("my-webtest-my-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr(""), + // Enabled: to.Ptr(false), + // Frequency: to.Ptr[int32](900), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // { + // Location: to.Ptr("apac-hk-hkn-azr"), + // }, + // }, + // WebTestName: to.Ptr("my-webtest"), + // RetryEnabled: to.Ptr(true), + // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), + // Timeout: to.Ptr[int32](120), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // Tags: map[string]*string{ + // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), + // }, // }, - // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Properties: &armapplicationinsights.WebTestProperties{ - // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ - // WebTest: to.Ptr(""), + // }, + // }, + // } + } +} + +// Generated from example definition: 2022-06-15/WebTestListByResourceGroup.json +func ExampleWebTestsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWebTestsClient().NewListByResourceGroupPager("my-resource-group", 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 = armapplicationinsights.WebTestsClientListByResourceGroupResponse{ + // WebTestListResult: armapplicationinsights.WebTestListResult{ + // Value: []*armapplicationinsights.WebTest{ + // { + // Name: to.Ptr("my-webtest-my-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr(""), + // Enabled: to.Ptr(false), + // Frequency: to.Ptr[int32](900), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // { + // Location: to.Ptr("apac-hk-hkn-azr"), + // }, + // }, + // WebTestName: to.Ptr("my-webtest"), + // RetryEnabled: to.Ptr(true), + // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), + // Timeout: to.Ptr[int32](120), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // Tags: map[string]*string{ + // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), + // }, + // }, + // { + // Name: to.Ptr("my-webtest-my-other-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-other-component"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr(""), + // Enabled: to.Ptr(false), + // Frequency: to.Ptr[int32](300), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // { + // Location: to.Ptr("us-fl-mia-edge"), + // }, + // }, + // WebTestName: to.Ptr("342bccf4-722f-496d-b064-123456789abc"), + // RetryEnabled: to.Ptr(false), + // SyntheticMonitorID: to.Ptr("my-webtest-my-other-component"), + // Timeout: to.Ptr[int32](90), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // Tags: map[string]*string{ + // "Test": to.Ptr("You can delete this synthetic monitor anytime"), + // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-other-component": to.Ptr("Resource"), // }, - // Description: to.Ptr(""), - // Enabled: to.Ptr(false), - // Frequency: to.Ptr[int32](900), - // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), - // Locations: []*armapplicationinsights.WebTestGeolocation{ - // { - // Location: to.Ptr("apac-hk-hkn-azr"), - // }}, - // WebTestName: to.Ptr("my-webtest"), - // RetryEnabled: to.Ptr(true), - // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), - // Timeout: to.Ptr[int32](120), - // ProvisioningState: to.Ptr("Succeeded"), // }, - // }}, + // }, + // }, // } } } + +// Generated from example definition: 2022-06-15/WebTestUpdateTagsOnly.json +func ExampleWebTestsClient_UpdateTags() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWebTestsClient().UpdateTags(ctx, "my-resource-group", "my-webtest-my-component", armapplicationinsights.TagsResource{ + Tags: map[string]*string{ + "Color": to.Ptr("AzureBlue"), + "CustomField-01": to.Ptr("This is a random value"), + "SystemType": to.Ptr("A08"), + "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), + }, + }, 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 = armapplicationinsights.WebTestsClientUpdateTagsResponse{ + // WebTest: armapplicationinsights.WebTest{ + // Name: to.Ptr("my-webtest-my-component"), + // Type: to.Ptr("Microsoft.Insights/webtests"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/webtests/my-webtest-my-component"), + // Kind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Location: to.Ptr("southcentralus"), + // Properties: &armapplicationinsights.WebTestProperties{ + // Configuration: &armapplicationinsights.WebTestPropertiesConfiguration{ + // WebTest: to.Ptr(""), + // }, + // Description: to.Ptr("Ping web test alert for mytestwebapp"), + // Enabled: to.Ptr(true), + // Frequency: to.Ptr[int32](600), + // WebTestKind: to.Ptr(armapplicationinsights.WebTestKindPing), + // Locations: []*armapplicationinsights.WebTestGeolocation{ + // { + // Location: to.Ptr("us-fl-mia-edge"), + // }, + // { + // Location: to.Ptr("apac-hk-hkn-azr"), + // }, + // }, + // WebTestName: to.Ptr("my-webtest-my-component"), + // RetryEnabled: to.Ptr(true), + // SyntheticMonitorID: to.Ptr("my-webtest-my-component"), + // Timeout: to.Ptr[int32](30), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // Tags: map[string]*string{ + // "Color": to.Ptr("AzureBlue"), + // "CustomField-01": to.Ptr("This is a random value"), + // "SystemType": to.Ptr("A08"), + // "hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component": to.Ptr("Resource"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooks_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooks_client.go index 211bd69c2534..c864668a6456 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooks_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooks_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -20,15 +19,17 @@ import ( // WorkbooksClient contains the methods for the Workbooks group. // Don't use this type directly, use NewWorkbooksClient() instead. +// +// Generated from API version 2023-06-01 type WorkbooksClient struct { internal *arm.Client subscriptionID string } // NewWorkbooksClient creates a new instance of WorkbooksClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewWorkbooksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkbooksClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -43,8 +44,6 @@ func NewWorkbooksClient(subscriptionID string, credential azcore.TokenCredential // CreateOrUpdate - Create a new workbook. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the workbook resource. The value must be an UUID. // - workbookProperties - Properties that need to be specified to create a new workbook. @@ -92,12 +91,13 @@ func (client *WorkbooksClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-06-01") + reqQP.Set("api-version", version20230601) if options != nil && options.SourceID != nil { reqQP.Set("sourceId", *options.SourceID) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, workbookProperties); err != nil { return nil, err } @@ -115,8 +115,6 @@ func (client *WorkbooksClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Delete a workbook. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the workbook resource. The value must be an UUID. // - options - WorkbooksClientDeleteOptions contains the optional parameters for the WorkbooksClient.Delete method. @@ -161,16 +159,13 @@ func (client *WorkbooksClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-06-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} + reqQP.Set("api-version", version20230601) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // Get - Get a single workbook by its resourceName. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the workbook resource. The value must be an UUID. // - options - WorkbooksClientGetOptions contains the optional parameters for the WorkbooksClient.Get method. @@ -216,11 +211,11 @@ func (client *WorkbooksClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-06-01") + reqQP.Set("api-version", version20230601) if options != nil && options.CanFetchContent != nil { reqQP.Set("canFetchContent", strconv.FormatBool(*options.CanFetchContent)) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -235,8 +230,6 @@ func (client *WorkbooksClient) getHandleResponse(resp *http.Response) (Workbooks } // NewListByResourceGroupPager - Get all Workbooks defined within a specified resource group and category. -// -// Generated from API version 2023-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - category - Category of workbook to return. // - options - WorkbooksClientListByResourceGroupOptions contains the optional parameters for the WorkbooksClient.NewListByResourceGroupPager @@ -280,7 +273,7 @@ func (client *WorkbooksClient) listByResourceGroupCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-06-01") + reqQP.Set("api-version", version20230601) if options != nil && options.CanFetchContent != nil { reqQP.Set("canFetchContent", strconv.FormatBool(*options.CanFetchContent)) } @@ -291,7 +284,7 @@ func (client *WorkbooksClient) listByResourceGroupCreateRequest(ctx context.Cont if options != nil && options.Tags != nil { reqQP.Set("tags", strings.Join(options.Tags, ",")) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -306,8 +299,6 @@ func (client *WorkbooksClient) listByResourceGroupHandleResponse(resp *http.Resp } // NewListBySubscriptionPager - Get all Workbooks defined within a specified subscription and category. -// -// Generated from API version 2023-06-01 // - category - Category of workbook to return. // - options - WorkbooksClientListBySubscriptionOptions contains the optional parameters for the WorkbooksClient.NewListBySubscriptionPager // method. @@ -346,7 +337,7 @@ func (client *WorkbooksClient) listBySubscriptionCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-06-01") + reqQP.Set("api-version", version20230601) if options != nil && options.CanFetchContent != nil { reqQP.Set("canFetchContent", strconv.FormatBool(*options.CanFetchContent)) } @@ -354,7 +345,7 @@ func (client *WorkbooksClient) listBySubscriptionCreateRequest(ctx context.Conte if options != nil && options.Tags != nil { reqQP.Set("tags", strings.Join(options.Tags, ",")) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -370,8 +361,6 @@ func (client *WorkbooksClient) listBySubscriptionHandleResponse(resp *http.Respo // RevisionGet - Get a single workbook revision defined by its revisionId. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the workbook resource. The value must be an UUID. // - revisionID - The id of the workbook's revision. @@ -422,8 +411,8 @@ func (client *WorkbooksClient) revisionGetCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-06-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20230601) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -438,8 +427,6 @@ func (client *WorkbooksClient) revisionGetHandleResponse(resp *http.Response) (W } // NewRevisionsListPager - Get the revisions for the workbook defined by its resourceName. -// -// Generated from API version 2023-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the workbook resource. The value must be an UUID. // - options - WorkbooksClientRevisionsListOptions contains the optional parameters for the WorkbooksClient.NewRevisionsListPager @@ -487,8 +474,8 @@ func (client *WorkbooksClient) revisionsListCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-06-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20230601) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -504,18 +491,17 @@ func (client *WorkbooksClient) revisionsListHandleResponse(resp *http.Response) // Update - Updates a workbook that has already been added. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-06-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the workbook resource. The value must be an UUID. +// - workbookUpdateParameters - Properties that need to be specified to create a new workbook. // - options - WorkbooksClientUpdateOptions contains the optional parameters for the WorkbooksClient.Update method. -func (client *WorkbooksClient) Update(ctx context.Context, resourceGroupName string, resourceName string, options *WorkbooksClientUpdateOptions) (WorkbooksClientUpdateResponse, error) { +func (client *WorkbooksClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookUpdateParameters WorkbookUpdateParameters, options *WorkbooksClientUpdateOptions) (WorkbooksClientUpdateResponse, error) { var err error const operationName = "WorkbooksClient.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, resourceName, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, workbookUpdateParameters, options) if err != nil { return WorkbooksClientUpdateResponse{}, err } @@ -532,7 +518,7 @@ func (client *WorkbooksClient) Update(ctx context.Context, resourceGroupName str } // updateCreateRequest creates the Update request. -func (client *WorkbooksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *WorkbooksClientUpdateOptions) (*policy.Request, error) { +func (client *WorkbooksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, workbookUpdateParameters WorkbookUpdateParameters, options *WorkbooksClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -551,17 +537,15 @@ func (client *WorkbooksClient) updateCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-06-01") + reqQP.Set("api-version", version20230601) if options != nil && options.SourceID != nil { reqQP.Set("sourceId", *options.SourceID) } - req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.WorkbookUpdateParameters != nil { - if err := runtime.MarshalAsJSON(req, *options.WorkbookUpdateParameters); err != nil { - return nil, err - } - return req, nil + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, workbookUpdateParameters); err != nil { + return nil, err } return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooks_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooks_client_example_test.go index 7166631c2ba7..70659f7aea2a 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooks_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooks_client_example_test.go @@ -1,651 +1,621 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksList2.json -func ExampleWorkbooksClient_NewListBySubscriptionPager_workbooksList2() { +// Generated from example definition: 2023-06-01/WorkbookAdd.json +func ExampleWorkbooksClient_CreateOrUpdate_workbookAdd() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewWorkbooksClient().NewListBySubscriptionPager(armapplicationinsights.CategoryTypeWorkbook, &armapplicationinsights.WorkbooksClientListBySubscriptionOptions{Tags: []string{}, - CanFetchContent: 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.WorkbooksListResult = armapplicationinsights.WorkbooksListResult{ - // Value: []*armapplicationinsights.Workbook{ - // }, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksListSub.json -func ExampleWorkbooksClient_NewListBySubscriptionPager_workbooksListSub() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + res, err := clientFactory.NewWorkbooksClient().CreateOrUpdate(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", armapplicationinsights.Workbook{ + Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + Location: to.Ptr("westus"), + Properties: &armapplicationinsights.WorkbookProperties{ + Description: to.Ptr("Sample workbook"), + Category: to.Ptr("workbook"), + DisplayName: to.Ptr("Sample workbook"), + SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + }, + Tags: map[string]*string{ + "TagSample01": to.Ptr("sample01"), + "TagSample02": to.Ptr("sample02"), + }, + }, &armapplicationinsights.WorkbooksClientCreateOrUpdateOptions{ + SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group")}) if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewWorkbooksClient().NewListBySubscriptionPager(armapplicationinsights.CategoryTypeWorkbook, &armapplicationinsights.WorkbooksClientListBySubscriptionOptions{Tags: []string{}, - CanFetchContent: 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.WorkbooksListResult = armapplicationinsights.WorkbooksListResult{ - // Value: []*armapplicationinsights.Workbook{ - // { - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My Workbook 1"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.422Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // }, - // { - // Name: to.Ptr("c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My Workbook 2"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bc"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.422Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // }}, - // } + 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 = armapplicationinsights.WorkbooksClientCreateOrUpdateResponse{ + // Workbook: armapplicationinsights.Workbook{ + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/microsoft.insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("Sample workbook"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-24T06:56:31.6301521Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksList.json -func ExampleWorkbooksClient_NewListByResourceGroupPager_workbooksList() { +// Generated from example definition: 2023-06-01/WorkbookManagedAdd.json +func ExampleWorkbooksClient_CreateOrUpdate_workbookManagedAdd() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewWorkbooksClient().NewListByResourceGroupPager("my-resource-group", armapplicationinsights.CategoryTypeWorkbook, &armapplicationinsights.WorkbooksClientListByResourceGroupOptions{Tags: []string{}, - SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - CanFetchContent: 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.WorkbooksListResult = armapplicationinsights.WorkbooksListResult{ - // Value: []*armapplicationinsights.Workbook{ - // { - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My Workbook 1"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-04T09:07:17.735Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // }, - // { - // Name: to.Ptr("c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My Workbook 2"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bc"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-04T09:07:17.735Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // }}, - // } + res, err := clientFactory.NewWorkbooksClient().CreateOrUpdate(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", armapplicationinsights.Workbook{ + Identity: &armapplicationinsights.WorkbookResourceIdentity{ + Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), + UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": {}, + }, + }, + Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + Location: to.Ptr("westus"), + Properties: &armapplicationinsights.WorkbookProperties{ + Description: to.Ptr("Sample workbook"), + Category: to.Ptr("workbook"), + DisplayName: to.Ptr("Sample workbook"), + SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"test\"},\"name\":\"text - 0\"}],\"isLocked\":false,\"fallbackResourceIds\":[\"/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/my-resource-group\"]}"), + StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), + Version: to.Ptr("Notebook/1.0"), + }, + }, &armapplicationinsights.WorkbooksClientCreateOrUpdateOptions{ + SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group")}) + 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 = armapplicationinsights.WorkbooksClientCreateOrUpdateResponse{ + // Workbook: armapplicationinsights.Workbook{ + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Identity: &armapplicationinsights.WorkbookResourceIdentity{ + // Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": &armapplicationinsights.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("Sample workbook"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[],\"isLocked\":false,\"fallbackResourceIds\":[\"/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/my-resource-group/providers/Microsoft.OperationalInsights/workspaces/test-ws\"]}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"), + // StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.4229554Z"); return t}()), + // UserID: to.Ptr("70d90f65-8a70-4e42-b8d5-86gv25e0a90f"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksManagedList.json -func ExampleWorkbooksClient_NewListByResourceGroupPager_workbooksManagedList() { +// Generated from example definition: 2023-06-01/WorkbookDelete.json +func ExampleWorkbooksClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewWorkbooksClient().NewListByResourceGroupPager("my-resource-group", armapplicationinsights.CategoryTypeWorkbook, &armapplicationinsights.WorkbooksClientListByResourceGroupOptions{Tags: []string{}, - SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - CanFetchContent: 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.WorkbooksListResult = armapplicationinsights.WorkbooksListResult{ - // Value: []*armapplicationinsights.Workbook{ - // { - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // }, - // Identity: &armapplicationinsights.WorkbookResourceIdentity{ - // Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": &armapplicationinsights.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My Workbook 1"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - // StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.422Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // }, - // { - // Name: to.Ptr("c0deea5e-3344-40f2-96f8-6f8e1cdd5722"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/c0deea5e-3344-40f2-96f8-6f8e1cdd5722"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My Workbook 2"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bc"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T21:00:26.422Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // }}, - // } + res, err := clientFactory.NewWorkbooksClient().Delete(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", 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 = armapplicationinsights.WorkbooksClientDeleteResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet.json +// Generated from example definition: 2023-06-01/WorkbookGet.json func ExampleWorkbooksClient_Get_workbookGet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbooksClient().Get(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", &armapplicationinsights.WorkbooksClientGetOptions{CanFetchContent: nil}) + res, err := clientFactory.NewWorkbooksClient().Get(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", 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.Workbook = armapplicationinsights.Workbook{ - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/microsoft.insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("Sample workbook"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-24T06:56:31.630Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), + // res = armapplicationinsights.WorkbooksClientGetResponse{ + // Workbook: armapplicationinsights.Workbook{ + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/microsoft.insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("Sample workbook"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-24T06:56:31.6301521Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet1.json +// Generated from example definition: 2023-06-01/WorkbookGet1.json func ExampleWorkbooksClient_Get_workbookGet1() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbooksClient().Get(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", &armapplicationinsights.WorkbooksClientGetOptions{CanFetchContent: nil}) + res, err := clientFactory.NewWorkbooksClient().Get(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", 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.Workbook = armapplicationinsights.Workbook{ - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/microsoft.insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("Sample workbook"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-24T06:56:31.630Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), + // res = armapplicationinsights.WorkbooksClientGetResponse{ + // Workbook: armapplicationinsights.Workbook{ + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/microsoft.insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("Sample workbook"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-24T06:56:31.6301521Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedGet.json +// Generated from example definition: 2023-06-01/WorkbookManagedGet.json func ExampleWorkbooksClient_Get_workbookManagedGet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbooksClient().Get(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", &armapplicationinsights.WorkbooksClientGetOptions{CanFetchContent: nil}) + res, err := clientFactory.NewWorkbooksClient().Get(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", 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.Workbook = armapplicationinsights.Workbook{ - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Identity: &armapplicationinsights.WorkbookResourceIdentity{ - // Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": &armapplicationinsights.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // res = armapplicationinsights.WorkbooksClientGetResponse{ + // Workbook: armapplicationinsights.Workbook{ + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Identity: &armapplicationinsights.WorkbookResourceIdentity{ + // Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": &armapplicationinsights.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, // }, // }, - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("azuremon"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"testing1\"},\"showPin\":false,\"name\":\"text - 0\"}],\"isLocked\":true,\"fallbackResourceIds\":[\"Azure Monitor\"]}"), - // SourceID: to.Ptr("azure monitor"), - // StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-04T09:07:17.735Z"); return t}()), - // UserID: to.Ptr("51d1409c-d725-4550-ac03-98c0bef9ef07"), - // Version: to.Ptr("Notebook/1.0"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("azuremon"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"testing1\"},\"showPin\":false,\"name\":\"text - 0\"}],\"isLocked\":true,\"fallbackResourceIds\":[\"Azure Monitor\"]}"), + // SourceID: to.Ptr("azure monitor"), + // StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-04T09:07:17.735638Z"); return t}()), + // UserID: to.Ptr("51d1409c-d725-4550-ac03-98c0bef9ef07"), + // Version: to.Ptr("Notebook/1.0"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookDelete.json -func ExampleWorkbooksClient_Delete() { +// Generated from example definition: 2023-06-01/WorkbooksList.json +func ExampleWorkbooksClient_NewListByResourceGroupPager_workbooksList() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewWorkbooksClient().Delete(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewWorkbooksClient().NewListByResourceGroupPager("my-resource-group", armapplicationinsights.CategoryTypeWorkbook, &armapplicationinsights.WorkbooksClientListByResourceGroupOptions{ + SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp")}) + 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 = armapplicationinsights.WorkbooksClientListByResourceGroupResponse{ + // WorkbooksListResult: armapplicationinsights.WorkbooksListResult{ + // Value: []*armapplicationinsights.Workbook{ + // { + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("My Workbook 1"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-04T09:07:17.735638Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // }, + // }, + // { + // Name: to.Ptr("c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("My Workbook 2"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bc"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-04T09:07:17.735638Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, + // }, + // }, + // }, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookAdd.json -func ExampleWorkbooksClient_CreateOrUpdate_workbookAdd() { +// Generated from example definition: 2023-06-01/WorkbooksManagedList.json +func ExampleWorkbooksClient_NewListByResourceGroupPager_workbooksManagedList() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac119r124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbooksClient().CreateOrUpdate(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", armapplicationinsights.Workbook{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "TagSample01": to.Ptr("sample01"), - "TagSample02": to.Ptr("sample02"), - }, - Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - Properties: &armapplicationinsights.WorkbookProperties{ - Description: to.Ptr("Sample workbook"), - Category: to.Ptr("workbook"), - DisplayName: to.Ptr("Sample workbook"), - SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - }, - }, &armapplicationinsights.WorkbooksClientCreateOrUpdateOptions{SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewWorkbooksClient().NewListByResourceGroupPager("my-resource-group", armapplicationinsights.CategoryTypeWorkbook, &armapplicationinsights.WorkbooksClientListByResourceGroupOptions{ + SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp")}) + 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 = armapplicationinsights.WorkbooksClientListByResourceGroupResponse{ + // WorkbooksListResult: armapplicationinsights.WorkbooksListResult{ + // Value: []*armapplicationinsights.Workbook{ + // { + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Identity: &armapplicationinsights.WorkbookResourceIdentity{ + // Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": &armapplicationinsights.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("My Workbook 1"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), + // StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.4229554Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // }, + // }, + // { + // Name: to.Ptr("c0deea5e-3344-40f2-96f8-6f8e1cdd5722"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/c0deea5e-3344-40f2-96f8-6f8e1cdd5722"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("My Workbook 2"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bc"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T21:00:26.4229555Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, + // }, + // }, + // }, + // } } - // 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.Workbook = armapplicationinsights.Workbook{ - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/microsoft.insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("Sample workbook"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-24T06:56:31.630Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedAdd.json -func ExampleWorkbooksClient_CreateOrUpdate_workbookManagedAdd() { +// Generated from example definition: 2023-06-01/WorkbooksList2.json +func ExampleWorkbooksClient_NewListBySubscriptionPager_workbooksList2() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbooksClient().CreateOrUpdate(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", armapplicationinsights.Workbook{ - Location: to.Ptr("westus"), - Identity: &armapplicationinsights.WorkbookResourceIdentity{ - Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": {}, - }, - }, - Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - Properties: &armapplicationinsights.WorkbookProperties{ - Description: to.Ptr("Sample workbook"), - Category: to.Ptr("workbook"), - DisplayName: to.Ptr("Sample workbook"), - SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"test\"},\"name\":\"text - 0\"}],\"isLocked\":false,\"fallbackResourceIds\":[\"/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/my-resource-group\"]}"), - StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), - Version: to.Ptr("Notebook/1.0"), - }, - }, &armapplicationinsights.WorkbooksClientCreateOrUpdateOptions{SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewWorkbooksClient().NewListBySubscriptionPager(armapplicationinsights.CategoryTypeWorkbook, 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 = armapplicationinsights.WorkbooksClientListBySubscriptionResponse{ + // WorkbooksListResult: armapplicationinsights.WorkbooksListResult{ + // Value: []*armapplicationinsights.Workbook{ + // }, + // }, + // } } - // 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.Workbook = armapplicationinsights.Workbook{ - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Identity: &armapplicationinsights.WorkbookResourceIdentity{ - // Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": &armapplicationinsights.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("Sample workbook"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[],\"isLocked\":false,\"fallbackResourceIds\":[\"/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/my-resource-group/providers/Microsoft.OperationalInsights/workspaces/test-ws\"]}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"), - // StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.422Z"); return t}()), - // UserID: to.Ptr("70d90f65-8a70-4e42-b8d5-86gv25e0a90f"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedUpdate.json -func ExampleWorkbooksClient_Update_workbookManagedUpdate() { +// Generated from example definition: 2023-06-01/WorkbooksListSub.json +func ExampleWorkbooksClient_NewListBySubscriptionPager_workbooksListSub() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbooksClient().Update(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", &armapplicationinsights.WorkbooksClientUpdateOptions{SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"), - WorkbookUpdateParameters: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewWorkbooksClient().NewListBySubscriptionPager(armapplicationinsights.CategoryTypeWorkbook, 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 = armapplicationinsights.WorkbooksClientListBySubscriptionResponse{ + // WorkbooksListResult: armapplicationinsights.WorkbooksListResult{ + // Value: []*armapplicationinsights.Workbook{ + // { + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("My Workbook 1"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.4229554Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // }, + // }, + // { + // Name: to.Ptr("c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/c0deea5e-3344-40f2-96f8-6f8e1c3b5722"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("My Workbook 2"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bc"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.4229554Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, + // }, + // }, + // }, + // } } - // 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.Workbook = armapplicationinsights.Workbook{ - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // "hidden-title": to.Ptr("Sample workbook"), - // }, - // Identity: &armapplicationinsights.WorkbookResourceIdentity{ - // Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": &armapplicationinsights.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("Sample workbook"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"test\"},\"name\":\"text - 0\"}],\"isLocked\":false,\"fallbackResourceIds\":[\"/subscriptions/8980832b-9589-4ac2-b322-a6ae6a97f02b/resourceGroups/my-resource-group\"]}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"), - // StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:15:08.187Z"); return t}()), - // UserID: to.Ptr("70d90f65-8a70-4e42-b8d5-863725e0a90f"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookUpdate.json -func ExampleWorkbooksClient_Update_workbookUpdate() { +// Generated from example definition: 2023-06-01/WorkbookRevisionGet.json +func ExampleWorkbooksClient_RevisionGet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbooksClient().Update(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", &armapplicationinsights.WorkbooksClientUpdateOptions{SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - WorkbookUpdateParameters: nil, - }) + res, err := clientFactory.NewWorkbooksClient().RevisionGet(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", "1e2f8435b98248febee70c64ac22e1ab", 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.Workbook = armapplicationinsights.Workbook{ - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("Sample workbook"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.422Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), + // res = armapplicationinsights.WorkbooksClientRevisionGetResponse{ + // Workbook: armapplicationinsights.Workbook{ + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("My New Workbook"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1ab"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-04T09:07:17.735638Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookRevisionsList.json +// Generated from example definition: 2023-06-01/WorkbookRevisionsList.json func ExampleWorkbooksClient_NewRevisionsListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -660,89 +630,157 @@ func ExampleWorkbooksClient_NewRevisionsListPager() { _ = 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.WorkbooksListResult = armapplicationinsights.WorkbooksListResult{ - // Value: []*armapplicationinsights.Workbook{ - // { - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ + // page = armapplicationinsights.WorkbooksClientRevisionsListResponse{ + // WorkbooksListResult: armapplicationinsights.WorkbooksListResult{ + // Value: []*armapplicationinsights.Workbook{ + // { + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Properties: &armapplicationinsights.WorkbookProperties{ + // DisplayName: to.Ptr("My Workbook 1"), + // UserID: to.Ptr("userId"), + // SourceID: to.Ptr("Azure Monitor"), + // SerializedData: nil, + // Version: to.Ptr("Notebook/1.0"), + // Category: to.Ptr("workbook"), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-04T09:07:17.735638Z"); return t}()), + // StorageURI: nil, + // Description: to.Ptr("Sample workbook"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1ab"), + // }, // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My Workbook 1"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1ab"), - // SourceID: to.Ptr("Azure Monitor"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-04T09:07:17.735Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), + // { + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Properties: &armapplicationinsights.WorkbookProperties{ + // DisplayName: to.Ptr("My Workbook 2"), + // UserID: to.Ptr("userId"), + // SourceID: to.Ptr("Azure Monitor"), + // SerializedData: nil, + // Version: to.Ptr("Notebook/1.0"), + // Category: to.Ptr("workbook"), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-04T09:07:17.735638Z"); return t}()), + // StorageURI: nil, + // Description: to.Ptr("Sample workbook"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // }, // }, // }, - // { - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), - // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My Workbook 2"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), - // SourceID: to.Ptr("Azure Monitor"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-04T09:07:17.735Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), - // }, - // }}, + // }, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookRevisionGet.json -func ExampleWorkbooksClient_RevisionGet() { +// Generated from example definition: 2023-06-01/WorkbookManagedUpdate.json +func ExampleWorkbooksClient_Update_workbookManagedUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbooksClient().RevisionGet(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", "1e2f8435b98248febee70c64ac22e1ab", nil) + res, err := clientFactory.NewWorkbooksClient().Update(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", armapplicationinsights.WorkbookUpdateParameters{}, &armapplicationinsights.WorkbooksClientUpdateOptions{ + SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group")}) 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.Workbook = armapplicationinsights.Workbook{ - // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Type: to.Ptr("Microsoft.Insights/workbooks"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "TagSample01": to.Ptr("sample01"), - // "TagSample02": to.Ptr("sample02"), + // res = armapplicationinsights.WorkbooksClientUpdateResponse{ + // Workbook: armapplicationinsights.Workbook{ + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Identity: &armapplicationinsights.WorkbookResourceIdentity{ + // Type: to.Ptr(armapplicationinsights.ManagedServiceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armapplicationinsights.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid": &armapplicationinsights.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("Sample workbook"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"test\"},\"name\":\"text - 0\"}],\"isLocked\":false,\"fallbackResourceIds\":[\"/subscriptions/8980832b-9589-4ac2-b322-a6ae6a97f02b/resourceGroups/my-resource-group\"]}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"), + // StorageURI: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:15:08.1875458Z"); return t}()), + // UserID: to.Ptr("70d90f65-8a70-4e42-b8d5-863725e0a90f"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // "hidden-title": to.Ptr("Sample workbook"), + // }, // }, - // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), - // Properties: &armapplicationinsights.WorkbookProperties{ - // Description: to.Ptr("Sample workbook"), - // Category: to.Ptr("workbook"), - // DisplayName: to.Ptr("My New Workbook"), - // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1ab"), - // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), - // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-04T09:07:17.735Z"); return t}()), - // UserID: to.Ptr("userId"), - // Version: to.Ptr("Notebook/1.0"), + // } +} + +// Generated from example definition: 2023-06-01/WorkbookUpdate.json +func ExampleWorkbooksClient_Update_workbookUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkbooksClient().Update(ctx, "my-resource-group", "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2", armapplicationinsights.WorkbookUpdateParameters{}, &armapplicationinsights.WorkbooksClientUpdateOptions{ + SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp")}) + 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 = armapplicationinsights.WorkbooksClientUpdateResponse{ + // Workbook: armapplicationinsights.Workbook{ + // Name: to.Ptr("deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Type: to.Ptr("Microsoft.Insights/workbooks"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group/providers/Microsoft.Insights/workbooks/deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"), + // Kind: to.Ptr(armapplicationinsights.WorkbookSharedTypeKindShared), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookProperties{ + // Description: to.Ptr("Sample workbook"), + // Category: to.Ptr("workbook"), + // DisplayName: to.Ptr("Sample workbook"), + // Revision: to.Ptr("1e2f8435b98248febee70c64ac22e1bb"), + // SerializedData: to.Ptr("{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}"), + // SourceID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"), + // StorageURI: nil, + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-20T22:00:26.4229554Z"); return t}()), + // UserID: to.Ptr("userId"), + // Version: to.Ptr("Notebook/1.0"), + // }, + // Tags: map[string]*string{ + // "TagSample01": to.Ptr("sample01"), + // "TagSample02": to.Ptr("sample02"), + // }, // }, // } } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooktemplates_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooktemplates_client.go index 4cf9cbe2783a..075b6ef7595c 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooktemplates_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooktemplates_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // WorkbookTemplatesClient contains the methods for the WorkbookTemplates group. // Don't use this type directly, use NewWorkbookTemplatesClient() instead. +// +// Generated from API version 2020-11-20 type WorkbookTemplatesClient struct { internal *arm.Client subscriptionID string } // NewWorkbookTemplatesClient creates a new instance of WorkbookTemplatesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewWorkbookTemplatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkbookTemplatesClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,8 +43,6 @@ func NewWorkbookTemplatesClient(subscriptionID string, credential azcore.TokenCr // CreateOrUpdate - Create a new workbook template. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-11-20 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - workbookTemplateProperties - Properties that need to be specified to create a new workbook. @@ -91,9 +90,10 @@ func (client *WorkbookTemplatesClient) createOrUpdateCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-11-20") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20201120) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, workbookTemplateProperties); err != nil { return nil, err } @@ -111,8 +111,6 @@ func (client *WorkbookTemplatesClient) createOrUpdateHandleResponse(resp *http.R // Delete - Delete a workbook template. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-11-20 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - WorkbookTemplatesClientDeleteOptions contains the optional parameters for the WorkbookTemplatesClient.Delete @@ -158,16 +156,13 @@ func (client *WorkbookTemplatesClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-11-20") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} + reqQP.Set("api-version", version20201120) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // Get - Get a single workbook template by its resourceName. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-11-20 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - WorkbookTemplatesClientGetOptions contains the optional parameters for the WorkbookTemplatesClient.Get method. @@ -213,8 +208,8 @@ func (client *WorkbookTemplatesClient) getCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-11-20") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20201120) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -229,29 +224,26 @@ func (client *WorkbookTemplatesClient) getHandleResponse(resp *http.Response) (W } // NewListByResourceGroupPager - Get all Workbook templates defined within a specified resource group. -// -// Generated from API version 2020-11-20 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - WorkbookTemplatesClientListByResourceGroupOptions contains the optional parameters for the WorkbookTemplatesClient.NewListByResourceGroupPager // method. func (client *WorkbookTemplatesClient) NewListByResourceGroupPager(resourceGroupName string, options *WorkbookTemplatesClientListByResourceGroupOptions) *runtime.Pager[WorkbookTemplatesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[WorkbookTemplatesClientListByResourceGroupResponse]{ More: func(page WorkbookTemplatesClientListByResourceGroupResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkbookTemplatesClientListByResourceGroupResponse) (WorkbookTemplatesClientListByResourceGroupResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkbookTemplatesClient.NewListByResourceGroupPager") - req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - if err != nil { - return WorkbookTemplatesClientListByResourceGroupResponse{}, err + 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 WorkbookTemplatesClientListByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkbookTemplatesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -274,8 +266,8 @@ func (client *WorkbookTemplatesClient) listByResourceGroupCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-11-20") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20201120) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -291,19 +283,18 @@ func (client *WorkbookTemplatesClient) listByResourceGroupHandleResponse(resp *h // Update - Updates a workbook template that has already been added. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-11-20 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. +// - workbookTemplateUpdateParameters - Properties that need to be specified to patch a workbook template. // - options - WorkbookTemplatesClientUpdateOptions contains the optional parameters for the WorkbookTemplatesClient.Update // method. -func (client *WorkbookTemplatesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, options *WorkbookTemplatesClientUpdateOptions) (WorkbookTemplatesClientUpdateResponse, error) { +func (client *WorkbookTemplatesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookTemplateUpdateParameters WorkbookTemplateUpdateParameters, options *WorkbookTemplatesClientUpdateOptions) (WorkbookTemplatesClientUpdateResponse, error) { var err error const operationName = "WorkbookTemplatesClient.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, resourceName, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, workbookTemplateUpdateParameters, options) if err != nil { return WorkbookTemplatesClientUpdateResponse{}, err } @@ -320,7 +311,7 @@ func (client *WorkbookTemplatesClient) Update(ctx context.Context, resourceGroup } // updateCreateRequest creates the Update request. -func (client *WorkbookTemplatesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *WorkbookTemplatesClientUpdateOptions) (*policy.Request, error) { +func (client *WorkbookTemplatesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, workbookTemplateUpdateParameters WorkbookTemplateUpdateParameters, _ *WorkbookTemplatesClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -339,14 +330,12 @@ func (client *WorkbookTemplatesClient) updateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-11-20") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20201120) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.WorkbookTemplateUpdateParameters != nil { - if err := runtime.MarshalAsJSON(req, *options.WorkbookTemplateUpdateParameters); err != nil { - return nil, err - } - return req, nil + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, workbookTemplateUpdateParameters); err != nil { + return nil, err } return req, nil } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooktemplates_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooktemplates_client_example_test.go index 788940b2e8fc..cd9375d824df 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooktemplates_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workbooktemplates_client_example_test.go @@ -1,137 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplatesList.json -func ExampleWorkbookTemplatesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewWorkbookTemplatesClient().NewListByResourceGroupPager("my-resource-group", 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.WorkbookTemplatesListResult = armapplicationinsights.WorkbookTemplatesListResult{ - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateGet.json -func ExampleWorkbookTemplatesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewWorkbookTemplatesClient().Get(ctx, "my-resource-group", "my-resource-name", 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.WorkbookTemplate = armapplicationinsights.WorkbookTemplate{ - // Name: to.Ptr("my-resource-name"), - // Type: to.Ptr("microsoft.insights/workbooktemplate"), - // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/microsoft.insights/workbooktemplates/my-resource-name"), - // Location: to.Ptr("westus"), - // Properties: &armapplicationinsights.WorkbookTemplateProperties{ - // Author: to.Ptr("Contoso"), - // Galleries: []*armapplicationinsights.WorkbookTemplateGallery{ - // { - // Name: to.Ptr("Simple Template"), - // Type: to.Ptr("tsg"), - // Category: to.Ptr("Failures"), - // Order: to.Ptr[int32](100), - // ResourceType: to.Ptr("microsoft.insights/components"), - // }}, - // Priority: to.Ptr[int32](1), - // TemplateData: map[string]any{ - // "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", - // "items":[]any{ - // map[string]any{ - // "name": "text - 2", - // "type": float64(1), - // "content":map[string]any{ - // "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", - // }, - // }, - // map[string]any{ - // "name": "query - 2", - // "type": float64(3), - // "content":map[string]any{ - // "exportToExcelOptions": "visible", - // "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", - // "queryType": float64(0), - // "resourceType": "microsoft.operationalinsights/workspaces", - // "size": float64(1), - // "version": "KqlItem/1.0", - // }, - // }, - // }, - // "styleSettings":map[string]any{ - // }, - // "version": "Notebook/1.0", - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateDelete.json -func ExampleWorkbookTemplatesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewWorkbookTemplatesClient().Delete(ctx, "my-resource-group", "my-template-resource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateAdd.json +// Generated from example definition: 2020-11-20/WorkbookTemplateAdd.json func ExampleWorkbookTemplatesClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -146,27 +34,28 @@ func ExampleWorkbookTemplatesClient_CreateOrUpdate() { Category: to.Ptr("Failures"), Order: to.Ptr[int32](100), ResourceType: to.Ptr("microsoft.insights/components"), - }}, + }, + }, Priority: to.Ptr[int32](1), TemplateData: map[string]any{ "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", "items": []any{ map[string]any{ "name": "text - 2", - "type": float64(1), + "type": 1, "content": map[string]any{ "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", }, }, map[string]any{ "name": "query - 2", - "type": float64(3), + "type": 3, "content": map[string]any{ "exportToExcelOptions": "visible", "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", - "queryType": float64(0), + "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", - "size": float64(1), + "size": 1, "version": "KqlItem/1.0", }, }, @@ -182,113 +71,333 @@ func ExampleWorkbookTemplatesClient_CreateOrUpdate() { // 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.WorkbookTemplate = armapplicationinsights.WorkbookTemplate{ - // Name: to.Ptr("testtemplate2"), - // Type: to.Ptr("microsoft.insights/workbooktemplates"), - // ID: to.Ptr("/subscriptions/50359d91-7b9d-4823-85af-eb298a61ba95/resourceGroups/testrg/providers/microsoft.insights/workbooktemplates/testtemplate2"), - // Location: to.Ptr("westeurope"), - // Properties: &armapplicationinsights.WorkbookTemplateProperties{ - // Author: to.Ptr("Contoso"), - // Galleries: []*armapplicationinsights.WorkbookTemplateGallery{ - // { - // Name: to.Ptr("Simple Template"), - // Type: to.Ptr("tsg"), - // Category: to.Ptr("Failures"), - // Order: to.Ptr[int32](100), - // ResourceType: to.Ptr("microsoft.insights/components"), - // }}, - // Priority: to.Ptr[int32](1), - // TemplateData: map[string]any{ - // "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", - // "items":[]any{ - // map[string]any{ - // "name": "text - 2", - // "type": float64(1), - // "content":map[string]any{ - // "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", - // }, + // res = armapplicationinsights.WorkbookTemplatesClientCreateOrUpdateResponse{ + // WorkbookTemplate: armapplicationinsights.WorkbookTemplate{ + // Name: to.Ptr("testtemplate2"), + // Type: to.Ptr("microsoft.insights/workbooktemplates"), + // ID: to.Ptr("/subscriptions/50359d91-7b9d-4823-85af-eb298a61ba95/resourceGroups/testrg/providers/microsoft.insights/workbooktemplates/testtemplate2"), + // Location: to.Ptr("westeurope"), + // Properties: &armapplicationinsights.WorkbookTemplateProperties{ + // Author: to.Ptr("Contoso"), + // Galleries: []*armapplicationinsights.WorkbookTemplateGallery{ + // { + // Name: to.Ptr("Simple Template"), + // Type: to.Ptr("tsg"), + // Category: to.Ptr("Failures"), + // Order: to.Ptr[int32](100), + // ResourceType: to.Ptr("microsoft.insights/components"), // }, - // map[string]any{ - // "name": "query - 2", - // "type": float64(3), - // "content":map[string]any{ - // "exportToExcelOptions": "visible", - // "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", - // "queryType": float64(0), - // "resourceType": "microsoft.operationalinsights/workspaces", - // "size": float64(1), - // "version": "KqlItem/1.0", + // }, + // Priority: to.Ptr[int32](1), + // TemplateData: map[string]any{ + // "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", + // "items": []any{ + // map[string]any{ + // "name": "text - 2", + // "type": 1, + // "content": map[string]any{ + // "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", + // }, // }, + // map[string]any{ + // "name": "query - 2", + // "type": 3, + // "content": map[string]any{ + // "exportToExcelOptions": "visible", + // "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", + // "queryType": 0, + // "resourceType": "microsoft.operationalinsights/workspaces", + // "size": 1, + // "version": "KqlItem/1.0", + // }, + // }, + // }, + // "styleSettings": map[string]any{ // }, + // "version": "Notebook/1.0", // }, - // "styleSettings":map[string]any{ + // }, + // }, + // } +} + +// Generated from example definition: 2020-11-20/WorkbookTemplateDelete.json +func ExampleWorkbookTemplatesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkbookTemplatesClient().Delete(ctx, "my-resource-group", "my-template-resource", 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 = armapplicationinsights.WorkbookTemplatesClientDeleteResponse{ + // } +} + +// Generated from example definition: 2020-11-20/WorkbookTemplateGet.json +func ExampleWorkbookTemplatesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkbookTemplatesClient().Get(ctx, "my-resource-group", "my-resource-name", 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 = armapplicationinsights.WorkbookTemplatesClientGetResponse{ + // WorkbookTemplate: armapplicationinsights.WorkbookTemplate{ + // Name: to.Ptr("my-resource-name"), + // Type: to.Ptr("microsoft.insights/workbooktemplate"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/microsoft.insights/workbooktemplates/my-resource-name"), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookTemplateProperties{ + // Author: to.Ptr("Contoso"), + // Galleries: []*armapplicationinsights.WorkbookTemplateGallery{ + // { + // Name: to.Ptr("Simple Template"), + // Type: to.Ptr("tsg"), + // Category: to.Ptr("Failures"), + // Order: to.Ptr[int32](100), + // ResourceType: to.Ptr("microsoft.insights/components"), + // }, + // }, + // Priority: to.Ptr[int32](1), + // TemplateData: map[string]any{ + // "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", + // "items": []any{ + // map[string]any{ + // "name": "text - 2", + // "type": 1, + // "content": map[string]any{ + // "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", + // }, + // }, + // map[string]any{ + // "name": "query - 2", + // "type": 3, + // "content": map[string]any{ + // "exportToExcelOptions": "visible", + // "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", + // "queryType": 0, + // "resourceType": "microsoft.operationalinsights/workspaces", + // "size": 1, + // "version": "KqlItem/1.0", + // }, + // }, + // }, + // "styleSettings": map[string]any{ + // }, + // "version": "Notebook/1.0", // }, - // "version": "Notebook/1.0", // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateUpdate.json +// Generated from example definition: 2020-11-20/WorkbookTemplatesList.json +func ExampleWorkbookTemplatesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkbookTemplatesClient().NewListByResourceGroupPager("my-resource-group", 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 = armapplicationinsights.WorkbookTemplatesClientListByResourceGroupResponse{ + // WorkbookTemplatesListResult: armapplicationinsights.WorkbookTemplatesListResult{ + // Value: []*armapplicationinsights.WorkbookTemplate{ + // { + // Name: to.Ptr("my-resource-name"), + // Type: to.Ptr("microsoft.insights/workbooktemplate"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/microsoft.insights/workbooktemplates/my-resource-name"), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookTemplateProperties{ + // Author: to.Ptr("Contoso"), + // Galleries: []*armapplicationinsights.WorkbookTemplateGallery{ + // { + // Name: to.Ptr("Simple Template"), + // Type: to.Ptr("tsg"), + // Category: to.Ptr("Failures"), + // Order: to.Ptr[int32](100), + // ResourceType: to.Ptr("microsoft.insights/components"), + // }, + // }, + // Priority: to.Ptr[int32](1), + // TemplateData: map[string]any{ + // "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", + // "items": []any{ + // map[string]any{ + // "name": "text - 2", + // "type": 1, + // "content": map[string]any{ + // "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", + // }, + // }, + // map[string]any{ + // "name": "query - 2", + // "type": 3, + // "content": map[string]any{ + // "exportToExcelOptions": "visible", + // "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", + // "queryType": 0, + // "resourceType": "microsoft.operationalinsights/workspaces", + // "size": 1, + // "version": "KqlItem/1.0", + // }, + // }, + // }, + // "styleSettings": map[string]any{ + // }, + // "version": "Notebook/1.0", + // }, + // }, + // }, + // { + // Name: to.Ptr("my-resource-name2"), + // Type: to.Ptr("microsoft.insights/workbooktemplate"), + // ID: to.Ptr("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/microsoft.insights/workbooktemplates/my-resource-name2"), + // Location: to.Ptr("westus"), + // Properties: &armapplicationinsights.WorkbookTemplateProperties{ + // Author: to.Ptr("Contoso"), + // Galleries: []*armapplicationinsights.WorkbookTemplateGallery{ + // { + // Name: to.Ptr("Simple Template 2"), + // Type: to.Ptr("tsg"), + // Category: to.Ptr("Failures"), + // Order: to.Ptr[int32](100), + // ResourceType: to.Ptr("microsoft.insights/components"), + // }, + // }, + // Priority: to.Ptr[int32](1), + // TemplateData: map[string]any{ + // "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", + // "items": []any{ + // map[string]any{ + // "name": "text - 2", + // "type": 1, + // "content": map[string]any{ + // "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", + // }, + // }, + // map[string]any{ + // "name": "query - 2", + // "type": 3, + // "content": map[string]any{ + // "exportToExcelOptions": "visible", + // "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", + // "queryType": 0, + // "resourceType": "microsoft.operationalinsights/workspaces", + // "size": 1, + // "version": "KqlItem/1.0", + // }, + // }, + // }, + // "styleSettings": map[string]any{ + // }, + // "version": "Notebook/1.0", + // }, + // }, + // }, + // }, + // NextLink: to.Ptr("https://nextlink.url"), + // }, + // } + } +} + +// Generated from example definition: 2020-11-20/WorkbookTemplateUpdate.json func ExampleWorkbookTemplatesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("6b643656-33eb-422f-aee8-3ac145d124af", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkbookTemplatesClient().Update(ctx, "my-resource-group", "my-template-resource", &armapplicationinsights.WorkbookTemplatesClientUpdateOptions{WorkbookTemplateUpdateParameters: nil}) + res, err := clientFactory.NewWorkbookTemplatesClient().Update(ctx, "my-resource-group", "my-template-resource", armapplicationinsights.WorkbookTemplateUpdateParameters{}, 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.WorkbookTemplate = armapplicationinsights.WorkbookTemplate{ - // Name: to.Ptr("testtemplate2"), - // Type: to.Ptr("microsoft.insights/workbooktemplates"), - // ID: to.Ptr("/subscriptions/50359d91-7b9d-4823-85af-eb298a61ba95/resourceGroups/testrg/providers/microsoft.insights/workbooktemplates/testtemplate2"), - // Location: to.Ptr("westeurope"), - // Properties: &armapplicationinsights.WorkbookTemplateProperties{ - // Author: to.Ptr("Contoso"), - // Galleries: []*armapplicationinsights.WorkbookTemplateGallery{ - // { - // Name: to.Ptr("Simple Template"), - // Type: to.Ptr("tsg"), - // Category: to.Ptr("Failures"), - // Order: to.Ptr[int32](100), - // ResourceType: to.Ptr("microsoft.insights/components"), - // }}, - // Priority: to.Ptr[int32](1), - // TemplateData: map[string]any{ - // "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", - // "items":[]any{ - // map[string]any{ - // "name": "text - 2", - // "type": float64(1), - // "content":map[string]any{ - // "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", - // }, + // res = armapplicationinsights.WorkbookTemplatesClientUpdateResponse{ + // WorkbookTemplate: armapplicationinsights.WorkbookTemplate{ + // Name: to.Ptr("testtemplate2"), + // Type: to.Ptr("microsoft.insights/workbooktemplates"), + // ID: to.Ptr("/subscriptions/50359d91-7b9d-4823-85af-eb298a61ba95/resourceGroups/testrg/providers/microsoft.insights/workbooktemplates/testtemplate2"), + // Location: to.Ptr("westeurope"), + // Properties: &armapplicationinsights.WorkbookTemplateProperties{ + // Author: to.Ptr("Contoso"), + // Galleries: []*armapplicationinsights.WorkbookTemplateGallery{ + // { + // Name: to.Ptr("Simple Template"), + // Type: to.Ptr("tsg"), + // Category: to.Ptr("Failures"), + // Order: to.Ptr[int32](100), + // ResourceType: to.Ptr("microsoft.insights/components"), // }, - // map[string]any{ - // "name": "query - 2", - // "type": float64(3), - // "content":map[string]any{ - // "exportToExcelOptions": "visible", - // "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", - // "queryType": float64(0), - // "resourceType": "microsoft.operationalinsights/workspaces", - // "size": float64(1), - // "version": "KqlItem/1.0", + // }, + // Priority: to.Ptr[int32](1), + // TemplateData: map[string]any{ + // "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", + // "items": []any{ + // map[string]any{ + // "name": "text - 2", + // "type": 1, + // "content": map[string]any{ + // "json": "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", + // }, + // }, + // map[string]any{ + // "name": "query - 2", + // "type": 3, + // "content": map[string]any{ + // "exportToExcelOptions": "visible", + // "query": "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", + // "queryType": 0, + // "resourceType": "microsoft.operationalinsights/workspaces", + // "size": 1, + // "version": "KqlItem/1.0", + // }, // }, // }, + // "styleSettings": map[string]any{ + // }, + // "version": "Notebook/1.0", // }, - // "styleSettings":map[string]any{ - // }, - // "version": "Notebook/1.0", // }, // }, // } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workitemconfigurations_client.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workitemconfigurations_client.go index da6c6583600c..7233d2af875f 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workitemconfigurations_client.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workitemconfigurations_client.go @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights @@ -19,15 +18,17 @@ import ( // WorkItemConfigurationsClient contains the methods for the WorkItemConfigurations group. // Don't use this type directly, use NewWorkItemConfigurationsClient() instead. +// +// Generated from API version 2015-05-01 type WorkItemConfigurationsClient struct { internal *arm.Client subscriptionID string } // NewWorkItemConfigurationsClient creates a new instance of WorkItemConfigurationsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewWorkItemConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkItemConfigurationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -42,12 +43,9 @@ func NewWorkItemConfigurationsClient(subscriptionID string, credential azcore.To // Create - Create a work item configuration for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. -// - workItemConfigurationProperties - Properties that need to be specified to create a work item configuration of a Application -// Insights component. +// - workItemConfigurationProperties - Work item configuration creation payload // - options - WorkItemConfigurationsClientCreateOptions contains the optional parameters for the WorkItemConfigurationsClient.Create // method. func (client *WorkItemConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties WorkItemCreateConfiguration, options *WorkItemConfigurationsClientCreateOptions) (WorkItemConfigurationsClientCreateResponse, error) { @@ -75,14 +73,14 @@ func (client *WorkItemConfigurationsClient) Create(ctx context.Context, resource // createCreateRequest creates the Create request. func (client *WorkItemConfigurationsClient) createCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties WorkItemCreateConfiguration, _ *WorkItemConfigurationsClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -92,9 +90,10 @@ func (client *WorkItemConfigurationsClient) createCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, workItemConfigurationProperties); err != nil { return nil, err } @@ -112,8 +111,6 @@ func (client *WorkItemConfigurationsClient) createHandleResponse(resp *http.Resp // Delete - Delete a work item configuration of an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - workItemConfigID - The unique work item configuration Id. This can be either friendly name of connector as defined in connector @@ -144,14 +141,14 @@ func (client *WorkItemConfigurationsClient) Delete(ctx context.Context, resource // deleteCreateRequest creates the Delete request. func (client *WorkItemConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string, _ *WorkItemConfigurationsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -165,15 +162,13 @@ func (client *WorkItemConfigurationsClient) deleteCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") return req, nil } // GetDefault - Gets default work item configurations that exist for the application // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - WorkItemConfigurationsClientGetDefaultOptions contains the optional parameters for the WorkItemConfigurationsClient.GetDefault @@ -203,14 +198,14 @@ func (client *WorkItemConfigurationsClient) GetDefault(ctx context.Context, reso // getDefaultCreateRequest creates the GetDefault request. func (client *WorkItemConfigurationsClient) getDefaultCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *WorkItemConfigurationsClientGetDefaultOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -220,8 +215,8 @@ func (client *WorkItemConfigurationsClient) getDefaultCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -237,8 +232,6 @@ func (client *WorkItemConfigurationsClient) getDefaultHandleResponse(resp *http. // GetItem - Gets specified work item configuration for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - workItemConfigID - The unique work item configuration Id. This can be either friendly name of connector as defined in connector @@ -270,14 +263,14 @@ func (client *WorkItemConfigurationsClient) GetItem(ctx context.Context, resourc // getItemCreateRequest creates the GetItem request. func (client *WorkItemConfigurationsClient) getItemCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string, _ *WorkItemConfigurationsClientGetItemOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -291,8 +284,8 @@ func (client *WorkItemConfigurationsClient) getItemCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -307,8 +300,6 @@ func (client *WorkItemConfigurationsClient) getItemHandleResponse(resp *http.Res } // NewListPager - Gets the list work item configurations that exist for the application -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - options - WorkItemConfigurationsClientListOptions contains the optional parameters for the WorkItemConfigurationsClient.NewListPager @@ -316,21 +307,20 @@ func (client *WorkItemConfigurationsClient) getItemHandleResponse(resp *http.Res func (client *WorkItemConfigurationsClient) NewListPager(resourceGroupName string, resourceName string, options *WorkItemConfigurationsClientListOptions) *runtime.Pager[WorkItemConfigurationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[WorkItemConfigurationsClientListResponse]{ More: func(page WorkItemConfigurationsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkItemConfigurationsClientListResponse) (WorkItemConfigurationsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkItemConfigurationsClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, options) - if err != nil { - return WorkItemConfigurationsClientListResponse{}, err + 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.listCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) if err != nil { return WorkItemConfigurationsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkItemConfigurationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -340,14 +330,14 @@ func (client *WorkItemConfigurationsClient) NewListPager(resourceGroupName strin // listCreateRequest creates the List request. func (client *WorkItemConfigurationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *WorkItemConfigurationsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -357,8 +347,8 @@ func (client *WorkItemConfigurationsClient) listCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -374,8 +364,6 @@ func (client *WorkItemConfigurationsClient) listHandleResponse(resp *http.Respon // UpdateItem - Update a work item configuration for an Application Insights component. // If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2015-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the Application Insights component resource. // - workItemConfigID - The unique work item configuration Id. This can be either friendly name of connector as defined in connector @@ -409,14 +397,14 @@ func (client *WorkItemConfigurationsClient) UpdateItem(ctx context.Context, reso // updateItemCreateRequest creates the UpdateItem request. func (client *WorkItemConfigurationsClient) updateItemCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string, workItemConfigurationProperties WorkItemCreateConfiguration, _ *WorkItemConfigurationsClientUpdateItemOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 resourceName == "" { return nil, errors.New("parameter resourceName cannot be empty") } @@ -430,9 +418,10 @@ func (client *WorkItemConfigurationsClient) updateItemCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2015-05-01") - req.Raw().URL.RawQuery = reqQP.Encode() + reqQP.Set("api-version", version20150501) + req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20") req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, workItemConfigurationProperties); err != nil { return nil, err } diff --git a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workitemconfigurations_client_example_test.go b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workitemconfigurations_client_example_test.go index 10ea2b8d9f66..391771f2baca 100644 --- a/sdk/resourcemanager/applicationinsights/armapplicationinsights/workitemconfigurations_client_example_test.go +++ b/sdk/resourcemanager/applicationinsights/armapplicationinsights/workitemconfigurations_client_example_test.go @@ -1,55 +1,25 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// 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 Microsoft (R) Go Code Generator. DO NOT EDIT. package armapplicationinsights_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/applicationinsights/armapplicationinsights/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/WorkItemConfigsGet.json -func ExampleWorkItemConfigurationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewWorkItemConfigurationsClient().NewListPager("my-resource-group", "my-component", 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.WorkItemConfigurationsListResult = armapplicationinsights.WorkItemConfigurationsListResult{ - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/WorkItemConfigCreate.json +// Generated from example definition: 2015-05-01/WorkItemConfigCreate.json func ExampleWorkItemConfigurationsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -58,8 +28,8 @@ func ExampleWorkItemConfigurationsClient_Create() { ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), ValidateOnly: to.Ptr(true), WorkItemProperties: map[string]*string{ - "0": to.Ptr("[object Object]"), - "1": to.Ptr("[object Object]"), + "name": to.Ptr("Title"), + "value": to.Ptr("Validate Only Title"), }, }, nil) if err != nil { @@ -68,62 +38,71 @@ func ExampleWorkItemConfigurationsClient_Create() { // 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.WorkItemConfiguration = armapplicationinsights.WorkItemConfiguration{ + // res = armapplicationinsights.WorkItemConfigurationsClientCreateResponse{ + // WorkItemConfiguration: armapplicationinsights.WorkItemConfiguration{ + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/WorkItemConfigDefaultGet.json -func ExampleWorkItemConfigurationsClient_GetDefault() { +// Generated from example definition: 2015-05-01/WorkItemConfigDelete.json +func ExampleWorkItemConfigurationsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewWorkItemConfigurationsClient().GetDefault(ctx, "my-resource-group", "my-component", nil) + res, err := clientFactory.NewWorkItemConfigurationsClient().Delete(ctx, "my-resource-group", "my-component", "Visual Studio Team Services", 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.WorkItemConfiguration = armapplicationinsights.WorkItemConfiguration{ - // ConfigDisplayName: to.Ptr("Visual Studio Team Services"), - // ConfigProperties: to.Ptr("{\"VSOAccountBaseUrl\":\"https://testtodelete.visualstudio.com\",\"ProjectCollection\":\"DefaultCollection\",\"Project\":\"todeletefirst\",\"ResourceId\":\"d0662b05-439a-4a1b-840b-33a7f8b42ebf\",\"ConfigurationType\":\"Standard\",\"WorkItemType\":\"Bug\",\"AreaPath\":\"todeletefirst\",\"AssignedTo\":\"\"}"), - // ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), - // ID: to.Ptr("Visual Studio Team Services"), - // IsDefault: to.Ptr(true), + // res = armapplicationinsights.WorkItemConfigurationsClientDeleteResponse{ // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/WorkItemConfigDelete.json -func ExampleWorkItemConfigurationsClient_Delete() { +// Generated from example definition: 2015-05-01/WorkItemConfigDefaultGet.json +func ExampleWorkItemConfigurationsClient_GetDefault() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewWorkItemConfigurationsClient().Delete(ctx, "my-resource-group", "my-component", "Visual Studio Team Services", nil) + res, err := clientFactory.NewWorkItemConfigurationsClient().GetDefault(ctx, "my-resource-group", "my-component", 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 = armapplicationinsights.WorkItemConfigurationsClientGetDefaultResponse{ + // WorkItemConfiguration: armapplicationinsights.WorkItemConfiguration{ + // ConfigDisplayName: to.Ptr("Visual Studio Team Services"), + // ConfigProperties: to.Ptr("{\"VSOAccountBaseUrl\":\"https://testtodelete.visualstudio.com\",\"ProjectCollection\":\"DefaultCollection\",\"Project\":\"todeletefirst\",\"ResourceId\":\"d0662b05-439a-4a1b-840b-33a7f8b42ebf\",\"ConfigurationType\":\"Standard\",\"WorkItemType\":\"Bug\",\"AreaPath\":\"todeletefirst\",\"AssignedTo\":\"\"}"), + // ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), + // ID: to.Ptr("Visual Studio Team Services"), + // IsDefault: to.Ptr(true), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/WorkItemConfigGet.json +// Generated from example definition: 2015-05-01/WorkItemConfigGet.json func ExampleWorkItemConfigurationsClient_GetItem() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -134,23 +113,70 @@ func ExampleWorkItemConfigurationsClient_GetItem() { // 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.WorkItemConfiguration = armapplicationinsights.WorkItemConfiguration{ - // ConfigDisplayName: to.Ptr("Visual Studio Team Services"), - // ConfigProperties: to.Ptr("{\"VSOAccountBaseUrl\":\"https://testtodelete.visualstudio.com\",\"ProjectCollection\":\"DefaultCollection\",\"Project\":\"todeletefirst\",\"ResourceId\":\"d0662b05-439a-4a1b-840b-33a7f8b42ebf\",\"ConfigurationType\":\"Standard\",\"WorkItemType\":\"Bug\",\"AreaPath\":\"todeletefirst\",\"AssignedTo\":\"\"}"), - // ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), - // ID: to.Ptr("Visual Studio Team Services"), - // IsDefault: to.Ptr(true), + // res = armapplicationinsights.WorkItemConfigurationsClientGetItemResponse{ + // WorkItemConfiguration: armapplicationinsights.WorkItemConfiguration{ + // ConfigDisplayName: to.Ptr("Visual Studio Team Services"), + // ConfigProperties: to.Ptr("{\"VSOAccountBaseUrl\":\"https://testtodelete.visualstudio.com\",\"ProjectCollection\":\"DefaultCollection\",\"Project\":\"todeletefirst\",\"ResourceId\":\"d0662b05-439a-4a1b-840b-33a7f8b42ebf\",\"ConfigurationType\":\"Standard\",\"WorkItemType\":\"Bug\",\"AreaPath\":\"todeletefirst\",\"AssignedTo\":\"\"}"), + // ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), + // ID: to.Ptr("Visual Studio Team Services"), + // IsDefault: to.Ptr(true), + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/8a0168458930c86636a76bcd7acfdc9c81291bfc/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/WorkItemConfigUpdate.json +// Generated from example definition: 2015-05-01/WorkItemConfigsGet.json +func ExampleWorkItemConfigurationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkItemConfigurationsClient().NewListPager("my-resource-group", "my-component", 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 = armapplicationinsights.WorkItemConfigurationsClientListResponse{ + // WorkItemConfigurationsListResult: armapplicationinsights.WorkItemConfigurationsListResult{ + // Value: []*armapplicationinsights.WorkItemConfiguration{ + // { + // ConfigDisplayName: to.Ptr("Visual Studio Team Services"), + // ConfigProperties: to.Ptr("{\"VSOAccountBaseUrl\":\"https://testtodelete.visualstudio.com\",\"ProjectCollection\":\"DefaultCollection\",\"Project\":\"todeletefirst\",\"ResourceId\":\"b370eeb2-5dff-4838-8253-ec3014b2c706\",\"ConfigurationType\":\"Standard\",\"WorkItemType\":\"Bug\",\"AreaPath\":\"todeletefirst\",\"AssignedTo\":\"\"}"), + // ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), + // ID: to.Ptr("Visual Studio Team Services"), + // IsDefault: to.Ptr(true), + // }, + // { + // ConfigDisplayName: to.Ptr("GitHub"), + // ConfigProperties: to.Ptr("{\"GitHubAccountUrl\":\"https://github.com/jpiyali/testrepository\",\"ResourceId\":\"b370eeb2-5dff-4838-8253-ec3014b2c706\"}"), + // ConnectorID: to.Ptr("4C89E219-D47E-4C14-866A-018D6D634CF3"), + // ID: to.Ptr("GitHub"), + // IsDefault: to.Ptr(false), + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2015-05-01/WorkItemConfigUpdate.json func ExampleWorkItemConfigurationsClient_UpdateItem() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armapplicationinsights.NewClientFactory("", cred, nil) + clientFactory, err := armapplicationinsights.NewClientFactory("subid", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -159,8 +185,8 @@ func ExampleWorkItemConfigurationsClient_UpdateItem() { ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), ValidateOnly: to.Ptr(true), WorkItemProperties: map[string]*string{ - "0": to.Ptr("[object Object]"), - "1": to.Ptr("[object Object]"), + "name": to.Ptr("Title"), + "value": to.Ptr("Validate Only Title"), }, }, nil) if err != nil { @@ -169,11 +195,13 @@ func ExampleWorkItemConfigurationsClient_UpdateItem() { // 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.WorkItemConfiguration = armapplicationinsights.WorkItemConfiguration{ - // ConfigDisplayName: to.Ptr("Visual Studio Team Services"), - // ConfigProperties: to.Ptr("{\"VSOAccountBaseUrl\":\"https://testtodelete.visualstudio.com\",\"ProjectCollection\":\"DefaultCollection\",\"Project\":\"todeletefirst\",\"ResourceId\":\"d0662b05-439a-4a1b-840b-33a7f8b42ebf\",\"ConfigurationType\":\"Standard\",\"WorkItemType\":\"Bug\",\"AreaPath\":\"todeletefirst\",\"AssignedTo\":\"\"}"), - // ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), - // ID: to.Ptr("Visual Studio Team Services"), - // IsDefault: to.Ptr(true), + // res = armapplicationinsights.WorkItemConfigurationsClientUpdateItemResponse{ + // WorkItemConfiguration: armapplicationinsights.WorkItemConfiguration{ + // ConfigDisplayName: to.Ptr("Visual Studio Team Services"), + // ConfigProperties: to.Ptr("{\"VSOAccountBaseUrl\":\"https://testtodelete.visualstudio.com\",\"ProjectCollection\":\"DefaultCollection\",\"Project\":\"todeletefirst\",\"ResourceId\":\"d0662b05-439a-4a1b-840b-33a7f8b42ebf\",\"ConfigurationType\":\"Standard\",\"WorkItemType\":\"Bug\",\"AreaPath\":\"todeletefirst\",\"AssignedTo\":\"\"}"), + // ConnectorID: to.Ptr("d334e2a4-6733-488e-8645-a9fdc1694f41"), + // ID: to.Ptr("Visual Studio Team Services"), + // IsDefault: to.Ptr(true), + // }, // } }