diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/CHANGELOG.md b/sdk/resourcemanager/operationalinsights/armoperationalinsights/CHANGELOG.md index db823f475b28..24d85d5bf46a 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/CHANGELOG.md +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 2.0.0-beta.4 (2024-08-19) +### Features Added + +- New function `*QueryPacksClient.CreateOrUpdateWithoutName(context.Context, string, LogAnalyticsQueryPack, *QueryPacksClientCreateOrUpdateWithoutNameOptions) (QueryPacksClientCreateOrUpdateWithoutNameResponse, error)` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/README.md b/sdk/resourcemanager/operationalinsights/armoperationalinsights/README.md index c4af147e765b..36c78f0c8ec7 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/README.md +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/README.md @@ -1,6 +1,6 @@ # Azure Operational Insights Module for Go -[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2) The `armoperationalinsights` module provides operations for working with Azure Operational Insights. @@ -20,7 +20,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Operational Insights module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2 ``` ## Authorization @@ -57,7 +57,7 @@ clientFactory, err := armoperationalinsights.NewClientFactory(, A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewClustersClient() +client := clientFactory.NewAvailableServiceTiersClient() ``` ## Fakes diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/assets.json b/sdk/resourcemanager/operationalinsights/armoperationalinsights/assets.json index e4a9a4db80fe..9e703d80f450 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/assets.json +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/resourcemanager/operationalinsights/armoperationalinsights", - "Tag": "go/resourcemanager/operationalinsights/armoperationalinsights_02f242b5fb" + "Tag": "go/resourcemanager/operationalinsights/armoperationalinsights_647c35dab2" } diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/autorest.md b/sdk/resourcemanager/operationalinsights/armoperationalinsights/autorest.md index 4084e7f61a82..f469ac1dfc32 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/autorest.md +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 -tag: package-2021-06 +module-version: 2.0.0-beta.4 +tag: package-2022-02 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/availableservicetiers_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/availableservicetiers_client_example_test.go index 334f94121934..83b18fab51d1 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/availableservicetiers_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/availableservicetiers_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesAvailableServiceTiers.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesAvailableServiceTiers.json func ExampleAvailableServiceTiersClient_ListByWorkspace() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/client_factory.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/client_factory.go index 9331eafb02f4..caa46c08491d 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/client_factory.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/client_factory.go @@ -17,8 +17,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,132 +26,187 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewAvailableServiceTiersClient creates a new instance of AvailableServiceTiersClient. func (c *ClientFactory) NewAvailableServiceTiersClient() *AvailableServiceTiersClient { - subClient, _ := NewAvailableServiceTiersClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AvailableServiceTiersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewClustersClient creates a new instance of ClustersClient. func (c *ClientFactory) NewClustersClient() *ClustersClient { - subClient, _ := NewClustersClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ClustersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDataExportsClient creates a new instance of DataExportsClient. func (c *ClientFactory) NewDataExportsClient() *DataExportsClient { - subClient, _ := NewDataExportsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DataExportsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDataSourcesClient creates a new instance of DataSourcesClient. func (c *ClientFactory) NewDataSourcesClient() *DataSourcesClient { - subClient, _ := NewDataSourcesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DataSourcesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDeletedWorkspacesClient creates a new instance of DeletedWorkspacesClient. func (c *ClientFactory) NewDeletedWorkspacesClient() *DeletedWorkspacesClient { - subClient, _ := NewDeletedWorkspacesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DeletedWorkspacesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGatewaysClient creates a new instance of GatewaysClient. func (c *ClientFactory) NewGatewaysClient() *GatewaysClient { - subClient, _ := NewGatewaysClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GatewaysClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewIntelligencePacksClient creates a new instance of IntelligencePacksClient. func (c *ClientFactory) NewIntelligencePacksClient() *IntelligencePacksClient { - subClient, _ := NewIntelligencePacksClient(c.subscriptionID, c.credential, c.options) - return subClient + return &IntelligencePacksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewLinkedServicesClient creates a new instance of LinkedServicesClient. func (c *ClientFactory) NewLinkedServicesClient() *LinkedServicesClient { - subClient, _ := NewLinkedServicesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &LinkedServicesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewLinkedStorageAccountsClient creates a new instance of LinkedStorageAccountsClient. func (c *ClientFactory) NewLinkedStorageAccountsClient() *LinkedStorageAccountsClient { - subClient, _ := NewLinkedStorageAccountsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &LinkedStorageAccountsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewManagementGroupsClient creates a new instance of ManagementGroupsClient. func (c *ClientFactory) NewManagementGroupsClient() *ManagementGroupsClient { - subClient, _ := NewManagementGroupsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ManagementGroupsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationStatusesClient creates a new instance of OperationStatusesClient. func (c *ClientFactory) NewOperationStatusesClient() *OperationStatusesClient { - subClient, _ := NewOperationStatusesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &OperationStatusesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } +} + +// NewQueriesClient creates a new instance of QueriesClient. +func (c *ClientFactory) NewQueriesClient() *QueriesClient { + return &QueriesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewQueryPacksClient creates a new instance of QueryPacksClient. +func (c *ClientFactory) NewQueryPacksClient() *QueryPacksClient { + return &QueryPacksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewSavedSearchesClient creates a new instance of SavedSearchesClient. func (c *ClientFactory) NewSavedSearchesClient() *SavedSearchesClient { - subClient, _ := NewSavedSearchesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SavedSearchesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewSchemaClient creates a new instance of SchemaClient. func (c *ClientFactory) NewSchemaClient() *SchemaClient { - subClient, _ := NewSchemaClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SchemaClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewSharedKeysClient creates a new instance of SharedKeysClient. func (c *ClientFactory) NewSharedKeysClient() *SharedKeysClient { - subClient, _ := NewSharedKeysClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SharedKeysClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewStorageInsightConfigsClient creates a new instance of StorageInsightConfigsClient. func (c *ClientFactory) NewStorageInsightConfigsClient() *StorageInsightConfigsClient { - subClient, _ := NewStorageInsightConfigsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &StorageInsightConfigsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTablesClient creates a new instance of TablesClient. func (c *ClientFactory) NewTablesClient() *TablesClient { - subClient, _ := NewTablesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TablesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewUsagesClient creates a new instance of UsagesClient. func (c *ClientFactory) NewUsagesClient() *UsagesClient { - subClient, _ := NewUsagesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &UsagesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewWorkspacePurgeClient creates a new instance of WorkspacePurgeClient. func (c *ClientFactory) NewWorkspacePurgeClient() *WorkspacePurgeClient { - subClient, _ := NewWorkspacePurgeClient(c.subscriptionID, c.credential, c.options) - return subClient + return &WorkspacePurgeClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewWorkspacesClient creates a new instance of WorkspacesClient. func (c *ClientFactory) NewWorkspacesClient() *WorkspacesClient { - subClient, _ := NewWorkspacesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &WorkspacesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_client.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_client.go index c23adf5364b2..30d618836d46 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_client.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_client.go @@ -419,7 +419,7 @@ func (client *ClustersClient) update(ctx context.Context, resourceGroupName stri if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_client_example_test.go index ec63faf4ec00..b043792fa14c 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersListByResourceGroup.json func ExampleClustersClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -70,7 +70,7 @@ func ExampleClustersClient_NewListByResourceGroupPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersSubscriptionList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersSubscriptionList.json func ExampleClustersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -122,7 +122,7 @@ func ExampleClustersClient_NewListPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersCreate.json func ExampleClustersClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -188,7 +188,7 @@ func ExampleClustersClient_BeginCreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersDelete.json func ExampleClustersClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -209,7 +209,7 @@ func ExampleClustersClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersGet.json func ExampleClustersClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -228,10 +228,54 @@ func ExampleClustersClient_Get() { _ = 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.Cluster = armoperationalinsights.Cluster{ + // Name: to.Ptr("TestResourceLock"), + // Type: to.Ptr("Microsoft.OperationalInsights/clusters"), + // ID: to.Ptr("/subscriptions/594038b5-1093-476e-a366-482775671c11/resourcegroups/calbot-rg/providers/microsoft.operationalinsights/clusters/testresourcelock"), + // Location: to.Ptr("eastus"), + // Identity: &armoperationalinsights.Identity{ + // Type: to.Ptr(armoperationalinsights.IdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("356d057d-cba5-44dd-8a30-b2e547bc416b"), + // TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), + // }, + // Properties: &armoperationalinsights.ClusterProperties{ + // AssociatedWorkspaces: []*armoperationalinsights.AssociatedWorkspace{ + // { + // AssociateDate: to.Ptr("Tue, 07 Jul 2020 07:35:51 GMT"), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/testRG/providers/microsoft.operationalinsights/workspaces/testWs1"), + // WorkspaceID: to.Ptr("942bdefd-e6c9-411c-ac69-70ffad564363"), + // WorkspaceName: to.Ptr("testWs1"), + // }, + // { + // AssociateDate: to.Ptr("Mon, 13 Jan 2020 16:03:39 GMT"), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/testRG/providers/microsoft.operationalinsights/workspaces/testWs2"), + // WorkspaceID: to.Ptr("c7edb8f8-67f7-41f2-bddb-aecf22507e3f"), + // WorkspaceName: to.Ptr("testWs2"), + // }}, + // BillingType: to.Ptr(armoperationalinsights.BillingTypeCluster), + // CapacityReservationProperties: &armoperationalinsights.CapacityReservationProperties{ + // LastSKUUpdate: to.Ptr("Thu, 01 Jan 1970 00:00:00 GMT"), + // MinCapacity: to.Ptr[int64](500), + // }, + // ClusterID: to.Ptr("1c3f2afc-9ec1-4e74-bfe8-022b83bcd7b1"), + // CreatedDate: to.Ptr("Mon, 13 Jan 2020 14:40:33 GMT"), + // IsAvailabilityZonesEnabled: to.Ptr(false), + // IsDoubleEncryptionEnabled: to.Ptr(false), + // KeyVaultProperties: &armoperationalinsights.KeyVaultProperties{ + // KeyName: to.Ptr("aztest2170cert"), + // KeyVaultURI: to.Ptr("https://aztest2170.vault.azure.net"), + // KeyVersion: to.Ptr("654ft6c4e63845cbb50fd6fg51540429"), + // }, + // LastModifiedDate: to.Ptr("Sun, 04 Jan 2020 17:10:56 GMT"), + // ProvisioningState: to.Ptr(armoperationalinsights.ClusterEntityStatusSucceeded), + // }, + // SKU: &armoperationalinsights.ClusterSKU{ + // Name: to.Ptr(armoperationalinsights.ClusterSKUNameEnumCapacityReservation), + // Capacity: to.Ptr(armoperationalinsights.CapacityTenHundred), + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersUpdate.json func ExampleClustersClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_live_test.go index 2a8c3988fc86..0f2173738ed3 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/clusters_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/constants.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/constants.go index 4fb7c188b054..1782aa1928c6 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/constants.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/constants.go @@ -10,7 +10,7 @@ package armoperationalinsights const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" - moduleVersion = "v1.2.0" + moduleVersion = "v2.0.0-beta.4" ) // BillingType - Configures whether billing will be only on the cluster or each workspace will be billed by its proportional @@ -119,6 +119,78 @@ func PossibleClusterSKUNameEnumValues() []ClusterSKUNameEnum { } } +// ColumnDataTypeHintEnum - Column data type logical hint. +type ColumnDataTypeHintEnum string + +const ( + // ColumnDataTypeHintEnumArmPath - An Azure Resource Model (ARM) path: /subscriptions/{...}/resourceGroups/{...}/providers/Microsoft.{...}/{...}/{...}/{...}... + ColumnDataTypeHintEnumArmPath ColumnDataTypeHintEnum = "armPath" + // ColumnDataTypeHintEnumGUID - A standard 128-bit GUID following the standard shape, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + ColumnDataTypeHintEnumGUID ColumnDataTypeHintEnum = "guid" + // ColumnDataTypeHintEnumIP - A standard V4/V6 ip address following the standard shape, x.x.x.x/y:y:y:y:y:y:y:y + ColumnDataTypeHintEnumIP ColumnDataTypeHintEnum = "ip" + // ColumnDataTypeHintEnumURI - A string that matches the pattern of a URI, for example, scheme://username:password@host:1234/this/is/a/path?k1=v1&k2=v2#fragment + ColumnDataTypeHintEnumURI ColumnDataTypeHintEnum = "uri" +) + +// PossibleColumnDataTypeHintEnumValues returns the possible values for the ColumnDataTypeHintEnum const type. +func PossibleColumnDataTypeHintEnumValues() []ColumnDataTypeHintEnum { + return []ColumnDataTypeHintEnum{ + ColumnDataTypeHintEnumArmPath, + ColumnDataTypeHintEnumGUID, + ColumnDataTypeHintEnumIP, + ColumnDataTypeHintEnumURI, + } +} + +// ColumnTypeEnum - Column data type. +type ColumnTypeEnum string + +const ( + ColumnTypeEnumBoolean ColumnTypeEnum = "boolean" + ColumnTypeEnumDateTime ColumnTypeEnum = "dateTime" + ColumnTypeEnumDynamic ColumnTypeEnum = "dynamic" + ColumnTypeEnumGUID ColumnTypeEnum = "guid" + ColumnTypeEnumInt ColumnTypeEnum = "int" + ColumnTypeEnumLong ColumnTypeEnum = "long" + ColumnTypeEnumReal ColumnTypeEnum = "real" + ColumnTypeEnumString ColumnTypeEnum = "string" +) + +// PossibleColumnTypeEnumValues returns the possible values for the ColumnTypeEnum const type. +func PossibleColumnTypeEnumValues() []ColumnTypeEnum { + return []ColumnTypeEnum{ + ColumnTypeEnumBoolean, + ColumnTypeEnumDateTime, + ColumnTypeEnumDynamic, + ColumnTypeEnumGUID, + ColumnTypeEnumInt, + ColumnTypeEnumLong, + ColumnTypeEnumReal, + ColumnTypeEnumString, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + // DataIngestionStatus - The status of data ingestion for this workspace. type DataIngestionStatus string @@ -234,6 +306,7 @@ const ( DataSourceTypeAlerts DataSourceType = "Alerts" DataSourceTypeAzureWatson DataSourceType = "AzureWatson" DataSourceTypeCustomLogs DataSourceType = "CustomLogs" + DataSourceTypeIngestion DataSourceType = "Ingestion" DataSourceTypeQuery DataSourceType = "Query" ) @@ -243,24 +316,33 @@ func PossibleDataSourceTypeValues() []DataSourceType { DataSourceTypeAlerts, DataSourceTypeAzureWatson, DataSourceTypeCustomLogs, + DataSourceTypeIngestion, DataSourceTypeQuery, } } -// IdentityType - Type of managed service identity. +// IdentityType - The type of identity that creates/modifies resources type IdentityType string const ( - IdentityTypeNone IdentityType = "None" - IdentityTypeSystemAssigned IdentityType = "SystemAssigned" - IdentityTypeUserAssigned IdentityType = "UserAssigned" + IdentityTypeApplication IdentityType = "application" + IdentityTypeKey IdentityType = "key" + IdentityTypeManagedIdentity IdentityType = "managedIdentity" + IdentityTypeNone IdentityType = "None" + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + IdentityTypeUser IdentityType = "user" + IdentityTypeUserAssigned IdentityType = "UserAssigned" ) // PossibleIdentityTypeValues returns the possible values for the IdentityType const type. func PossibleIdentityTypeValues() []IdentityType { return []IdentityType{ + IdentityTypeApplication, + IdentityTypeKey, + IdentityTypeManagedIdentity, IdentityTypeNone, IdentityTypeSystemAssigned, + IdentityTypeUser, IdentityTypeUserAssigned, } } @@ -285,6 +367,29 @@ func PossibleLinkedServiceEntityStatusValues() []LinkedServiceEntityStatus { } } +// ProvisioningStateEnum - Table's current provisioning state. If set to 'updating', indicates a resource lock due to ongoing +// operation, forbidding any update to the table until the ongoing operation is concluded. +type ProvisioningStateEnum string + +const ( + // ProvisioningStateEnumInProgress - Table schema is stable and without changes, table data is being updated. + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + // ProvisioningStateEnumSucceeded - Table state is stable and without changes, table is unlocked and open for new updates. + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" + // ProvisioningStateEnumUpdating - Table schema is still being built and updated, table is currently locked for any changes + // till the procedure is done. + ProvisioningStateEnumUpdating ProvisioningStateEnum = "Updating" +) + +// PossibleProvisioningStateEnumValues returns the possible values for the ProvisioningStateEnum const type. +func PossibleProvisioningStateEnumValues() []ProvisioningStateEnum { + return []ProvisioningStateEnum{ + ProvisioningStateEnumInProgress, + ProvisioningStateEnumSucceeded, + ProvisioningStateEnumUpdating, + } +} + // PublicNetworkAccessType - The network access type for operating on the Log Analytics Workspace. By default it is Enabled type PublicNetworkAccessType string @@ -361,6 +466,25 @@ func PossibleSearchSortEnumValues() []SearchSortEnum { } } +// SourceEnum - Table's creator. +type SourceEnum string + +const ( + // SourceEnumCustomer - Tables created by the owner of the Workspace, and only found in this Workspace. + SourceEnumCustomer SourceEnum = "customer" + // SourceEnumMicrosoft - Tables provisioned by the system, as collected via Diagnostic Settings, the Agents, or any other + // standard data collection means. + SourceEnumMicrosoft SourceEnum = "microsoft" +) + +// PossibleSourceEnumValues returns the possible values for the SourceEnum const type. +func PossibleSourceEnumValues() []SourceEnum { + return []SourceEnum{ + SourceEnumCustomer, + SourceEnumMicrosoft, + } +} + // StorageInsightState - The state of the storage insight connection to the workspace type StorageInsightState string @@ -377,6 +501,73 @@ func PossibleStorageInsightStateValues() []StorageInsightState { } } +// TablePlanEnum - Instruct the system how to handle and charge the logs ingested to this table. +type TablePlanEnum string + +const ( + // TablePlanEnumAnalytics - Logs that allow monitoring and analytics. + TablePlanEnumAnalytics TablePlanEnum = "Analytics" + // TablePlanEnumBasic - Logs that are adjusted to support high volume low value verbose logs. + TablePlanEnumBasic TablePlanEnum = "Basic" +) + +// PossibleTablePlanEnumValues returns the possible values for the TablePlanEnum const type. +func PossibleTablePlanEnumValues() []TablePlanEnum { + return []TablePlanEnum{ + TablePlanEnumAnalytics, + TablePlanEnumBasic, + } +} + +// TableSubTypeEnum - The subtype describes what APIs can be used to interact with the table, and what features are available +// against it. +type TableSubTypeEnum string + +const ( + // TableSubTypeEnumAny - The default subtype with which built-in tables are created. + TableSubTypeEnumAny TableSubTypeEnum = "Any" + // TableSubTypeEnumClassic - Indicates a table created through the Data Collector API or with the custom logs feature of the + // MMA agent, or any table against which Custom Fields were created. + TableSubTypeEnumClassic TableSubTypeEnum = "Classic" + // TableSubTypeEnumDataCollectionRuleBased - A table eligible to have data sent into it via any of the means supported by + // Data Collection Rules: the Data Collection Endpoint API, ingestion-time transformations, or any other mechanism provided + // by Data Collection Rules + TableSubTypeEnumDataCollectionRuleBased TableSubTypeEnum = "DataCollectionRuleBased" +) + +// PossibleTableSubTypeEnumValues returns the possible values for the TableSubTypeEnum const type. +func PossibleTableSubTypeEnumValues() []TableSubTypeEnum { + return []TableSubTypeEnum{ + TableSubTypeEnumAny, + TableSubTypeEnumClassic, + TableSubTypeEnumDataCollectionRuleBased, + } +} + +// TableTypeEnum - Table's creator. +type TableTypeEnum string + +const ( + // TableTypeEnumCustomLog - Custom log table. + TableTypeEnumCustomLog TableTypeEnum = "CustomLog" + // TableTypeEnumMicrosoft - Standard data collected by Azure Monitor. + TableTypeEnumMicrosoft TableTypeEnum = "Microsoft" + // TableTypeEnumRestoredLogs - Restored data. + TableTypeEnumRestoredLogs TableTypeEnum = "RestoredLogs" + // TableTypeEnumSearchResults - Data collected by a search job. + TableTypeEnumSearchResults TableTypeEnum = "SearchResults" +) + +// PossibleTableTypeEnumValues returns the possible values for the TableTypeEnum const type. +func PossibleTableTypeEnumValues() []TableTypeEnum { + return []TableTypeEnum{ + TableTypeEnumCustomLog, + TableTypeEnumMicrosoft, + TableTypeEnumRestoredLogs, + TableTypeEnumSearchResults, + } +} + // Type - The type of the destination resource type Type string diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/dataexports_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/dataexports_client_example_test.go index 3d90fb349c5a..54fafba50429 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/dataexports_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/dataexports_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportListByWorkspace.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportListByWorkspace.json func ExampleDataExportsClient_NewListByWorkspacePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -63,7 +63,7 @@ func ExampleDataExportsClient_NewListByWorkspacePager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportCreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportCreateOrUpdate.json func ExampleDataExportsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -108,7 +108,7 @@ func ExampleDataExportsClient_CreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportGet.json func ExampleDataExportsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -145,7 +145,7 @@ func ExampleDataExportsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportDelete.json func ExampleDataExportsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/dataexports_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/dataexports_live_test.go index 91d1dec63659..c66812eb8de5 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/dataexports_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/dataexports_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/datasources_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/datasources_client_example_test.go index b85a99e1cbef..bdada8921b82 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/datasources_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/datasources_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesCreate.json func ExampleDataSourcesClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -53,7 +53,7 @@ func ExampleDataSourcesClient_CreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesDelete.json func ExampleDataSourcesClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -70,7 +70,7 @@ func ExampleDataSourcesClient_Delete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesGet.json func ExampleDataSourcesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -100,7 +100,7 @@ func ExampleDataSourcesClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesListByWorkspace.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesListByWorkspace.json func ExampleDataSourcesClient_NewListByWorkspacePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/datasources_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/datasources_live_test.go index 2b893b2c40a9..a6aa3c588491 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/datasources_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/datasources_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/deletedworkspaces_client.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/deletedworkspaces_client.go index 7442582128f3..f986ec19c578 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/deletedworkspaces_client.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/deletedworkspaces_client.go @@ -45,7 +45,7 @@ func NewDeletedWorkspacesClient(subscriptionID string, credential azcore.TokenCr // NewListPager - Gets recently deleted workspaces in a subscription, available for recovery. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview // - options - DeletedWorkspacesClientListOptions contains the optional parameters for the DeletedWorkspacesClient.NewListPager // method. func (client *DeletedWorkspacesClient) NewListPager(options *DeletedWorkspacesClientListOptions) *runtime.Pager[DeletedWorkspacesClientListResponse] { @@ -84,7 +84,7 @@ func (client *DeletedWorkspacesClient) listCreateRequest(ctx context.Context, op return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -101,7 +101,7 @@ func (client *DeletedWorkspacesClient) listHandleResponse(resp *http.Response) ( // NewListByResourceGroupPager - Gets recently deleted workspaces in a resource group, available for recovery. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - DeletedWorkspacesClientListByResourceGroupOptions contains the optional parameters for the DeletedWorkspacesClient.NewListByResourceGroupPager // method. @@ -145,7 +145,7 @@ func (client *DeletedWorkspacesClient) listByResourceGroupCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/deletedworkspaces_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/deletedworkspaces_client_example_test.go index 3b8cf7e42f6c..ccfb1fd2768d 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/deletedworkspaces_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/deletedworkspaces_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/WorkspacesSubscriptionList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/WorkspacesSubscriptionList.json func ExampleDeletedWorkspacesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -64,7 +64,7 @@ func ExampleDeletedWorkspacesClient_NewListPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/WorkspacesListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/WorkspacesListByResourceGroup.json func ExampleDeletedWorkspacesClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/availableservicetiers_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/availableservicetiers_server.go index 0f3f52c71455..4a4fbc5b23ee 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/availableservicetiers_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/availableservicetiers_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/clusters_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/clusters_server.go index fd0ae82150a5..69b726aae65f 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/clusters_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/clusters_server.go @@ -16,7 +16,7 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" @@ -45,7 +45,7 @@ type ClustersServer struct { NewListByResourceGroupPager func(resourceGroupName string, options *armoperationalinsights.ClustersClientListByResourceGroupOptions) (resp azfake.PagerResponder[armoperationalinsights.ClustersClientListByResourceGroupResponse]) // BeginUpdate is the fake for method ClustersClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted BeginUpdate func(ctx context.Context, resourceGroupName string, clusterName string, parameters armoperationalinsights.ClusterPatch, options *armoperationalinsights.ClustersClientBeginUpdateOptions) (resp azfake.PollerResponder[armoperationalinsights.ClustersClientUpdateResponse], errResp azfake.ErrorResponder) } @@ -341,9 +341,9 @@ func (c *ClustersServerTransport) dispatchBeginUpdate(req *http.Request) (*http. return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { c.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { c.beginUpdate.remove(req) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/dataexports_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/dataexports_server.go index f26fbb32404f..6eadf7f5a8d1 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/dataexports_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/dataexports_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/datasources_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/datasources_server.go index 1b3ecf5bd7b0..09b46a52d08e 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/datasources_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/datasources_server.go @@ -16,7 +16,7 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/deletedworkspaces_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/deletedworkspaces_server.go index a654f9c1e18f..09d9a77b2682 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/deletedworkspaces_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/deletedworkspaces_server.go @@ -14,7 +14,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/gateways_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/gateways_server.go index 7f95535a02bb..45cd5e66cad2 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/gateways_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/gateways_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/intelligencepacks_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/intelligencepacks_server.go index 2d0237c28892..8a64b3ca2c56 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/intelligencepacks_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/intelligencepacks_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/linkedservices_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/linkedservices_server.go index dd882fddf252..b9b9348abe0e 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/linkedservices_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/linkedservices_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/linkedstorageaccounts_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/linkedstorageaccounts_server.go index 79c8cb264cc0..4e4474968f3b 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/linkedstorageaccounts_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/linkedstorageaccounts_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/managementgroups_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/managementgroups_server.go index bc5e5c8a21ce..5b03cd83cc0f 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/managementgroups_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/managementgroups_server.go @@ -14,7 +14,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/operations_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/operations_server.go index 677edaa448d6..4a81c9b795a6 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/operations_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/operations_server.go @@ -15,7 +15,7 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/operationstatuses_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/operationstatuses_server.go index bd1ffcaa179b..c1ccd2c6cdab 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/operationstatuses_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/operationstatuses_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/queries_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/queries_server.go new file mode 100644 index 000000000000..6d71383b8742 --- /dev/null +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/queries_server.go @@ -0,0 +1,419 @@ +//go:build go1.18 +// +build go1.18 + +// 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 ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// QueriesServer is a fake server for instances of the armoperationalinsights.QueriesClient type. +type QueriesServer struct { + // Delete is the fake for method QueriesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, queryPackName string, id string, options *armoperationalinsights.QueriesClientDeleteOptions) (resp azfake.Responder[armoperationalinsights.QueriesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method QueriesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, queryPackName string, id string, options *armoperationalinsights.QueriesClientGetOptions) (resp azfake.Responder[armoperationalinsights.QueriesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method QueriesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, queryPackName string, options *armoperationalinsights.QueriesClientListOptions) (resp azfake.PagerResponder[armoperationalinsights.QueriesClientListResponse]) + + // Put is the fake for method QueriesClient.Put + // HTTP status codes to indicate success: http.StatusOK + Put func(ctx context.Context, resourceGroupName string, queryPackName string, id string, queryPayload armoperationalinsights.LogAnalyticsQueryPackQuery, options *armoperationalinsights.QueriesClientPutOptions) (resp azfake.Responder[armoperationalinsights.QueriesClientPutResponse], errResp azfake.ErrorResponder) + + // NewSearchPager is the fake for method QueriesClient.NewSearchPager + // HTTP status codes to indicate success: http.StatusOK + NewSearchPager func(resourceGroupName string, queryPackName string, querySearchProperties armoperationalinsights.LogAnalyticsQueryPackQuerySearchProperties, options *armoperationalinsights.QueriesClientSearchOptions) (resp azfake.PagerResponder[armoperationalinsights.QueriesClientSearchResponse]) + + // Update is the fake for method QueriesClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, queryPackName string, id string, queryPayload armoperationalinsights.LogAnalyticsQueryPackQuery, options *armoperationalinsights.QueriesClientUpdateOptions) (resp azfake.Responder[armoperationalinsights.QueriesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewQueriesServerTransport creates a new instance of QueriesServerTransport with the provided implementation. +// The returned QueriesServerTransport instance is connected to an instance of armoperationalinsights.QueriesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewQueriesServerTransport(srv *QueriesServer) *QueriesServerTransport { + return &QueriesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armoperationalinsights.QueriesClientListResponse]](), + newSearchPager: newTracker[azfake.PagerResponder[armoperationalinsights.QueriesClientSearchResponse]](), + } +} + +// QueriesServerTransport connects instances of armoperationalinsights.QueriesClient to instances of QueriesServer. +// Don't use this type directly, use NewQueriesServerTransport instead. +type QueriesServerTransport struct { + srv *QueriesServer + newListPager *tracker[azfake.PagerResponder[armoperationalinsights.QueriesClientListResponse]] + newSearchPager *tracker[azfake.PagerResponder[armoperationalinsights.QueriesClientSearchResponse]] +} + +// Do implements the policy.Transporter interface for QueriesServerTransport. +func (q *QueriesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "QueriesClient.Delete": + resp, err = q.dispatchDelete(req) + case "QueriesClient.Get": + resp, err = q.dispatchGet(req) + case "QueriesClient.NewListPager": + resp, err = q.dispatchNewListPager(req) + case "QueriesClient.Put": + resp, err = q.dispatchPut(req) + case "QueriesClient.NewSearchPager": + resp, err = q.dispatchNewSearchPager(req) + case "QueriesClient.Update": + resp, err = q.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (q *QueriesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if q.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\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Delete(req.Context(), resourceGroupNameParam, queryPackNameParam, idParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !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) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueriesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if q.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\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Get(req.Context(), resourceGroupNameParam, queryPackNameParam, idParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LogAnalyticsQueryPackQuery, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueriesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if q.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := q.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queries` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + includeBodyUnescaped, err := url.QueryUnescape(qp.Get("includeBody")) + if err != nil { + return nil, err + } + includeBodyParam, err := parseOptional(includeBodyUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + var options *armoperationalinsights.QueriesClientListOptions + if topParam != nil || includeBodyParam != nil || skipTokenParam != nil { + options = &armoperationalinsights.QueriesClientListOptions{ + Top: topParam, + IncludeBody: includeBodyParam, + SkipToken: skipTokenParam, + } + } + resp := q.srv.NewListPager(resourceGroupNameParam, queryPackNameParam, options) + newListPager = &resp + q.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armoperationalinsights.QueriesClientListResponse, 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) { + q.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + q.newListPager.remove(req) + } + return resp, nil +} + +func (q *QueriesServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { + if q.srv.Put == nil { + return nil, &nonRetriableError{errors.New("fake for method Put not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.LogAnalyticsQueryPackQuery](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Put(req.Context(), resourceGroupNameParam, queryPackNameParam, idParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LogAnalyticsQueryPackQuery, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueriesServerTransport) dispatchNewSearchPager(req *http.Request) (*http.Response, error) { + if q.srv.NewSearchPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewSearchPager not implemented")} + } + newSearchPager := q.newSearchPager.get(req) + if newSearchPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queries/search` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.LogAnalyticsQueryPackQuerySearchProperties](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int64, error) { + p, parseErr := strconv.ParseInt(v, 10, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } + includeBodyUnescaped, err := url.QueryUnescape(qp.Get("includeBody")) + if err != nil { + return nil, err + } + includeBodyParam, err := parseOptional(includeBodyUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + var options *armoperationalinsights.QueriesClientSearchOptions + if topParam != nil || includeBodyParam != nil || skipTokenParam != nil { + options = &armoperationalinsights.QueriesClientSearchOptions{ + Top: topParam, + IncludeBody: includeBodyParam, + SkipToken: skipTokenParam, + } + } + resp := q.srv.NewSearchPager(resourceGroupNameParam, queryPackNameParam, body, options) + newSearchPager = &resp + q.newSearchPager.add(req, newSearchPager) + server.PagerResponderInjectNextLinks(newSearchPager, req, func(page *armoperationalinsights.QueriesClientSearchResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newSearchPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + q.newSearchPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newSearchPager) { + q.newSearchPager.remove(req) + } + return resp, nil +} + +func (q *QueriesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if q.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\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.LogAnalyticsQueryPackQuery](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Update(req.Context(), resourceGroupNameParam, queryPackNameParam, idParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LogAnalyticsQueryPackQuery, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/querypacks_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/querypacks_server.go new file mode 100644 index 000000000000..025629751d9f --- /dev/null +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/querypacks_server.go @@ -0,0 +1,353 @@ +//go:build go1.18 +// +build go1.18 + +// 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 ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" + "net/http" + "net/url" + "regexp" +) + +// QueryPacksServer is a fake server for instances of the armoperationalinsights.QueryPacksClient type. +type QueryPacksServer struct { + // CreateOrUpdate is the fake for method QueryPacksClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, queryPackName string, logAnalyticsQueryPackPayload armoperationalinsights.LogAnalyticsQueryPack, options *armoperationalinsights.QueryPacksClientCreateOrUpdateOptions) (resp azfake.Responder[armoperationalinsights.QueryPacksClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdateWithoutName is the fake for method QueryPacksClient.CreateOrUpdateWithoutName + // HTTP status codes to indicate success: http.StatusCreated + CreateOrUpdateWithoutName func(ctx context.Context, resourceGroupName string, logAnalyticsQueryPackPayload armoperationalinsights.LogAnalyticsQueryPack, options *armoperationalinsights.QueryPacksClientCreateOrUpdateWithoutNameOptions) (resp azfake.Responder[armoperationalinsights.QueryPacksClientCreateOrUpdateWithoutNameResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method QueryPacksClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, queryPackName string, options *armoperationalinsights.QueryPacksClientDeleteOptions) (resp azfake.Responder[armoperationalinsights.QueryPacksClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method QueryPacksClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, queryPackName string, options *armoperationalinsights.QueryPacksClientGetOptions) (resp azfake.Responder[armoperationalinsights.QueryPacksClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method QueryPacksClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armoperationalinsights.QueryPacksClientListOptions) (resp azfake.PagerResponder[armoperationalinsights.QueryPacksClientListResponse]) + + // NewListByResourceGroupPager is the fake for method QueryPacksClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armoperationalinsights.QueryPacksClientListByResourceGroupOptions) (resp azfake.PagerResponder[armoperationalinsights.QueryPacksClientListByResourceGroupResponse]) + + // UpdateTags is the fake for method QueryPacksClient.UpdateTags + // HTTP status codes to indicate success: http.StatusOK + UpdateTags func(ctx context.Context, resourceGroupName string, queryPackName string, queryPackTags armoperationalinsights.TagsResource, options *armoperationalinsights.QueryPacksClientUpdateTagsOptions) (resp azfake.Responder[armoperationalinsights.QueryPacksClientUpdateTagsResponse], errResp azfake.ErrorResponder) +} + +// NewQueryPacksServerTransport creates a new instance of QueryPacksServerTransport with the provided implementation. +// The returned QueryPacksServerTransport instance is connected to an instance of armoperationalinsights.QueryPacksClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewQueryPacksServerTransport(srv *QueryPacksServer) *QueryPacksServerTransport { + return &QueryPacksServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armoperationalinsights.QueryPacksClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armoperationalinsights.QueryPacksClientListByResourceGroupResponse]](), + } +} + +// QueryPacksServerTransport connects instances of armoperationalinsights.QueryPacksClient to instances of QueryPacksServer. +// Don't use this type directly, use NewQueryPacksServerTransport instead. +type QueryPacksServerTransport struct { + srv *QueryPacksServer + newListPager *tracker[azfake.PagerResponder[armoperationalinsights.QueryPacksClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armoperationalinsights.QueryPacksClientListByResourceGroupResponse]] +} + +// Do implements the policy.Transporter interface for QueryPacksServerTransport. +func (q *QueryPacksServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "QueryPacksClient.CreateOrUpdate": + resp, err = q.dispatchCreateOrUpdate(req) + case "QueryPacksClient.CreateOrUpdateWithoutName": + resp, err = q.dispatchCreateOrUpdateWithoutName(req) + case "QueryPacksClient.Delete": + resp, err = q.dispatchDelete(req) + case "QueryPacksClient.Get": + resp, err = q.dispatchGet(req) + case "QueryPacksClient.NewListPager": + resp, err = q.dispatchNewListPager(req) + case "QueryPacksClient.NewListByResourceGroupPager": + resp, err = q.dispatchNewListByResourceGroupPager(req) + case "QueryPacksClient.UpdateTags": + resp, err = q.dispatchUpdateTags(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (q *QueryPacksServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if q.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.LogAnalyticsQueryPack](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, queryPackNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LogAnalyticsQueryPack, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueryPacksServerTransport) dispatchCreateOrUpdateWithoutName(req *http.Request) (*http.Response, error) { + if q.srv.CreateOrUpdateWithoutName == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateWithoutName not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/queryPacks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.LogAnalyticsQueryPack](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.CreateOrUpdateWithoutName(req.Context(), resourceGroupNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LogAnalyticsQueryPack, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueryPacksServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if q.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\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Delete(req.Context(), resourceGroupNameParam, queryPackNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !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) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueryPacksServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if q.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\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Get(req.Context(), resourceGroupNameParam, queryPackNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LogAnalyticsQueryPack, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueryPacksServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if q.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := q.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/queryPacks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := q.srv.NewListPager(nil) + newListPager = &resp + q.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armoperationalinsights.QueryPacksClientListResponse, 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) { + q.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + q.newListPager.remove(req) + } + return resp, nil +} + +func (q *QueryPacksServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if q.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := q.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/queryPacks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := q.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + q.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armoperationalinsights.QueryPacksClientListByResourceGroupResponse, 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) { + q.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + q.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (q *QueryPacksServerTransport) dispatchUpdateTags(req *http.Request) (*http.Response, error) { + if q.srv.UpdateTags == nil { + return nil, &nonRetriableError{errors.New("fake for method UpdateTags not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/queryPacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.TagsResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + queryPackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("queryPackName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.UpdateTags(req.Context(), resourceGroupNameParam, queryPackNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LogAnalyticsQueryPack, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/savedsearches_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/savedsearches_server.go index ea8e461276cc..c8213d338581 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/savedsearches_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/savedsearches_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/schema_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/schema_server.go index 9f45d07acae7..9c913d4cdd32 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/schema_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/schema_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/server_factory.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/server_factory.go index 97bfc2484c9a..92412d8a6cbe 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/server_factory.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/server_factory.go @@ -31,6 +31,8 @@ type ServerFactory struct { ManagementGroupsServer ManagementGroupsServer OperationStatusesServer OperationStatusesServer OperationsServer OperationsServer + QueriesServer QueriesServer + QueryPacksServer QueryPacksServer SavedSearchesServer SavedSearchesServer SchemaServer SchemaServer SharedKeysServer SharedKeysServer @@ -67,6 +69,8 @@ type ServerFactoryTransport struct { trManagementGroupsServer *ManagementGroupsServerTransport trOperationStatusesServer *OperationStatusesServerTransport trOperationsServer *OperationsServerTransport + trQueriesServer *QueriesServerTransport + trQueryPacksServer *QueryPacksServerTransport trSavedSearchesServer *SavedSearchesServerTransport trSchemaServer *SchemaServerTransport trSharedKeysServer *SharedKeysServerTransport @@ -140,6 +144,12 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) + case "QueriesClient": + initServer(s, &s.trQueriesServer, func() *QueriesServerTransport { return NewQueriesServerTransport(&s.srv.QueriesServer) }) + resp, err = s.trQueriesServer.Do(req) + case "QueryPacksClient": + initServer(s, &s.trQueryPacksServer, func() *QueryPacksServerTransport { return NewQueryPacksServerTransport(&s.srv.QueryPacksServer) }) + resp, err = s.trQueryPacksServer.Do(req) case "SavedSearchesClient": initServer(s, &s.trSavedSearchesServer, func() *SavedSearchesServerTransport { return NewSavedSearchesServerTransport(&s.srv.SavedSearchesServer) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/sharedkeys_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/sharedkeys_server.go index b53bad299437..329a89fc0b77 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/sharedkeys_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/sharedkeys_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/storageinsightconfigs_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/storageinsightconfigs_server.go index e576cb4131d1..693b7f0ca573 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/storageinsightconfigs_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/storageinsightconfigs_server.go @@ -16,7 +16,7 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/tables_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/tables_server.go index 3a87f72e4b22..8440f5ca82f8 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/tables_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/tables_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" @@ -23,6 +23,14 @@ import ( // TablesServer is a fake server for instances of the armoperationalinsights.TablesClient type. type TablesServer struct { + // BeginCreateOrUpdate is the fake for method TablesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters armoperationalinsights.Table, options *armoperationalinsights.TablesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armoperationalinsights.TablesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method TablesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *armoperationalinsights.TablesClientBeginDeleteOptions) (resp azfake.PollerResponder[armoperationalinsights.TablesClientDeleteResponse], errResp azfake.ErrorResponder) + // Get is the fake for method TablesClient.Get // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *armoperationalinsights.TablesClientGetOptions) (resp azfake.Responder[armoperationalinsights.TablesClientGetResponse], errResp azfake.ErrorResponder) @@ -31,9 +39,13 @@ type TablesServer struct { // HTTP status codes to indicate success: http.StatusOK NewListByWorkspacePager func(resourceGroupName string, workspaceName string, options *armoperationalinsights.TablesClientListByWorkspaceOptions) (resp azfake.PagerResponder[armoperationalinsights.TablesClientListByWorkspaceResponse]) - // Update is the fake for method TablesClient.Update + // Migrate is the fake for method TablesClient.Migrate // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters armoperationalinsights.Table, options *armoperationalinsights.TablesClientUpdateOptions) (resp azfake.Responder[armoperationalinsights.TablesClientUpdateResponse], errResp azfake.ErrorResponder) + Migrate func(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *armoperationalinsights.TablesClientMigrateOptions) (resp azfake.Responder[armoperationalinsights.TablesClientMigrateResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method TablesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters armoperationalinsights.Table, options *armoperationalinsights.TablesClientBeginUpdateOptions) (resp azfake.PollerResponder[armoperationalinsights.TablesClientUpdateResponse], errResp azfake.ErrorResponder) } // NewTablesServerTransport creates a new instance of TablesServerTransport with the provided implementation. @@ -42,7 +54,10 @@ type TablesServer struct { func NewTablesServerTransport(srv *TablesServer) *TablesServerTransport { return &TablesServerTransport{ srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armoperationalinsights.TablesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armoperationalinsights.TablesClientDeleteResponse]](), newListByWorkspacePager: newTracker[azfake.PagerResponder[armoperationalinsights.TablesClientListByWorkspaceResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armoperationalinsights.TablesClientUpdateResponse]](), } } @@ -50,7 +65,10 @@ func NewTablesServerTransport(srv *TablesServer) *TablesServerTransport { // Don't use this type directly, use NewTablesServerTransport instead. type TablesServerTransport struct { srv *TablesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armoperationalinsights.TablesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armoperationalinsights.TablesClientDeleteResponse]] newListByWorkspacePager *tracker[azfake.PagerResponder[armoperationalinsights.TablesClientListByWorkspaceResponse]] + beginUpdate *tracker[azfake.PollerResponder[armoperationalinsights.TablesClientUpdateResponse]] } // Do implements the policy.Transporter interface for TablesServerTransport. @@ -65,12 +83,18 @@ func (t *TablesServerTransport) Do(req *http.Request) (*http.Response, error) { var err error switch method { + case "TablesClient.BeginCreateOrUpdate": + resp, err = t.dispatchBeginCreateOrUpdate(req) + case "TablesClient.BeginDelete": + resp, err = t.dispatchBeginDelete(req) case "TablesClient.Get": resp, err = t.dispatchGet(req) case "TablesClient.NewListByWorkspacePager": resp, err = t.dispatchNewListByWorkspacePager(req) - case "TablesClient.Update": - resp, err = t.dispatchUpdate(req) + case "TablesClient.Migrate": + resp, err = t.dispatchMigrate(req) + case "TablesClient.BeginUpdate": + resp, err = t.dispatchBeginUpdate(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -82,6 +106,106 @@ func (t *TablesServerTransport) Do(req *http.Request) (*http.Response, error) { return resp, nil } +func (t *TablesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if t.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := t.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.Table](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceName")]) + if err != nil { + return nil, err + } + tableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("tableName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, workspaceNameParam, tableNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + t.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + t.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + t.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (t *TablesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if t.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := t.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceName")]) + if err != nil { + return nil, err + } + tableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("tableName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginDelete(req.Context(), resourceGroupNameParam, workspaceNameParam, tableNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + t.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + t.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + t.beginDelete.remove(req) + } + + return resp, nil +} + func (t *TablesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if t.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} @@ -157,20 +281,16 @@ func (t *TablesServerTransport) dispatchNewListByWorkspacePager(req *http.Reques return resp, nil } -func (t *TablesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if t.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} +func (t *TablesServerTransport) dispatchMigrate(req *http.Request) (*http.Response, error) { + if t.srv.Migrate == nil { + return nil, &nonRetriableError{errors.New("fake for method Migrate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/migrate` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.Table](req) - if err != nil { - return nil, err - } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err @@ -183,7 +303,7 @@ func (t *TablesServerTransport) dispatchUpdate(req *http.Request) (*http.Respons if err != nil { return nil, err } - respr, errRespr := t.srv.Update(req.Context(), resourceGroupNameParam, workspaceNameParam, tableNameParam, body, nil) + respr, errRespr := t.srv.Migrate(req.Context(), resourceGroupNameParam, workspaceNameParam, tableNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -191,9 +311,61 @@ func (t *TablesServerTransport) dispatchUpdate(req *http.Request) (*http.Respons if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Table, req) + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TablesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if t.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := t.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.OperationalInsights/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armoperationalinsights.Table](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceName")]) + if err != nil { + return nil, err + } + tableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("tableName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), resourceGroupNameParam, workspaceNameParam, tableNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + t.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) if err != nil { return nil, err } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + t.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + t.beginUpdate.remove(req) + } + return resp, nil } diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/time_rfc3339.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/time_rfc3339.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // 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+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + 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 @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + 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 { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + 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)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { 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 @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/usages_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/usages_server.go index c14c97f2c5d2..10d7b17870e4 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/usages_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/usages_server.go @@ -14,7 +14,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/workspacepurge_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/workspacepurge_server.go index 55021ea77c7b..39477b1656be 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/workspacepurge_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/workspacepurge_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/workspaces_server.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/workspaces_server.go index 716688b6fc1b..c746bc503907 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/workspaces_server.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/fake/workspaces_server.go @@ -15,7 +15,7 @@ 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/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/gateways_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/gateways_client_example_test.go index 83aeb09b9c8d..820d7832a8bd 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/gateways_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/gateways_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesGatewaysDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesGatewaysDelete.json func ExampleGatewaysClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/go.mod b/sdk/resourcemanager/operationalinsights/armoperationalinsights/go.mod index 1278ab7639bf..47a9912f2ec3 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/go.mod +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/go.mod @@ -1,4 +1,4 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2 go 1.18 diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/intelligencepacks_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/intelligencepacks_client_example_test.go index 1c3a7b8ae75a..9cea686cb450 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/intelligencepacks_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/intelligencepacks_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesDisableIntelligencePack.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesDisableIntelligencePack.json func ExampleIntelligencePacksClient_Disable() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -34,7 +34,7 @@ func ExampleIntelligencePacksClient_Disable() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesEnableIntelligencePack.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesEnableIntelligencePack.json func ExampleIntelligencePacksClient_Enable() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -51,7 +51,7 @@ func ExampleIntelligencePacksClient_Enable() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesListIntelligencePacks.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesListIntelligencePacks.json func ExampleIntelligencePacksClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/intelligencepacks_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/intelligencepacks_live_test.go index 0fe67bb9e8da..b6bc4905ab44 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/intelligencepacks_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/intelligencepacks_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedservices_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedservices_client_example_test.go index 6abffd238322..ad9496cdba6f 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedservices_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedservices_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesCreate.json func ExampleLinkedServicesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -55,7 +55,7 @@ func ExampleLinkedServicesClient_BeginCreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesDelete.json func ExampleLinkedServicesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -88,7 +88,7 @@ func ExampleLinkedServicesClient_BeginDelete() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesGet.json func ExampleLinkedServicesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -117,7 +117,7 @@ func ExampleLinkedServicesClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesListByWorkspace.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesListByWorkspace.json func ExampleLinkedServicesClient_NewListByWorkspacePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedservices_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedservices_live_test.go index 0e77afbe6fb6..8efc9ddeae01 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedservices_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedservices_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedstorageaccounts_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedstorageaccounts_client_example_test.go index 1c5b36062583..a5ac3681a17b 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedstorageaccounts_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedstorageaccounts_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsCreate.json func ExampleLinkedStorageAccountsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -55,7 +55,7 @@ func ExampleLinkedStorageAccountsClient_CreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsDelete.json func ExampleLinkedStorageAccountsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -72,7 +72,7 @@ func ExampleLinkedStorageAccountsClient_Delete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsGet.json func ExampleLinkedStorageAccountsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -103,7 +103,7 @@ func ExampleLinkedStorageAccountsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsListByWorkspace.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsListByWorkspace.json func ExampleLinkedStorageAccountsClient_NewListByWorkspacePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedstorageaccounts_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedstorageaccounts_live_test.go index e54db4e8ea06..4acdaaafbbec 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedstorageaccounts_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/linkedstorageaccounts_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/managementgroups_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/managementgroups_client_example_test.go index 7a5113af7a90..d6389a95f654 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/managementgroups_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/managementgroups_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesListManagementGroups.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesListManagementGroups.json func ExampleManagementGroupsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/models.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/models.go index d05f3ea3ad2e..55404d79a51b 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/models.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/models.go @@ -64,6 +64,21 @@ type AzureEntityResource struct { Type *string } +// AzureResourceProperties - An Azure resource QueryPack-Query object +type AzureResourceProperties struct { + // READ-ONLY; Azure resource Id + ID *string + + // READ-ONLY; Azure resource name + Name *string + + // READ-ONLY; Read only system data + SystemData *SystemData + + // READ-ONLY; Azure resource type + Type *string +} + // CapacityReservationProperties - The Capacity Reservation properties. type CapacityReservationProperties struct { // READ-ONLY; The last time Sku was updated. @@ -178,6 +193,30 @@ type ClusterSKU struct { Name *ClusterSKUNameEnum } +// Column - Table column. +type Column struct { + // Column data type logical hint. + DataTypeHint *ColumnDataTypeHintEnum + + // Column description. + Description *string + + // Column display name. + DisplayName *string + + // Column name. + Name *string + + // Column data type. + Type *ColumnTypeEnum + + // READ-ONLY; Is displayed by default. + IsDefaultDisplay *bool + + // READ-ONLY; Is column hidden. + IsHidden *bool +} + // CoreSummary - The core summary of a search. type CoreSummary struct { // REQUIRED; The number of documents of a core summary. @@ -432,6 +471,148 @@ type LinkedStorageAccountsResource struct { Type *string } +// LogAnalyticsQueryPack - An Log Analytics QueryPack definition. +type LogAnalyticsQueryPack struct { + // REQUIRED; Resource location + Location *string + + // REQUIRED; Properties that define a Log Analytics QueryPack resource. + Properties *LogAnalyticsQueryPackProperties + + // 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 +} + +// LogAnalyticsQueryPackListResult - Describes the list of Log Analytics QueryPack resources. +type LogAnalyticsQueryPackListResult struct { + // REQUIRED; List of Log Analytics QueryPack definitions. + Value []*LogAnalyticsQueryPack + + // The URI to get the next set of Log Analytics QueryPack definitions if too many QueryPacks where returned in the result + // set. + NextLink *string +} + +// LogAnalyticsQueryPackProperties - Properties that define a Log Analytics QueryPack resource. +type LogAnalyticsQueryPackProperties struct { + // READ-ONLY; Current state of this QueryPack: 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. + ProvisioningState *string + + // READ-ONLY; The unique ID of your application. This field cannot be changed. + QueryPackID *string + + // READ-ONLY; Creation Date for the Log Analytics QueryPack, in ISO 8601 format. + TimeCreated *time.Time + + // READ-ONLY; Last modified date of the Log Analytics QueryPack, in ISO 8601 format. + TimeModified *time.Time +} + +// LogAnalyticsQueryPackQuery - A Log Analytics QueryPack-Query definition. +type LogAnalyticsQueryPackQuery struct { + // Properties that define an Log Analytics QueryPack-Query resource. + Properties *LogAnalyticsQueryPackQueryProperties + + // READ-ONLY; Azure resource Id + ID *string + + // READ-ONLY; Azure resource name + Name *string + + // READ-ONLY; Read only system data + SystemData *SystemData + + // READ-ONLY; Azure resource type + Type *string +} + +// LogAnalyticsQueryPackQueryListResult - Describes the list of Log Analytics QueryPack-Query resources. +type LogAnalyticsQueryPackQueryListResult struct { + // REQUIRED; List of Log Analytics QueryPack Query definitions. + Value []*LogAnalyticsQueryPackQuery + + // The URI to get the next set of Log Analytics QueryPack definitions if too many QueryPack-Queries where returned in the + // result set. + NextLink *string +} + +// LogAnalyticsQueryPackQueryProperties - Properties that define an Log Analytics QueryPack-Query resource. +type LogAnalyticsQueryPackQueryProperties struct { + // REQUIRED; Body of the query. + Body *string + + // REQUIRED; Unique display name for your query within the Query Pack. + DisplayName *string + + // Description of the query. + Description *string + + // Additional properties that can be set for the query. + Properties any + + // The related metadata items for the function. + Related *LogAnalyticsQueryPackQueryPropertiesRelated + + // Tags associated with the query. + Tags map[string][]*string + + // READ-ONLY; Object Id of user creating the query. + Author *string + + // READ-ONLY; The unique ID of your application. This field cannot be changed. + ID *string + + // READ-ONLY; Creation Date for the Log Analytics Query, in ISO 8601 format. + TimeCreated *time.Time + + // READ-ONLY; Last modified date of the Log Analytics Query, in ISO 8601 format. + TimeModified *time.Time +} + +// LogAnalyticsQueryPackQueryPropertiesRelated - The related metadata items for the function. +type LogAnalyticsQueryPackQueryPropertiesRelated struct { + // The related categories for the function. + Categories []*string + + // The related resource types for the function. + ResourceTypes []*string + + // The related Log Analytics solutions for the function. + Solutions []*string +} + +// LogAnalyticsQueryPackQuerySearchProperties - Properties that define an Log Analytics QueryPack-Query search properties. +type LogAnalyticsQueryPackQuerySearchProperties struct { + // The related metadata items for the function. + Related *LogAnalyticsQueryPackQuerySearchPropertiesRelated + + // Tags associated with the query. + Tags map[string][]*string +} + +// LogAnalyticsQueryPackQuerySearchPropertiesRelated - The related metadata items for the function. +type LogAnalyticsQueryPackQuerySearchPropertiesRelated struct { + // The related categories for the function. + Categories []*string + + // The related resource types for the function. + ResourceTypes []*string + + // The related Log Analytics solutions for the function. + Solutions []*string +} + // ManagementGroup - A management group that is connected to a workspace type ManagementGroup struct { // The properties of the management group. @@ -550,6 +731,24 @@ type ProxyResource struct { Type *string } +// QueryPacksResource - An azure resource object +type QueryPacksResource 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 +} + // 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} @@ -562,6 +761,27 @@ type Resource struct { Type *string } +// RestoredLogs - Restore parameters. +type RestoredLogs struct { + // The timestamp to end the restore by (UTC). + EndRestoreTime *time.Time + + // The table to restore data from. + SourceTable *string + + // The timestamp to start the restore from (UTC). + StartRestoreTime *time.Time +} + +// ResultStatistics - Search job execution statistics. +type ResultStatistics struct { + // READ-ONLY; The number of rows that were returned by the search job. + IngestedRecords *int32 + + // READ-ONLY; Search job completion percentage. + Progress *float32 +} + // SavedSearch - Value object for saved search results. type SavedSearch struct { // REQUIRED; The properties of the saved search. @@ -612,6 +832,49 @@ type SavedSearchesListResult struct { Value []*SavedSearch } +// Schema - Table's schema. +type Schema struct { + // A list of table custom columns. + Columns []*Column + + // Table description. + Description *string + + // Table display name. + DisplayName *string + + // Table name. + Name *string + + // READ-ONLY; Table category. + Categories []*string + + // READ-ONLY; Table labels. + Labels []*string + + // READ-ONLY; Parameters of the restore operation that initiated this table. + RestoredLogs *RestoredLogs + + // READ-ONLY; Parameters of the search job that initiated this table. + SearchResults *SearchResults + + // READ-ONLY; List of solutions the table is affiliated with + Solutions []*string + + // READ-ONLY; Table's creator. + Source *SourceEnum + + // READ-ONLY; A list of table standard columns. + StandardColumns []*Column + + // READ-ONLY; The subtype describes what APIs can be used to interact with the table, and what features are available against + // it. + TableSubType *TableSubTypeEnum + + // READ-ONLY; Table's creator. + TableType *TableTypeEnum +} + // SearchGetSchemaResponse - The get schema operation response. type SearchGetSchemaResponse struct { // The metadata from search results. @@ -684,6 +947,27 @@ type SearchMetadataSchema struct { Version *int32 } +// SearchResults - Parameters of the search job that initiated this table. +type SearchResults struct { + // Search job Description. + Description *string + + // The timestamp to end the search by (UTC) + EndSearchTime *time.Time + + // Limit the search job to return up to specified number of rows. + Limit *int32 + + // Search job query. + Query *string + + // The timestamp to start the search from (UTC) + StartSearchTime *time.Time + + // READ-ONLY; The table used in the search job. + SourceTable *string +} + // SearchSchemaValue - Value object for schema results. type SearchSchemaValue struct { // REQUIRED; The boolean that indicates whether or not the field is a facet. @@ -789,9 +1073,51 @@ type StorageInsightStatus struct { Description *string } +// SystemData - Read only system data +type SystemData struct { + // The timestamp of resource creation (UTC) + CreatedAt *time.Time + + // An identifier for the identity that created the resource + CreatedBy *string + + // The type of identity that created the resource + CreatedByType *IdentityType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // An identifier for the identity that last modified the resource + LastModifiedBy *string + + // The type of identity that last modified the resource + LastModifiedByType *IdentityType +} + +// SystemDataAutoGenerated - Metadata pertaining to creation and last modification of the resource. +type SystemDataAutoGenerated struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + // Table - Workspace data table definition. type Table struct { - // Table properties. + // Table's properties. Properties *TableProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} @@ -800,15 +1126,45 @@ type Table struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemDataAutoGenerated + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } // TableProperties - Table properties. type TableProperties struct { - // The data table data retention in days, between 30 and 730. Setting this property to null will default to the workspace - // retention. + // Instruct the system how to handle and charge the logs ingested to this table. + Plan *TablePlanEnum + + // Parameters of the restore operation that initiated this table. + RestoredLogs *RestoredLogs + + // Search job execution statistics. + ResultStatistics *ResultStatistics + + // The table retention in days, between 4 and 730. Setting this property to -1 will default to the workspace retention. RetentionInDays *int32 + + // Table schema. + Schema *Schema + + // Parameters of the search job that initiated this table. + SearchResults *SearchResults + + // The table total retention in days, between 4 and 2555. Setting this property to -1 will default to table retention. + TotalRetentionInDays *int32 + + // READ-ONLY; The table data archive retention in days. Calculated as (totalRetentionInDays-retentionInDays) + ArchiveRetentionInDays *int32 + + // READ-ONLY; The timestamp that table plan was last modified (UTC). + LastPlanModifiedDate *string + + // READ-ONLY; Table's current provisioning state. If set to 'updating', indicates a resource lock due to ongoing operation, + // forbidding any update to the table until the ongoing operation is concluded. + ProvisioningState *ProvisioningStateEnum } // TablesListResult - The list tables operation response. @@ -826,6 +1182,12 @@ type Tag struct { Value *string } +// TagsResource - A container holding only the Tags for a resource, allowing the user to update the tags on a QueryPack instance. +type TagsResource struct { + // Resource tags + 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 { @@ -880,8 +1242,8 @@ type Workspace struct { // REQUIRED; The geo-location where the resource lives Location *string - // The etag of the workspace. - Etag *string + // The ETag of the workspace. + ETag *string // Workspace properties. Properties *WorkspaceProperties @@ -895,6 +1257,9 @@ type Workspace struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemDataAutoGenerated + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -973,15 +1338,16 @@ type WorkspacePatch struct { // WorkspaceProperties - Workspace properties. type WorkspaceProperties struct { + // The resource ID of the default Data Collection Rule to use for this workspace. Expected format is - + // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dcrName}. + DefaultDataCollectionRuleResourceID *string + // Workspace features. Features *WorkspaceFeatures // Indicates whether customer managed storage is mandatory for query management. ForceCmkForQuery *bool - // The provisioning state of the workspace. - ProvisioningState *WorkspaceEntityStatus - // The network access type for accessing Log Analytics ingestion. PublicNetworkAccessForIngestion *PublicNetworkAccessType @@ -1008,6 +1374,9 @@ type WorkspaceProperties struct { // READ-ONLY; List of linked private link scope resources. PrivateLinkScopedResources []*PrivateLinkScopedResource + + // READ-ONLY; The provisioning state of the workspace. + ProvisioningState *WorkspaceEntityStatus } // WorkspacePurgeBody - Describes the body of a purge request for an App Insights Workspace diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/models_serde.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/models_serde.go index f84d09a8f439..69f020a78776 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/models_serde.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/models_serde.go @@ -144,6 +144,45 @@ func (a *AzureEntityResource) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AzureResourceProperties. +func (a AzureResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureResourceProperties. +func (a *AzureResourceProperties) 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 "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + 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 CapacityReservationProperties. func (c CapacityReservationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -425,6 +464,57 @@ func (c *ClusterSKU) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Column. +func (c Column) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataTypeHint", c.DataTypeHint) + populate(objectMap, "description", c.Description) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "isDefaultDisplay", c.IsDefaultDisplay) + populate(objectMap, "isHidden", c.IsHidden) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Column. +func (c *Column) 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 "dataTypeHint": + err = unpopulate(val, "DataTypeHint", &c.DataTypeHint) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &c.DisplayName) + delete(rawMsg, key) + case "isDefaultDisplay": + err = unpopulate(val, "IsDefaultDisplay", &c.IsDefaultDisplay) + delete(rawMsg, key) + case "isHidden": + err = unpopulate(val, "IsHidden", &c.IsHidden) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + 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 CoreSummary. func (c CoreSummary) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1106,8 +1196,367 @@ func (l *LinkedStorageAccountsProperties) UnmarshalJSON(data []byte) error { case "dataSourceType": err = unpopulate(val, "DataSourceType", &l.DataSourceType) delete(rawMsg, key) - case "storageAccountIds": - err = unpopulate(val, "StorageAccountIDs", &l.StorageAccountIDs) + case "storageAccountIds": + err = unpopulate(val, "StorageAccountIDs", &l.StorageAccountIDs) + 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 LinkedStorageAccountsResource. +func (l LinkedStorageAccountsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkedStorageAccountsResource. +func (l *LinkedStorageAccountsResource) 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 "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + 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 LogAnalyticsQueryPack. +func (l LogAnalyticsQueryPack) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPack. +func (l *LogAnalyticsQueryPack) 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 "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &l.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &l.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + 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 LogAnalyticsQueryPackListResult. +func (l LogAnalyticsQueryPackListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPackListResult. +func (l *LogAnalyticsQueryPackListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + 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 LogAnalyticsQueryPackProperties. +func (l LogAnalyticsQueryPackProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "queryPackId", l.QueryPackID) + populateDateTimeRFC3339(objectMap, "timeCreated", l.TimeCreated) + populateDateTimeRFC3339(objectMap, "timeModified", l.TimeModified) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPackProperties. +func (l *LogAnalyticsQueryPackProperties) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + delete(rawMsg, key) + case "queryPackId": + err = unpopulate(val, "QueryPackID", &l.QueryPackID) + delete(rawMsg, key) + case "timeCreated": + err = unpopulateDateTimeRFC3339(val, "TimeCreated", &l.TimeCreated) + delete(rawMsg, key) + case "timeModified": + err = unpopulateDateTimeRFC3339(val, "TimeModified", &l.TimeModified) + 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 LogAnalyticsQueryPackQuery. +func (l LogAnalyticsQueryPackQuery) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPackQuery. +func (l *LogAnalyticsQueryPackQuery) 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 "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &l.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + 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 LogAnalyticsQueryPackQueryListResult. +func (l LogAnalyticsQueryPackQueryListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPackQueryListResult. +func (l *LogAnalyticsQueryPackQueryListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + 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 LogAnalyticsQueryPackQueryProperties. +func (l LogAnalyticsQueryPackQueryProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "author", l.Author) + populate(objectMap, "body", l.Body) + populate(objectMap, "description", l.Description) + populate(objectMap, "displayName", l.DisplayName) + populate(objectMap, "id", l.ID) + populateAny(objectMap, "properties", l.Properties) + populate(objectMap, "related", l.Related) + populate(objectMap, "tags", l.Tags) + populateDateTimeRFC3339(objectMap, "timeCreated", l.TimeCreated) + populateDateTimeRFC3339(objectMap, "timeModified", l.TimeModified) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPackQueryProperties. +func (l *LogAnalyticsQueryPackQueryProperties) 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 "author": + err = unpopulate(val, "Author", &l.Author) + delete(rawMsg, key) + case "body": + err = unpopulate(val, "Body", &l.Body) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &l.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &l.DisplayName) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "related": + err = unpopulate(val, "Related", &l.Related) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &l.Tags) + delete(rawMsg, key) + case "timeCreated": + err = unpopulateDateTimeRFC3339(val, "TimeCreated", &l.TimeCreated) + delete(rawMsg, key) + case "timeModified": + err = unpopulateDateTimeRFC3339(val, "TimeModified", &l.TimeModified) + 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 LogAnalyticsQueryPackQueryPropertiesRelated. +func (l LogAnalyticsQueryPackQueryPropertiesRelated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "categories", l.Categories) + populate(objectMap, "resourceTypes", l.ResourceTypes) + populate(objectMap, "solutions", l.Solutions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPackQueryPropertiesRelated. +func (l *LogAnalyticsQueryPackQueryPropertiesRelated) 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 "categories": + err = unpopulate(val, "Categories", &l.Categories) + delete(rawMsg, key) + case "resourceTypes": + err = unpopulate(val, "ResourceTypes", &l.ResourceTypes) + delete(rawMsg, key) + case "solutions": + err = unpopulate(val, "Solutions", &l.Solutions) + 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 LogAnalyticsQueryPackQuerySearchProperties. +func (l LogAnalyticsQueryPackQuerySearchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "related", l.Related) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPackQuerySearchProperties. +func (l *LogAnalyticsQueryPackQuerySearchProperties) 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 "related": + err = unpopulate(val, "Related", &l.Related) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &l.Tags) delete(rawMsg, key) } if err != nil { @@ -1117,18 +1566,17 @@ func (l *LinkedStorageAccountsProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type LinkedStorageAccountsResource. -func (l LinkedStorageAccountsResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type LogAnalyticsQueryPackQuerySearchPropertiesRelated. +func (l LogAnalyticsQueryPackQuerySearchPropertiesRelated) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", l.ID) - populate(objectMap, "name", l.Name) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "type", l.Type) + populate(objectMap, "categories", l.Categories) + populate(objectMap, "resourceTypes", l.ResourceTypes) + populate(objectMap, "solutions", l.Solutions) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type LinkedStorageAccountsResource. -func (l *LinkedStorageAccountsResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQueryPackQuerySearchPropertiesRelated. +func (l *LogAnalyticsQueryPackQuerySearchPropertiesRelated) 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) @@ -1136,17 +1584,14 @@ func (l *LinkedStorageAccountsResource) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &l.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &l.Name) + case "categories": + err = unpopulate(val, "Categories", &l.Categories) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &l.Properties) + case "resourceTypes": + err = unpopulate(val, "ResourceTypes", &l.ResourceTypes) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &l.Type) + case "solutions": + err = unpopulate(val, "Solutions", &l.Solutions) delete(rawMsg, key) } if err != nil { @@ -1483,6 +1928,49 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type QueryPacksResource. +func (q QueryPacksResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", q.ID) + populate(objectMap, "location", q.Location) + populate(objectMap, "name", q.Name) + populate(objectMap, "tags", q.Tags) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryPacksResource. +func (q *QueryPacksResource) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &q.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &q.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &q.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1518,6 +2006,72 @@ func (r *Resource) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type RestoredLogs. +func (r RestoredLogs) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "endRestoreTime", r.EndRestoreTime) + populate(objectMap, "sourceTable", r.SourceTable) + populateDateTimeRFC3339(objectMap, "startRestoreTime", r.StartRestoreTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RestoredLogs. +func (r *RestoredLogs) 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 "endRestoreTime": + err = unpopulateDateTimeRFC3339(val, "EndRestoreTime", &r.EndRestoreTime) + delete(rawMsg, key) + case "sourceTable": + err = unpopulate(val, "SourceTable", &r.SourceTable) + delete(rawMsg, key) + case "startRestoreTime": + err = unpopulateDateTimeRFC3339(val, "StartRestoreTime", &r.StartRestoreTime) + 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 ResultStatistics. +func (r ResultStatistics) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ingestedRecords", r.IngestedRecords) + populate(objectMap, "progress", r.Progress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResultStatistics. +func (r *ResultStatistics) 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 "ingestedRecords": + err = unpopulate(val, "IngestedRecords", &r.IngestedRecords) + delete(rawMsg, key) + case "progress": + err = unpopulate(val, "Progress", &r.Progress) + 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 SavedSearch. func (s SavedSearch) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1639,6 +2193,81 @@ func (s *SavedSearchesListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Schema. +func (s Schema) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "categories", s.Categories) + populate(objectMap, "columns", s.Columns) + populate(objectMap, "description", s.Description) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "labels", s.Labels) + populate(objectMap, "name", s.Name) + populate(objectMap, "restoredLogs", s.RestoredLogs) + populate(objectMap, "searchResults", s.SearchResults) + populate(objectMap, "solutions", s.Solutions) + populate(objectMap, "source", s.Source) + populate(objectMap, "standardColumns", s.StandardColumns) + populate(objectMap, "tableSubType", s.TableSubType) + populate(objectMap, "tableType", s.TableType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Schema. +func (s *Schema) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "categories": + err = unpopulate(val, "Categories", &s.Categories) + delete(rawMsg, key) + case "columns": + err = unpopulate(val, "Columns", &s.Columns) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &s.Labels) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "restoredLogs": + err = unpopulate(val, "RestoredLogs", &s.RestoredLogs) + delete(rawMsg, key) + case "searchResults": + err = unpopulate(val, "SearchResults", &s.SearchResults) + delete(rawMsg, key) + case "solutions": + err = unpopulate(val, "Solutions", &s.Solutions) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &s.Source) + delete(rawMsg, key) + case "standardColumns": + err = unpopulate(val, "StandardColumns", &s.StandardColumns) + delete(rawMsg, key) + case "tableSubType": + err = unpopulate(val, "TableSubType", &s.TableSubType) + delete(rawMsg, key) + case "tableType": + err = unpopulate(val, "TableType", &s.TableType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SearchGetSchemaResponse. func (s SearchGetSchemaResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1792,6 +2421,53 @@ func (s *SearchMetadataSchema) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SearchResults. +func (s SearchResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", s.Description) + populateDateTimeRFC3339(objectMap, "endSearchTime", s.EndSearchTime) + populate(objectMap, "limit", s.Limit) + populate(objectMap, "query", s.Query) + populate(objectMap, "sourceTable", s.SourceTable) + populateDateTimeRFC3339(objectMap, "startSearchTime", s.StartSearchTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SearchResults. +func (s *SearchResults) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "endSearchTime": + err = unpopulateDateTimeRFC3339(val, "EndSearchTime", &s.EndSearchTime) + delete(rawMsg, key) + case "limit": + err = unpopulate(val, "Limit", &s.Limit) + delete(rawMsg, key) + case "query": + err = unpopulate(val, "Query", &s.Query) + delete(rawMsg, key) + case "sourceTable": + err = unpopulate(val, "SourceTable", &s.SourceTable) + delete(rawMsg, key) + case "startSearchTime": + err = unpopulateDateTimeRFC3339(val, "StartSearchTime", &s.StartSearchTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SearchSchemaValue. func (s SearchSchemaValue) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2084,12 +2760,107 @@ func (s *StorageInsightStatus) UnmarshalJSON(data []byte) error { 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) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemDataAutoGenerated. +func (s SystemDataAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemDataAutoGenerated. +func (s *SystemDataAutoGenerated) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Table. func (t Table) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "name", t.Name) populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) populate(objectMap, "type", t.Type) return json.Marshal(objectMap) } @@ -2112,6 +2883,9 @@ func (t *Table) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &t.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &t.Type) delete(rawMsg, key) @@ -2126,7 +2900,16 @@ func (t *Table) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TableProperties. func (t TableProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "archiveRetentionInDays", t.ArchiveRetentionInDays) + populate(objectMap, "lastPlanModifiedDate", t.LastPlanModifiedDate) + populate(objectMap, "plan", t.Plan) + populate(objectMap, "provisioningState", t.ProvisioningState) + populate(objectMap, "restoredLogs", t.RestoredLogs) + populate(objectMap, "resultStatistics", t.ResultStatistics) populate(objectMap, "retentionInDays", t.RetentionInDays) + populate(objectMap, "schema", t.Schema) + populate(objectMap, "searchResults", t.SearchResults) + populate(objectMap, "totalRetentionInDays", t.TotalRetentionInDays) return json.Marshal(objectMap) } @@ -2139,9 +2922,36 @@ func (t *TableProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "archiveRetentionInDays": + err = unpopulate(val, "ArchiveRetentionInDays", &t.ArchiveRetentionInDays) + delete(rawMsg, key) + case "lastPlanModifiedDate": + err = unpopulate(val, "LastPlanModifiedDate", &t.LastPlanModifiedDate) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &t.Plan) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &t.ProvisioningState) + delete(rawMsg, key) + case "restoredLogs": + err = unpopulate(val, "RestoredLogs", &t.RestoredLogs) + delete(rawMsg, key) + case "resultStatistics": + err = unpopulate(val, "ResultStatistics", &t.ResultStatistics) + delete(rawMsg, key) case "retentionInDays": err = unpopulate(val, "RetentionInDays", &t.RetentionInDays) delete(rawMsg, key) + case "schema": + err = unpopulate(val, "Schema", &t.Schema) + delete(rawMsg, key) + case "searchResults": + err = unpopulate(val, "SearchResults", &t.SearchResults) + delete(rawMsg, key) + case "totalRetentionInDays": + err = unpopulate(val, "TotalRetentionInDays", &t.TotalRetentionInDays) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -2208,6 +3018,33 @@ func (t *Tag) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TagsResource. +func (t TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagsResource. +func (t *TagsResource) 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 "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2332,11 +3169,12 @@ func (u *UserIdentityProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Workspace. func (w Workspace) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "etag", w.Etag) + populate(objectMap, "eTag", w.ETag) populate(objectMap, "id", w.ID) 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) @@ -2351,8 +3189,8 @@ func (w *Workspace) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "etag": - err = unpopulate(val, "Etag", &w.Etag) + case "eTag": + err = unpopulate(val, "ETag", &w.ETag) delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &w.ID) @@ -2366,6 +3204,9 @@ func (w *Workspace) 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) @@ -2606,6 +3447,7 @@ func (w WorkspaceProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "createdDate", w.CreatedDate) populate(objectMap, "customerId", w.CustomerID) + populate(objectMap, "defaultDataCollectionRuleResourceId", w.DefaultDataCollectionRuleResourceID) populate(objectMap, "features", w.Features) populate(objectMap, "forceCmkForQuery", w.ForceCmkForQuery) populate(objectMap, "modifiedDate", w.ModifiedDate) @@ -2634,6 +3476,9 @@ func (w *WorkspaceProperties) UnmarshalJSON(data []byte) error { case "customerId": err = unpopulate(val, "CustomerID", &w.CustomerID) delete(rawMsg, key) + case "defaultDataCollectionRuleResourceId": + err = unpopulate(val, "DefaultDataCollectionRuleResourceID", &w.DefaultDataCollectionRuleResourceID) + delete(rawMsg, key) case "features": err = unpopulate(val, "Features", &w.Features) delete(rawMsg, key) @@ -2852,7 +3697,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/operations_client.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/operations_client.go index 93d99aff3891..059c62ca42b7 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/operations_client.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available OperationalInsights Rest API operations. // -// Generated from API version 2020-10-01 +// Generated from API version 2021-12-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/operations_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/operations_client_example_test.go index 76fc45e63e5a..207ec64d6a9e 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/operations_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/operations_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-10-01/examples/OperationsListByTenant.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/OperationsListByTenant.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/operationstatuses_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/operationstatuses_client_example_test.go index ef0ab48bb9d1..c940992c3657 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/operationstatuses_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/operationstatuses_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/OperationStatusesGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/OperationStatusesGet.json func ExampleOperationStatusesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/options.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/options.go index 07733ab17645..14634ce61d74 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/options.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/options.go @@ -183,6 +183,87 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } +// QueriesClientDeleteOptions contains the optional parameters for the QueriesClient.Delete method. +type QueriesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// QueriesClientGetOptions contains the optional parameters for the QueriesClient.Get method. +type QueriesClientGetOptions struct { + // placeholder for future optional parameters +} + +// QueriesClientListOptions contains the optional parameters for the QueriesClient.NewListPager method. +type QueriesClientListOptions struct { + // Flag indicating whether or not to return the body of each applicable query. If false, only return the query information. + IncludeBody *bool + + // Base64 encoded token used to fetch the next page of items. Default is null. + SkipToken *string + + // Maximum items returned in page. + Top *int64 +} + +// QueriesClientPutOptions contains the optional parameters for the QueriesClient.Put method. +type QueriesClientPutOptions struct { + // placeholder for future optional parameters +} + +// QueriesClientSearchOptions contains the optional parameters for the QueriesClient.NewSearchPager method. +type QueriesClientSearchOptions struct { + // Flag indicating whether or not to return the body of each applicable query. If false, only return the query information. + IncludeBody *bool + + // Base64 encoded token used to fetch the next page of items. Default is null. + SkipToken *string + + // Maximum items returned in page. + Top *int64 +} + +// QueriesClientUpdateOptions contains the optional parameters for the QueriesClient.Update method. +type QueriesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// QueryPacksClientCreateOrUpdateOptions contains the optional parameters for the QueryPacksClient.CreateOrUpdate method. +type QueryPacksClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// QueryPacksClientCreateOrUpdateWithoutNameOptions contains the optional parameters for the QueryPacksClient.CreateOrUpdateWithoutName +// method. +type QueryPacksClientCreateOrUpdateWithoutNameOptions struct { + // placeholder for future optional parameters +} + +// QueryPacksClientDeleteOptions contains the optional parameters for the QueryPacksClient.Delete method. +type QueryPacksClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// QueryPacksClientGetOptions contains the optional parameters for the QueryPacksClient.Get method. +type QueryPacksClientGetOptions struct { + // placeholder for future optional parameters +} + +// QueryPacksClientListByResourceGroupOptions contains the optional parameters for the QueryPacksClient.NewListByResourceGroupPager +// method. +type QueryPacksClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// QueryPacksClientListOptions contains the optional parameters for the QueryPacksClient.NewListPager method. +type QueryPacksClientListOptions struct { + // placeholder for future optional parameters +} + +// QueryPacksClientUpdateTagsOptions contains the optional parameters for the QueryPacksClient.UpdateTags method. +type QueryPacksClientUpdateTagsOptions struct { + // placeholder for future optional parameters +} + // SavedSearchesClientCreateOrUpdateOptions contains the optional parameters for the SavedSearchesClient.CreateOrUpdate method. type SavedSearchesClientCreateOrUpdateOptions struct { // placeholder for future optional parameters @@ -241,6 +322,24 @@ type StorageInsightConfigsClientListByWorkspaceOptions struct { // placeholder for future optional parameters } +// TablesClientBeginCreateOrUpdateOptions contains the optional parameters for the TablesClient.BeginCreateOrUpdate method. +type TablesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TablesClientBeginDeleteOptions contains the optional parameters for the TablesClient.BeginDelete method. +type TablesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TablesClientBeginUpdateOptions contains the optional parameters for the TablesClient.BeginUpdate method. +type TablesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // TablesClientGetOptions contains the optional parameters for the TablesClient.Get method. type TablesClientGetOptions struct { // placeholder for future optional parameters @@ -251,8 +350,8 @@ type TablesClientListByWorkspaceOptions struct { // placeholder for future optional parameters } -// TablesClientUpdateOptions contains the optional parameters for the TablesClient.Update method. -type TablesClientUpdateOptions struct { +// TablesClientMigrateOptions contains the optional parameters for the TablesClient.Migrate method. +type TablesClientMigrateOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/queries_client.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/queries_client.go new file mode 100644 index 000000000000..6e274d29cf42 --- /dev/null +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/queries_client.go @@ -0,0 +1,469 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// QueriesClient contains the methods for the Queries group. +// Don't use this type directly, use NewQueriesClient() instead. +type QueriesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewQueriesClient creates a new instance of QueriesClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewQueriesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QueriesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &QueriesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Delete - Deletes a specific Query defined within an Log Analytics QueryPack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - id - The id of a specific query defined in the Log Analytics QueryPack +// - options - QueriesClientDeleteOptions contains the optional parameters for the QueriesClient.Delete method. +func (client *QueriesClient) Delete(ctx context.Context, resourceGroupName string, queryPackName string, id string, options *QueriesClientDeleteOptions) (QueriesClientDeleteResponse, error) { + var err error + const operationName = "QueriesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, queryPackName, id, options) + if err != nil { + return QueriesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueriesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return QueriesClientDeleteResponse{}, err + } + return QueriesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *QueriesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, id string, options *QueriesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a specific Log Analytics Query defined within a Log Analytics QueryPack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - id - The id of a specific query defined in the Log Analytics QueryPack +// - options - QueriesClientGetOptions contains the optional parameters for the QueriesClient.Get method. +func (client *QueriesClient) Get(ctx context.Context, resourceGroupName string, queryPackName string, id string, options *QueriesClientGetOptions) (QueriesClientGetResponse, error) { + var err error + const operationName = "QueriesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, queryPackName, id, options) + if err != nil { + return QueriesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueriesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueriesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *QueriesClient) getCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, id string, options *QueriesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + 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", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *QueriesClient) getHandleResponse(resp *http.Response) (QueriesClientGetResponse, error) { + result := QueriesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPackQuery); err != nil { + return QueriesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets a list of Queries defined within a Log Analytics QueryPack. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - options - QueriesClientListOptions contains the optional parameters for the QueriesClient.NewListPager method. +func (client *QueriesClient) NewListPager(resourceGroupName string, queryPackName string, options *QueriesClientListOptions) *runtime.Pager[QueriesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[QueriesClientListResponse]{ + More: func(page QueriesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *QueriesClientListResponse) (QueriesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "QueriesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, queryPackName, options) + }, nil) + if err != nil { + return QueriesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *QueriesClient) listCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, options *QueriesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(*options.Top, 10)) + } + reqQP.Set("api-version", "2019-09-01") + if options != nil && options.IncludeBody != nil { + reqQP.Set("includeBody", strconv.FormatBool(*options.IncludeBody)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *QueriesClient) listHandleResponse(resp *http.Response) (QueriesClientListResponse, error) { + result := QueriesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPackQueryListResult); err != nil { + return QueriesClientListResponse{}, err + } + return result, nil +} + +// Put - Adds or Updates a specific Query within a Log Analytics QueryPack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - id - The id of a specific query defined in the Log Analytics QueryPack +// - queryPayload - Properties that need to be specified to create a new query and add it to a Log Analytics QueryPack. +// - options - QueriesClientPutOptions contains the optional parameters for the QueriesClient.Put method. +func (client *QueriesClient) Put(ctx context.Context, resourceGroupName string, queryPackName string, id string, queryPayload LogAnalyticsQueryPackQuery, options *QueriesClientPutOptions) (QueriesClientPutResponse, error) { + var err error + const operationName = "QueriesClient.Put" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.putCreateRequest(ctx, resourceGroupName, queryPackName, id, queryPayload, options) + if err != nil { + return QueriesClientPutResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueriesClientPutResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueriesClientPutResponse{}, err + } + resp, err := client.putHandleResponse(httpResp) + return resp, err +} + +// putCreateRequest creates the Put request. +func (client *QueriesClient) putCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, id string, queryPayload LogAnalyticsQueryPackQuery, options *QueriesClientPutOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, queryPayload); err != nil { + return nil, err + } + return req, nil +} + +// putHandleResponse handles the Put response. +func (client *QueriesClient) putHandleResponse(resp *http.Response) (QueriesClientPutResponse, error) { + result := QueriesClientPutResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPackQuery); err != nil { + return QueriesClientPutResponse{}, err + } + return result, nil +} + +// NewSearchPager - Search a list of Queries defined within a Log Analytics QueryPack according to given search properties. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - querySearchProperties - Properties by which to search queries in the given Log Analytics QueryPack. +// - options - QueriesClientSearchOptions contains the optional parameters for the QueriesClient.NewSearchPager method. +func (client *QueriesClient) NewSearchPager(resourceGroupName string, queryPackName string, querySearchProperties LogAnalyticsQueryPackQuerySearchProperties, options *QueriesClientSearchOptions) *runtime.Pager[QueriesClientSearchResponse] { + return runtime.NewPager(runtime.PagingHandler[QueriesClientSearchResponse]{ + More: func(page QueriesClientSearchResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *QueriesClientSearchResponse) (QueriesClientSearchResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "QueriesClient.NewSearchPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.searchCreateRequest(ctx, resourceGroupName, queryPackName, querySearchProperties, options) + }, nil) + if err != nil { + return QueriesClientSearchResponse{}, err + } + return client.searchHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// searchCreateRequest creates the Search request. +func (client *QueriesClient) searchCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, querySearchProperties LogAnalyticsQueryPackQuerySearchProperties, options *QueriesClientSearchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(*options.Top, 10)) + } + reqQP.Set("api-version", "2019-09-01") + if options != nil && options.IncludeBody != nil { + reqQP.Set("includeBody", strconv.FormatBool(*options.IncludeBody)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, querySearchProperties); err != nil { + return nil, err + } + return req, nil +} + +// searchHandleResponse handles the Search response. +func (client *QueriesClient) searchHandleResponse(resp *http.Response) (QueriesClientSearchResponse, error) { + result := QueriesClientSearchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPackQueryListResult); err != nil { + return QueriesClientSearchResponse{}, err + } + return result, nil +} + +// Update - Adds or Updates a specific Query within a Log Analytics QueryPack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - id - The id of a specific query defined in the Log Analytics QueryPack +// - queryPayload - Properties that need to be specified to create a new query and add it to a Log Analytics QueryPack. +// - options - QueriesClientUpdateOptions contains the optional parameters for the QueriesClient.Update method. +func (client *QueriesClient) Update(ctx context.Context, resourceGroupName string, queryPackName string, id string, queryPayload LogAnalyticsQueryPackQuery, options *QueriesClientUpdateOptions) (QueriesClientUpdateResponse, error) { + var err error + const operationName = "QueriesClient.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, queryPackName, id, queryPayload, options) + if err != nil { + return QueriesClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueriesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueriesClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *QueriesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, id string, queryPayload LogAnalyticsQueryPackQuery, options *QueriesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, queryPayload); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *QueriesClient) updateHandleResponse(resp *http.Response) (QueriesClientUpdateResponse, error) { + result := QueriesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPackQuery); err != nil { + return QueriesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/queries_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/queries_client_example_test.go new file mode 100644 index 000000000000..69e3b48d468b --- /dev/null +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/queries_client_example_test.go @@ -0,0 +1,470 @@ +//go:build go1.18 +// +build go1.18 + +// 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. + +package armoperationalinsights_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/operationalinsights/armoperationalinsights/v2" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesList.json +func ExampleQueriesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewQueriesClient().NewListPager("my-resource-group", "my-querypack", &armoperationalinsights.QueriesClientListOptions{Top: nil, + IncludeBody: to.Ptr(true), + SkipToken: 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.LogAnalyticsQueryPackQueryListResult = armoperationalinsights.LogAnalyticsQueryPackQueryListResult{ + // Value: []*armoperationalinsights.LogAnalyticsQueryPackQuery{ + // { + // Name: to.Ptr("4337bb16-d6fe-4ff7-97cf-59df25941476"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/4337bb16-d6fe-4ff7-97cf-59df25941476"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("Thie query takes 10 entries of heartbeat"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: to.Ptr("heartbeat | take 10"), + // DisplayName: to.Ptr("Heartbeat_1"), + // ID: to.Ptr("4337bb16-d6fe-4ff7-97cf-59df25941476"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:29:56.103Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:29:56.103Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("bf015bf7-be70-49c2-8d52-4cce85c42ef1"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/bf015bf7-be70-49c2-8d52-4cce85c42ef1"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("Thie query takes 10 entries of heartbeat"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: to.Ptr("heartbeat | take 10"), + // DisplayName: to.Ptr("Heartbeat_2"), + // ID: to.Ptr("bf015bf7-be70-49c2-8d52-4cce85c42ef1"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:26.794Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:26.794Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("8d91c6ca-9c56-49c6-b3ae-112a68871acd"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/8d91c6ca-9c56-49c6-b3ae-112a68871acd"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("Thie query takes 10 entries of heartbeat"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: to.Ptr("heartbeat | take 10"), + // DisplayName: to.Ptr("Heartbeat_3"), + // ID: to.Ptr("8d91c6ca-9c56-49c6-b3ae-112a68871acd"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:29.450Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:29.450Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("a5a9010e-e4b7-45ad-8b14-09d7e6082819"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/a5a9010e-e4b7-45ad-8b14-09d7e6082819"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("Thie query takes 10 entries of heartbeat"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: to.Ptr("heartbeat | take 10"), + // DisplayName: to.Ptr("Heartbeat_4"), + // ID: to.Ptr("a5a9010e-e4b7-45ad-8b14-09d7e6082819"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:32.574Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:32.574Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesSearch.json +func ExampleQueriesClient_NewSearchPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewQueriesClient().NewSearchPager("my-resource-group", "my-querypack", armoperationalinsights.LogAnalyticsQueryPackQuerySearchProperties{ + Related: &armoperationalinsights.LogAnalyticsQueryPackQuerySearchPropertiesRelated{ + Categories: []*string{ + to.Ptr("other"), + to.Ptr("analytics")}, + }, + Tags: map[string][]*string{ + "my-label": { + to.Ptr("label1")}, + }, + }, &armoperationalinsights.QueriesClientSearchOptions{Top: to.Ptr[int64](3), + IncludeBody: to.Ptr(true), + SkipToken: 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.LogAnalyticsQueryPackQueryListResult = armoperationalinsights.LogAnalyticsQueryPackQueryListResult{ + // Value: []*armoperationalinsights.LogAnalyticsQueryPackQuery{ + // { + // Name: to.Ptr("4337bb16-d6fe-4ff7-97cf-59df25941476"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/4337bb16-d6fe-4ff7-97cf-59df25941476"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("Thie query takes 10 entries of heartbeat 0"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: to.Ptr("Heartbeat | take 1"), + // DisplayName: to.Ptr("Heartbeat_1"), + // ID: to.Ptr("4337bb16-d6fe-4ff7-97cf-59df25941476"), + // Related: &armoperationalinsights.LogAnalyticsQueryPackQueryPropertiesRelated{ + // Categories: []*string{ + // to.Ptr("other")}, + // }, + // Tags: map[string][]*string{ + // "my-label": []*string{ + // to.Ptr("label1")}, + // "my-other-label": []*string{ + // to.Ptr("label2")}, + // }, + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:29:56.103Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:29:56.103Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("bf015bf7-be70-49c2-8d52-4cce85c42ef1"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/bf015bf7-be70-49c2-8d52-4cce85c42ef1"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("Thie query takes 10 entries of heartbeat 1"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: to.Ptr("Heartbeat | take 1"), + // DisplayName: to.Ptr("Heartbeat_2"), + // ID: to.Ptr("bf015bf7-be70-49c2-8d52-4cce85c42ef1"), + // Related: &armoperationalinsights.LogAnalyticsQueryPackQueryPropertiesRelated{ + // Categories: []*string{ + // to.Ptr("analytics")}, + // }, + // Tags: map[string][]*string{ + // "my-label": []*string{ + // to.Ptr("label1")}, + // "my-other-label": []*string{ + // to.Ptr("label2")}, + // }, + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:26.794Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:26.794Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("8d91c6ca-9c56-49c6-b3ae-112a68871acd"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/8d91c6ca-9c56-49c6-b3ae-112a68871acd"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("Thie query takes 10 entries of heartbeat 2"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: to.Ptr("Heartbeat | take 1"), + // DisplayName: to.Ptr("Heartbeat_3"), + // ID: to.Ptr("8d91c6ca-9c56-49c6-b3ae-112a68871acd"), + // Related: &armoperationalinsights.LogAnalyticsQueryPackQueryPropertiesRelated{ + // Categories: []*string{ + // to.Ptr("other"), + // to.Ptr("analytics")}, + // }, + // Tags: map[string][]*string{ + // "my-label": []*string{ + // to.Ptr("label1")}, + // "my-other-label": []*string{ + // to.Ptr("label2")}, + // }, + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:29.450Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:29.450Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesGet.json +func ExampleQueriesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQueriesClient().Get(ctx, "my-resource-group", "my-querypack", "a449f8af-8e64-4b3a-9b16-5a7165ff98c4", 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.LogAnalyticsQueryPackQuery = armoperationalinsights.LogAnalyticsQueryPackQuery{ + // Name: to.Ptr("a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("Thie query fetcges the recent exceptions from the last 24 hours"), + // Body: 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"), + // DisplayName: to.Ptr("Exceptions - New in the last 24 hours"), + // ID: to.Ptr("a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-12T11:44:39.298Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-14T13:13:19.338Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesPut.json +func ExampleQueriesClient_Put() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQueriesClient().Put(ctx, "my-resource-group", "my-querypack", "a449f8af-8e64-4b3a-9b16-5a7165ff98c4", armoperationalinsights.LogAnalyticsQueryPackQuery{ + Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + Description: to.Ptr("my description"), + Body: 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"), + DisplayName: to.Ptr("Exceptions - New in the last 24 hours"), + Related: &armoperationalinsights.LogAnalyticsQueryPackQueryPropertiesRelated{ + Categories: []*string{ + to.Ptr("analytics")}, + }, + Tags: map[string][]*string{ + "my-label": { + to.Ptr("label1")}, + "my-other-label": { + to.Ptr("label2")}, + }, + }, + }, 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.LogAnalyticsQueryPackQuery = armoperationalinsights.LogAnalyticsQueryPackQuery{ + // Name: to.Ptr("a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("my description"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: 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"), + // DisplayName: to.Ptr("Exceptions - New in the last 24 hours"), + // ID: to.Ptr("a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // Related: &armoperationalinsights.LogAnalyticsQueryPackQueryPropertiesRelated{ + // Categories: []*string{ + // to.Ptr("analytics")}, + // }, + // Tags: map[string][]*string{ + // "my-label": []*string{ + // to.Ptr("label1")}, + // "my-other-label": []*string{ + // to.Ptr("label2")}, + // }, + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:32.574Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:32.574Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesUpdate.json +func ExampleQueriesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQueriesClient().Update(ctx, "my-resource-group", "my-querypack", "a449f8af-8e64-4b3a-9b16-5a7165ff98c4", armoperationalinsights.LogAnalyticsQueryPackQuery{ + Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + Description: to.Ptr("my description"), + Body: 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"), + DisplayName: to.Ptr("Exceptions - New in the last 24 hours"), + Related: &armoperationalinsights.LogAnalyticsQueryPackQueryPropertiesRelated{ + Categories: []*string{ + to.Ptr("analytics")}, + }, + Tags: map[string][]*string{ + "my-label": { + to.Ptr("label1")}, + "my-other-label": { + to.Ptr("label2")}, + }, + }, + }, 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.LogAnalyticsQueryPackQuery = armoperationalinsights.LogAnalyticsQueryPackQuery{ + // Name: to.Ptr("a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // Type: to.Ptr("microsoft.operationalinsights/queryPacks/queries"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4918/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack/queries/a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // SystemData: &armoperationalinsights.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armoperationalinsights.IdentityTypeApplication), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackQueryProperties{ + // Description: to.Ptr("my description"), + // Author: to.Ptr("1809f206-263a-46f7-942d-4572c156b7e7"), + // Body: 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"), + // DisplayName: to.Ptr("Exceptions - New in the last 24 hours"), + // ID: to.Ptr("a449f8af-8e64-4b3a-9b16-5a7165ff98c4"), + // Related: &armoperationalinsights.LogAnalyticsQueryPackQueryPropertiesRelated{ + // Categories: []*string{ + // to.Ptr("analytics")}, + // }, + // Tags: map[string][]*string{ + // "my-label": []*string{ + // to.Ptr("label1")}, + // "my-other-label": []*string{ + // to.Ptr("label2")}, + // }, + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:32.574Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-15T10:30:32.574Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesDelete.json +func ExampleQueriesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewQueriesClient().Delete(ctx, "my-resource-group", "my-querypack", "a449f8af-8e64-4b3a-9b16-5a7165ff98c4", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/querypacks_client.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/querypacks_client.go new file mode 100644 index 000000000000..faa38059a945 --- /dev/null +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/querypacks_client.go @@ -0,0 +1,479 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// QueryPacksClient contains the methods for the QueryPacks group. +// Don't use this type directly, use NewQueryPacksClient() instead. +type QueryPacksClient struct { + internal *arm.Client + subscriptionID string +} + +// NewQueryPacksClient creates a new instance of QueryPacksClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewQueryPacksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QueryPacksClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &QueryPacksClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates (or updates) a Log Analytics QueryPack. 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 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - logAnalyticsQueryPackPayload - Properties that need to be specified to create or update a Log Analytics QueryPack. +// - options - QueryPacksClientCreateOrUpdateOptions contains the optional parameters for the QueryPacksClient.CreateOrUpdate +// method. +func (client *QueryPacksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, queryPackName string, logAnalyticsQueryPackPayload LogAnalyticsQueryPack, options *QueryPacksClientCreateOrUpdateOptions) (QueryPacksClientCreateOrUpdateResponse, error) { + var err error + const operationName = "QueryPacksClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, queryPackName, logAnalyticsQueryPackPayload, options) + if err != nil { + return QueryPacksClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueryPacksClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueryPacksClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *QueryPacksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, logAnalyticsQueryPackPayload LogAnalyticsQueryPack, options *QueryPacksClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, logAnalyticsQueryPackPayload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *QueryPacksClient) createOrUpdateHandleResponse(resp *http.Response) (QueryPacksClientCreateOrUpdateResponse, error) { + result := QueryPacksClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPack); err != nil { + return QueryPacksClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// CreateOrUpdateWithoutName - Creates a Log Analytics QueryPack. 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 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - logAnalyticsQueryPackPayload - Properties that need to be specified to create or update a Log Analytics QueryPack. +// - options - QueryPacksClientCreateOrUpdateWithoutNameOptions contains the optional parameters for the QueryPacksClient.CreateOrUpdateWithoutName +// method. +func (client *QueryPacksClient) CreateOrUpdateWithoutName(ctx context.Context, resourceGroupName string, logAnalyticsQueryPackPayload LogAnalyticsQueryPack, options *QueryPacksClientCreateOrUpdateWithoutNameOptions) (QueryPacksClientCreateOrUpdateWithoutNameResponse, error) { + var err error + const operationName = "QueryPacksClient.CreateOrUpdateWithoutName" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateWithoutNameCreateRequest(ctx, resourceGroupName, logAnalyticsQueryPackPayload, options) + if err != nil { + return QueryPacksClientCreateOrUpdateWithoutNameResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueryPacksClientCreateOrUpdateWithoutNameResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return QueryPacksClientCreateOrUpdateWithoutNameResponse{}, err + } + resp, err := client.createOrUpdateWithoutNameHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateWithoutNameCreateRequest creates the CreateOrUpdateWithoutName request. +func (client *QueryPacksClient) createOrUpdateWithoutNameCreateRequest(ctx context.Context, resourceGroupName string, logAnalyticsQueryPackPayload LogAnalyticsQueryPack, options *QueryPacksClientCreateOrUpdateWithoutNameOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, logAnalyticsQueryPackPayload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateWithoutNameHandleResponse handles the CreateOrUpdateWithoutName response. +func (client *QueryPacksClient) createOrUpdateWithoutNameHandleResponse(resp *http.Response) (QueryPacksClientCreateOrUpdateWithoutNameResponse, error) { + result := QueryPacksClientCreateOrUpdateWithoutNameResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPack); err != nil { + return QueryPacksClientCreateOrUpdateWithoutNameResponse{}, err + } + return result, nil +} + +// Delete - Deletes a Log Analytics QueryPack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - options - QueryPacksClientDeleteOptions contains the optional parameters for the QueryPacksClient.Delete method. +func (client *QueryPacksClient) Delete(ctx context.Context, resourceGroupName string, queryPackName string, options *QueryPacksClientDeleteOptions) (QueryPacksClientDeleteResponse, error) { + var err error + const operationName = "QueryPacksClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, queryPackName, options) + if err != nil { + return QueryPacksClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueryPacksClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return QueryPacksClientDeleteResponse{}, err + } + return QueryPacksClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *QueryPacksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, options *QueryPacksClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns a Log Analytics QueryPack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - options - QueryPacksClientGetOptions contains the optional parameters for the QueryPacksClient.Get method. +func (client *QueryPacksClient) Get(ctx context.Context, resourceGroupName string, queryPackName string, options *QueryPacksClientGetOptions) (QueryPacksClientGetResponse, error) { + var err error + const operationName = "QueryPacksClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, queryPackName, options) + if err != nil { + return QueryPacksClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueryPacksClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueryPacksClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *QueryPacksClient) getCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, options *QueryPacksClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + 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", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *QueryPacksClient) getHandleResponse(resp *http.Response) (QueryPacksClientGetResponse, error) { + result := QueryPacksClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPack); err != nil { + return QueryPacksClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets a list of all Log Analytics QueryPacks within a subscription. +// +// Generated from API version 2019-09-01 +// - options - QueryPacksClientListOptions contains the optional parameters for the QueryPacksClient.NewListPager method. +func (client *QueryPacksClient) NewListPager(options *QueryPacksClientListOptions) *runtime.Pager[QueryPacksClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[QueryPacksClientListResponse]{ + More: func(page QueryPacksClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *QueryPacksClientListResponse) (QueryPacksClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "QueryPacksClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return QueryPacksClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *QueryPacksClient) listCreateRequest(ctx context.Context, options *QueryPacksClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/queryPacks" + 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", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *QueryPacksClient) listHandleResponse(resp *http.Response) (QueryPacksClientListResponse, error) { + result := QueryPacksClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPackListResult); err != nil { + return QueryPacksClientListResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets a list of Log Analytics QueryPacks within a resource group. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - QueryPacksClientListByResourceGroupOptions contains the optional parameters for the QueryPacksClient.NewListByResourceGroupPager +// method. +func (client *QueryPacksClient) NewListByResourceGroupPager(resourceGroupName string, options *QueryPacksClientListByResourceGroupOptions) *runtime.Pager[QueryPacksClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[QueryPacksClientListByResourceGroupResponse]{ + More: func(page QueryPacksClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *QueryPacksClientListByResourceGroupResponse) (QueryPacksClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "QueryPacksClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return QueryPacksClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *QueryPacksClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *QueryPacksClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks" + 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)) + 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", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *QueryPacksClient) listByResourceGroupHandleResponse(resp *http.Response) (QueryPacksClientListByResourceGroupResponse, error) { + result := QueryPacksClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPackListResult); err != nil { + return QueryPacksClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// UpdateTags - Updates an existing QueryPack's tags. To update other fields use the CreateOrUpdate method. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2019-09-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - queryPackName - The name of the Log Analytics QueryPack resource. +// - queryPackTags - Updated tag information to set into the QueryPack instance. +// - options - QueryPacksClientUpdateTagsOptions contains the optional parameters for the QueryPacksClient.UpdateTags method. +func (client *QueryPacksClient) UpdateTags(ctx context.Context, resourceGroupName string, queryPackName string, queryPackTags TagsResource, options *QueryPacksClientUpdateTagsOptions) (QueryPacksClientUpdateTagsResponse, error) { + var err error + const operationName = "QueryPacksClient.UpdateTags" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, queryPackName, queryPackTags, options) + if err != nil { + return QueryPacksClientUpdateTagsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueryPacksClientUpdateTagsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueryPacksClientUpdateTagsResponse{}, err + } + resp, err := client.updateTagsHandleResponse(httpResp) + return resp, err +} + +// updateTagsCreateRequest creates the UpdateTags request. +func (client *QueryPacksClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, queryPackName string, queryPackTags TagsResource, options *QueryPacksClientUpdateTagsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}" + 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 queryPackName == "" { + return nil, errors.New("parameter queryPackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queryPackName}", url.PathEscape(queryPackName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2019-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, queryPackTags); err != nil { + return nil, err + } + return req, nil +} + +// updateTagsHandleResponse handles the UpdateTags response. +func (client *QueryPacksClient) updateTagsHandleResponse(resp *http.Response) (QueryPacksClientUpdateTagsResponse, error) { + result := QueryPacksClientUpdateTagsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogAnalyticsQueryPack); err != nil { + return QueryPacksClientUpdateTagsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/querypacks_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/querypacks_client_example_test.go new file mode 100644 index 000000000000..ba1dd6f7762a --- /dev/null +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/querypacks_client_example_test.go @@ -0,0 +1,344 @@ +//go:build go1.18 +// +build go1.18 + +// 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. + +package armoperationalinsights_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/operationalinsights/armoperationalinsights/v2" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksList.json +func ExampleQueryPacksClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewQueryPacksClient().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.LogAnalyticsQueryPackListResult = armoperationalinsights.LogAnalyticsQueryPackListResult{ + // Value: []*armoperationalinsights.LogAnalyticsQueryPack{ + // { + // Name: to.Ptr("my-querypack"), + // Type: to.Ptr("microsoft.operationalinsights/querypacks"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4919/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // QueryPackID: to.Ptr("d1c8fc00-2b68-441e-8f9b-ded8748dc6aa"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("my-other-querypack"), + // Type: to.Ptr("microsoft.operationalinsights/querypacks"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4919/resourceGroups/my-other-resource-group/providers/microsoft.operationalinsights/queryPacks/my-other-querypack"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // QueryPackID: to.Ptr("aac8fc00-2b68-441e-8f9b-ded8748dc635"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-04T12:37:56.854Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksListByResourceGroup.json +func ExampleQueryPacksClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewQueryPacksClient().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.LogAnalyticsQueryPackListResult = armoperationalinsights.LogAnalyticsQueryPackListResult{ + // Value: []*armoperationalinsights.LogAnalyticsQueryPack{ + // { + // Name: to.Ptr("my-querypack"), + // Type: to.Ptr("microsoft.operationalinsights/querypacks"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4919/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // QueryPackID: to.Ptr("d1c8fc00-2b68-441e-8f9b-ded8748dc6aa"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("my-other-querypack"), + // Type: to.Ptr("microsoft.operationalinsights/querypacks"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4919/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-other-querypack"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // QueryPackID: to.Ptr("aac8fc00-2b68-441e-8f9b-ded8748dc635"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-04T12:37:56.854Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksCreateNoName.json +func ExampleQueryPacksClient_CreateOrUpdateWithoutName_queryPackCreateNoName() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewQueryPacksClient().CreateOrUpdateWithoutName(ctx, "my-resource-group", armoperationalinsights.LogAnalyticsQueryPack{ + Location: to.Ptr("South Central US"), + Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{}, + }, 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/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackUpdateNoName.json +func ExampleQueryPacksClient_CreateOrUpdateWithoutName_queryPackUpdateNoName() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewQueryPacksClient().CreateOrUpdateWithoutName(ctx, "my-resource-group", armoperationalinsights.LogAnalyticsQueryPack{ + Location: to.Ptr("South Central US"), + Tags: map[string]*string{ + "Tag1": to.Ptr("Value1"), + }, + Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{}, + }, 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/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksDelete.json +func ExampleQueryPacksClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewQueryPacksClient().Delete(ctx, "my-resource-group", "my-querypack", 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/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksGet.json +func ExampleQueryPacksClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQueryPacksClient().Get(ctx, "my-resource-group", "my-querypack", 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.LogAnalyticsQueryPack = armoperationalinsights.LogAnalyticsQueryPack{ + // Name: to.Ptr("my-querypack"), + // Type: to.Ptr("microsoft.operationalinsights/querypacks"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4919/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack"), + // Location: to.Ptr("southcentralus"), + // Tags: map[string]*string{ + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // QueryPackID: to.Ptr("d1c8fc00-2b68-441e-8f9b-ded8748dc635"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksCreate.json +func ExampleQueryPacksClient_CreateOrUpdate_queryPackCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQueryPacksClient().CreateOrUpdate(ctx, "my-resource-group", "my-querypack", armoperationalinsights.LogAnalyticsQueryPack{ + Location: to.Ptr("South Central US"), + Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{}, + }, 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.LogAnalyticsQueryPack = armoperationalinsights.LogAnalyticsQueryPack{ + // Name: to.Ptr("my-querypack"), + // Type: to.Ptr("microsoft.operationalinsights/querypacks"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4919/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // QueryPackID: to.Ptr("d1c8fc00-2b68-441e-8f9b-ded8748dc635"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksUpdate.json +func ExampleQueryPacksClient_CreateOrUpdate_queryPackUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQueryPacksClient().CreateOrUpdate(ctx, "my-resource-group", "my-querypack", armoperationalinsights.LogAnalyticsQueryPack{ + Location: to.Ptr("South Central US"), + Tags: map[string]*string{ + "Tag1": to.Ptr("Value1"), + }, + Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{}, + }, 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.LogAnalyticsQueryPack = armoperationalinsights.LogAnalyticsQueryPack{ + // Name: to.Ptr("my-querypack"), + // Type: to.Ptr("microsoft.operationalinsights/querypacks"), + // ID: to.Ptr("/subscriptions/86dc51d3-92ed-4d7e-947a-775ea79b4919/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // QueryPackID: to.Ptr("aac8fc00-2b68-441e-8f9b-ded8748dc635"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-04T12:37:56.854Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksUpdateTagsOnly.json +func ExampleQueryPacksClient_UpdateTags() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewQueryPacksClient().UpdateTags(ctx, "my-resource-group", "my-querypack", armoperationalinsights.TagsResource{ + Tags: map[string]*string{ + "Tag1": to.Ptr("Value1"), + "Tag2": to.Ptr("Value2"), + }, + }, 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.LogAnalyticsQueryPack = armoperationalinsights.LogAnalyticsQueryPack{ + // Name: to.Ptr("my-querypack"), + // Type: to.Ptr("microsoft.operationalinsights/querypacks"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/microsoft.operationalinsights/queryPacks/my-querypack"), + // Location: to.Ptr("South Central US"), + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // "Tag2": to.Ptr("Value2"), + // }, + // Properties: &armoperationalinsights.LogAnalyticsQueryPackProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // QueryPackID: to.Ptr("aac8fc00-2b68-441e-8f9b-ded8748dc635"), + // TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-04T12:37:56.854Z"); return t}()), + // TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-04T12:37:56.854Z"); return t}()), + // }, + // } +} diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/response_types.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/responses.go similarity index 78% rename from sdk/resourcemanager/operationalinsights/armoperationalinsights/response_types.go rename to sdk/resourcemanager/operationalinsights/armoperationalinsights/responses.go index 830dc223ede6..11e0c295ceec 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/response_types.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/responses.go @@ -193,6 +193,82 @@ type OperationsClientListResponse struct { OperationListResult } +// QueriesClientDeleteResponse contains the response from method QueriesClient.Delete. +type QueriesClientDeleteResponse struct { + // placeholder for future response values +} + +// QueriesClientGetResponse contains the response from method QueriesClient.Get. +type QueriesClientGetResponse struct { + // A Log Analytics QueryPack-Query definition. + LogAnalyticsQueryPackQuery +} + +// QueriesClientListResponse contains the response from method QueriesClient.NewListPager. +type QueriesClientListResponse struct { + // Describes the list of Log Analytics QueryPack-Query resources. + LogAnalyticsQueryPackQueryListResult +} + +// QueriesClientPutResponse contains the response from method QueriesClient.Put. +type QueriesClientPutResponse struct { + // A Log Analytics QueryPack-Query definition. + LogAnalyticsQueryPackQuery +} + +// QueriesClientSearchResponse contains the response from method QueriesClient.NewSearchPager. +type QueriesClientSearchResponse struct { + // Describes the list of Log Analytics QueryPack-Query resources. + LogAnalyticsQueryPackQueryListResult +} + +// QueriesClientUpdateResponse contains the response from method QueriesClient.Update. +type QueriesClientUpdateResponse struct { + // A Log Analytics QueryPack-Query definition. + LogAnalyticsQueryPackQuery +} + +// QueryPacksClientCreateOrUpdateResponse contains the response from method QueryPacksClient.CreateOrUpdate. +type QueryPacksClientCreateOrUpdateResponse struct { + // An Log Analytics QueryPack definition. + LogAnalyticsQueryPack +} + +// QueryPacksClientCreateOrUpdateWithoutNameResponse contains the response from method QueryPacksClient.CreateOrUpdateWithoutName. +type QueryPacksClientCreateOrUpdateWithoutNameResponse struct { + // An Log Analytics QueryPack definition. + LogAnalyticsQueryPack +} + +// QueryPacksClientDeleteResponse contains the response from method QueryPacksClient.Delete. +type QueryPacksClientDeleteResponse struct { + // placeholder for future response values +} + +// QueryPacksClientGetResponse contains the response from method QueryPacksClient.Get. +type QueryPacksClientGetResponse struct { + // An Log Analytics QueryPack definition. + LogAnalyticsQueryPack +} + +// QueryPacksClientListByResourceGroupResponse contains the response from method QueryPacksClient.NewListByResourceGroupPager. +type QueryPacksClientListByResourceGroupResponse struct { + // Describes the list of Log Analytics QueryPack resources. + LogAnalyticsQueryPackListResult +} + +// QueryPacksClientListResponse contains the response from method QueryPacksClient.NewListPager. +type QueryPacksClientListResponse struct { + // Describes the list of Log Analytics QueryPack resources. + LogAnalyticsQueryPackListResult +} + +// QueryPacksClientUpdateTagsResponse contains the response from method QueryPacksClient.UpdateTags. +type QueryPacksClientUpdateTagsResponse struct { + // An Log Analytics QueryPack definition. + LogAnalyticsQueryPack +} + // SavedSearchesClientCreateOrUpdateResponse contains the response from method SavedSearchesClient.CreateOrUpdate. type SavedSearchesClientCreateOrUpdateResponse struct { // Value object for saved search results. @@ -257,6 +333,17 @@ type StorageInsightConfigsClientListByWorkspaceResponse struct { StorageInsightListResult } +// TablesClientCreateOrUpdateResponse contains the response from method TablesClient.BeginCreateOrUpdate. +type TablesClientCreateOrUpdateResponse struct { + // Workspace data table definition. + Table +} + +// TablesClientDeleteResponse contains the response from method TablesClient.BeginDelete. +type TablesClientDeleteResponse struct { + // placeholder for future response values +} + // TablesClientGetResponse contains the response from method TablesClient.Get. type TablesClientGetResponse struct { // Workspace data table definition. @@ -269,7 +356,12 @@ type TablesClientListByWorkspaceResponse struct { TablesListResult } -// TablesClientUpdateResponse contains the response from method TablesClient.Update. +// TablesClientMigrateResponse contains the response from method TablesClient.Migrate. +type TablesClientMigrateResponse struct { + // placeholder for future response values +} + +// TablesClientUpdateResponse contains the response from method TablesClient.BeginUpdate. type TablesClientUpdateResponse struct { // Workspace data table definition. Table diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/savedsearches_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/savedsearches_client_example_test.go index f3013994d670..9c2e10e453f5 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/savedsearches_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/savedsearches_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesDeleteSavedSearches.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesDeleteSavedSearches.json func ExampleSavedSearchesClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -35,7 +35,7 @@ func ExampleSavedSearchesClient_Delete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesCreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesCreateOrUpdate.json func ExampleSavedSearchesClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -81,7 +81,7 @@ func ExampleSavedSearchesClient_CreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesGet.json func ExampleSavedSearchesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -113,7 +113,7 @@ func ExampleSavedSearchesClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json func ExampleSavedSearchesClient_ListByWorkspace() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/savedsearches_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/savedsearches_live_test.go index d3be07a31c9d..af8889935589 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/savedsearches_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/savedsearches_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/schema_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/schema_client_example_test.go index 438e791b1b06..7b4080d839d7 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/schema_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/schema_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesGetSchema.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesGetSchema.json func ExampleSchemaClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/sharedkeys_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/sharedkeys_client_example_test.go index 7b867e8032cd..2c84e0b118a1 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/sharedkeys_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/sharedkeys_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesGetSharedKeys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesGetSharedKeys.json func ExampleSharedKeysClient_GetSharedKeys() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -41,7 +41,7 @@ func ExampleSharedKeysClient_GetSharedKeys() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesRegenerateSharedKeys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesRegenerateSharedKeys.json func ExampleSharedKeysClient_Regenerate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/storageinsightconfigs_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/storageinsightconfigs_client_example_test.go index 3c082d9e8dde..517466cee483 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/storageinsightconfigs_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/storageinsightconfigs_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsCreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsCreateOrUpdate.json func ExampleStorageInsightConfigsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -69,7 +69,7 @@ func ExampleStorageInsightConfigsClient_CreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsGet.json func ExampleStorageInsightConfigsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -108,7 +108,7 @@ func ExampleStorageInsightConfigsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsDelete.json func ExampleStorageInsightConfigsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -125,7 +125,7 @@ func ExampleStorageInsightConfigsClient_Delete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsListByWorkspace.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsListByWorkspace.json func ExampleStorageInsightConfigsClient_NewListByWorkspacePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/storageinsightconfigs_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/storageinsightconfigs_live_test.go index 12770843fc2d..95e487f91426 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/storageinsightconfigs_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/storageinsightconfigs_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/tables_client.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/tables_client.go index 258777ef3fa1..a0e518996093 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/tables_client.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/tables_client.go @@ -43,10 +43,177 @@ func NewTablesClient(subscriptionID string, credential azcore.TokenCredential, o return client, nil } +// BeginCreateOrUpdate - Update or Create a Log Analytics workspace table. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the workspace. +// - tableName - The name of the table. +// - parameters - The parameters required to update table properties. +// - options - TablesClientBeginCreateOrUpdateOptions contains the optional parameters for the TablesClient.BeginCreateOrUpdate +// method. +func (client *TablesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesClientBeginCreateOrUpdateOptions) (*runtime.Poller[TablesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, workspaceName, tableName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TablesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TablesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Update or Create a Log Analytics workspace table. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +func (client *TablesClient) createOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "TablesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, tableName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TablesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}" + 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 workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if tableName == "" { + return nil, errors.New("parameter tableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a Log Analytics workspace table. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the workspace. +// - tableName - The name of the table. +// - options - TablesClientBeginDeleteOptions contains the optional parameters for the TablesClient.BeginDelete method. +func (client *TablesClient) BeginDelete(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *TablesClientBeginDeleteOptions) (*runtime.Poller[TablesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, workspaceName, tableName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TablesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TablesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a Log Analytics workspace table. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +func (client *TablesClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *TablesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "TablesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, tableName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TablesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *TablesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}" + 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 workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if tableName == "" { + return nil, errors.New("parameter tableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + // Get - Gets a Log Analytics workspace table. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-08-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The name of the workspace. // - tableName - The name of the table. @@ -97,7 +264,7 @@ func (client *TablesClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-08-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -114,7 +281,7 @@ func (client *TablesClient) getHandleResponse(resp *http.Response) (TablesClient // NewListByWorkspacePager - Gets all the tables for the specified Log Analytics workspace. // -// Generated from API version 2020-08-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The name of the workspace. // - options - TablesClientListByWorkspaceOptions contains the optional parameters for the TablesClient.NewListByWorkspacePager @@ -163,7 +330,7 @@ func (client *TablesClient) listByWorkspaceCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-08-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -178,39 +345,120 @@ func (client *TablesClient) listByWorkspaceHandleResponse(resp *http.Response) ( return result, nil } -// Update - Updates a Log Analytics workspace table properties. +// Migrate - Migrate a Log Analytics table from support of the Data Collector API and Custom Fields features to support of +// Data Collection Rule-based Custom Logs. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The name of the workspace. +// - tableName - The name of the table. +// - options - TablesClientMigrateOptions contains the optional parameters for the TablesClient.Migrate method. +func (client *TablesClient) Migrate(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *TablesClientMigrateOptions) (TablesClientMigrateResponse, error) { + var err error + const operationName = "TablesClient.Migrate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.migrateCreateRequest(ctx, resourceGroupName, workspaceName, tableName, options) + if err != nil { + return TablesClientMigrateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TablesClientMigrateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TablesClientMigrateResponse{}, err + } + return TablesClientMigrateResponse{}, nil +} + +// migrateCreateRequest creates the Migrate request. +func (client *TablesClient) migrateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *TablesClientMigrateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate" + 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 workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if tableName == "" { + return nil, errors.New("parameter tableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) + 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-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginUpdate - Update a Log Analytics workspace table. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-08-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The name of the workspace. // - tableName - The name of the table. // - parameters - The parameters required to update table properties. -// - options - TablesClientUpdateOptions contains the optional parameters for the TablesClient.Update method. -func (client *TablesClient) Update(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesClientUpdateOptions) (TablesClientUpdateResponse, error) { +// - options - TablesClientBeginUpdateOptions contains the optional parameters for the TablesClient.BeginUpdate method. +func (client *TablesClient) BeginUpdate(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesClientBeginUpdateOptions) (*runtime.Poller[TablesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, workspaceName, tableName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TablesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TablesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a Log Analytics workspace table. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +func (client *TablesClient) update(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesClientBeginUpdateOptions) (*http.Response, error) { var err error - const operationName = "TablesClient.Update" + const operationName = "TablesClient.BeginUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, workspaceName, tableName, parameters, options) if err != nil { - return TablesClientUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return TablesClientUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return TablesClientUpdateResponse{}, err + return nil, err } - resp, err := client.updateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // updateCreateRequest creates the Update request. -func (client *TablesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesClientUpdateOptions) (*policy.Request, error) { +func (client *TablesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -233,7 +481,7 @@ func (client *TablesClient) updateCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-08-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -241,12 +489,3 @@ func (client *TablesClient) updateCreateRequest(ctx context.Context, resourceGro } return req, nil } - -// updateHandleResponse handles the Update response. -func (client *TablesClient) updateHandleResponse(resp *http.Response) (TablesClientUpdateResponse, error) { - result := TablesClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Table); err != nil { - return TablesClientUpdateResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/tables_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/tables_client_example_test.go index 20f3158dd0c0..0e904d31f168 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/tables_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/tables_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/TablesList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/TablesList.json func ExampleTablesClient_NewListByWorkspacePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -43,32 +43,169 @@ func ExampleTablesClient_NewListByWorkspacePager() { // page.TablesListResult = armoperationalinsights.TablesListResult{ // Value: []*armoperationalinsights.Table{ // { - // Name: to.Ptr("table1"), - // ID: to.Ptr("/subscriptions/594038b5-1093-476e-a366-482775671c11/resourcegroups/calbot-rg/providers/microsoft.operationalinsights/workspaces/testresourcelock/tables/table1"), + // Name: to.Ptr("AzureNetworkFlow"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/oiautorest6685/providers/Microsoft.OperationalInsights/workspaces/oiautorest6685/tables/AzureNetworkFlow"), // Properties: &armoperationalinsights.TableProperties{ - // RetentionInDays: to.Ptr[int32](30), + // Schema: &armoperationalinsights.Schema{ + // Name: to.Ptr("AzureNetworkFlow"), + // Solutions: []*string{ + // to.Ptr("LogManagement")}, + // StandardColumns: []*armoperationalinsights.Column{ + // { + // Name: to.Ptr("TenantId"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumGUID), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(true), + // }, + // { + // Name: to.Ptr("SourceSystem"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("TimeGenerated"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumDateTime), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("AgentID"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("SourceIP"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Protocol"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("SourcePort"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("DestinationPort"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("TcpFlags"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Packets"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Bytes"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("BytesOut"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("DurationInMs"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("RstCount"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("MaxSampleRtt"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }}, + // TableSubType: to.Ptr(armoperationalinsights.TableSubTypeEnumAny), + // TableType: to.Ptr(armoperationalinsights.TableTypeEnumMicrosoft), + // }, + // ArchiveRetentionInDays: to.Ptr[int32](25), + // Plan: to.Ptr(armoperationalinsights.TablePlanEnumAnalytics), + // ProvisioningState: to.Ptr(armoperationalinsights.ProvisioningStateEnumSucceeded), + // RetentionInDays: to.Ptr[int32](45), + // TotalRetentionInDays: to.Ptr[int32](70), + // }, // }, - // }, - // { - // Name: to.Ptr("table2"), - // ID: to.Ptr("/subscriptions/594038b5-1093-476e-a366-482775671c11/resourcegroups/calbot-rg/providers/microsoft.operationalinsights/workspaces/testresourcelock/tables/table2"), - // Properties: &armoperationalinsights.TableProperties{ - // RetentionInDays: to.Ptr[int32](30), - // }, - // }, - // { - // Name: to.Ptr("table3"), - // ID: to.Ptr("/subscriptions/594038b5-1093-476e-a366-482775671c11/resourcegroups/calbot-rg/providers/microsoft.operationalinsights/workspaces/testresourcelock/tables/table3"), - // Properties: &armoperationalinsights.TableProperties{ - // RetentionInDays: to.Ptr[int32](30), - // }, - // }}, - // } + // { + // Name: to.Ptr("SurfaceHubDns"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/oiautorest6685/providers/Microsoft.OperationalInsights/workspaces/oiautorest6685/tables/SurfaceHubDns"), + // Properties: &armoperationalinsights.TableProperties{ + // Schema: &armoperationalinsights.Schema{ + // Name: to.Ptr("SurfaceHubDns"), + // Solutions: []*string{ + // to.Ptr("LogManagement")}, + // StandardColumns: []*armoperationalinsights.Column{ + // { + // Name: to.Ptr("TenantId"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumGUID), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(true), + // }, + // { + // Name: to.Ptr("SourceSystem"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("TimeGenerated"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumDateTime), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("QueryName"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("ComputerName"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }}, + // TableSubType: to.Ptr(armoperationalinsights.TableSubTypeEnumAny), + // TableType: to.Ptr(armoperationalinsights.TableTypeEnumMicrosoft), + // }, + // ArchiveRetentionInDays: to.Ptr[int32](0), + // Plan: to.Ptr(armoperationalinsights.TablePlanEnumAnalytics), + // ProvisioningState: to.Ptr(armoperationalinsights.ProvisioningStateEnumSucceeded), + // RetentionInDays: to.Ptr[int32](30), + // TotalRetentionInDays: to.Ptr[int32](30), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/TablesUpdate.json -func ExampleTablesClient_Update() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/TablesUpsert.json +func ExampleTablesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -78,27 +215,149 @@ func ExampleTablesClient_Update() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewTablesClient().Update(ctx, "oiautorest6685", "oiautorest6685", "table1", armoperationalinsights.Table{ + poller, err := clientFactory.NewTablesClient().BeginCreateOrUpdate(ctx, "oiautorest6685", "oiautorest6685", "AzureNetworkFlow", armoperationalinsights.Table{ Properties: &armoperationalinsights.TableProperties{ - RetentionInDays: to.Ptr[int32](30), + Schema: &armoperationalinsights.Schema{ + Name: to.Ptr("AzureNetworkFlow"), + Columns: []*armoperationalinsights.Column{ + { + Name: to.Ptr("MyNewColumn"), + Type: to.Ptr(armoperationalinsights.ColumnTypeEnumGUID), + }}, + }, + RetentionInDays: to.Ptr[int32](45), + TotalRetentionInDays: to.Ptr[int32](70), }, }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // res.Table = armoperationalinsights.Table{ - // Name: to.Ptr("table1"), - // ID: to.Ptr("/subscriptions/594038b5-1093-476e-a366-482775671c11/resourcegroups/calbot-rg/providers/microsoft.operationalinsights/workspaces/testresourcelock/tables/table1"), + // Name: to.Ptr("AzureNetworkFlow"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/oiautorest6685/providers/Microsoft.OperationalInsights/workspaces/oiautorest6685/tables/AzureNetworkFlow"), // Properties: &armoperationalinsights.TableProperties{ - // RetentionInDays: to.Ptr[int32](30), - // }, - // } + // Schema: &armoperationalinsights.Schema{ + // Name: to.Ptr("AzureNetworkFlow"), + // Columns: []*armoperationalinsights.Column{ + // { + // Name: to.Ptr("MyNewColumn"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumGUID), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }}, + // Solutions: []*string{ + // to.Ptr("LogManagement")}, + // StandardColumns: []*armoperationalinsights.Column{ + // { + // Name: to.Ptr("TenantId"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumGUID), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(true), + // }, + // { + // Name: to.Ptr("SourceSystem"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("TimeGenerated"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumDateTime), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("AgentID"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("SourceIP"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Protocol"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("SourcePort"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("DestinationPort"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("TcpFlags"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Packets"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Bytes"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("BytesOut"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("DurationInMs"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("RstCount"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("MaxSampleRtt"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumInt), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }}, + // TableSubType: to.Ptr(armoperationalinsights.TableSubTypeEnumDataCollectionRuleBased), + // TableType: to.Ptr(armoperationalinsights.TableTypeEnumMicrosoft), + // }, + // ArchiveRetentionInDays: to.Ptr[int32](25), + // Plan: to.Ptr(armoperationalinsights.TablePlanEnumAnalytics), + // ProvisioningState: to.Ptr(armoperationalinsights.ProvisioningStateEnumSucceeded), + // RetentionInDays: to.Ptr[int32](45), + // TotalRetentionInDays: to.Ptr[int32](70), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/TablesGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/TablesGet.json func ExampleTablesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -109,7 +368,7 @@ func ExampleTablesClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewTablesClient().Get(ctx, "oiautorest6685", "oiautorest6685", "table1", nil) + res, err := clientFactory.NewTablesClient().Get(ctx, "oiautorest6685", "oiautorest6685", "table1_SRCH", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -117,10 +376,120 @@ func ExampleTablesClient_Get() { _ = 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.Table = armoperationalinsights.Table{ - // Name: to.Ptr("table1"), - // ID: to.Ptr("/subscriptions/594038b5-1093-476e-a366-482775671c11/resourcegroups/calbot-rg/providers/microsoft.operationalinsights/workspaces/testresourcelock/tables/table1"), + // Name: to.Ptr("table1_SRCH"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/oiautorest6685/providers/Microsoft.OperationalInsights/workspaces/oiautorest6685/tables/table1_SRCH"), // Properties: &armoperationalinsights.TableProperties{ - // RetentionInDays: to.Ptr[int32](30), - // }, - // } + // Schema: &armoperationalinsights.Schema{ + // Name: to.Ptr("table1_SRCH"), + // Columns: []*armoperationalinsights.Column{ + // }, + // SearchResults: &armoperationalinsights.SearchResults{ + // Description: to.Ptr("This table was created using a Search Job with the following query: 'Heartbeat | where SourceSystem != '' | project SourceSystem'."), + // EndSearchTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T04:05:06.000Z"); return t}()), + // Limit: to.Ptr[int32](1000), + // Query: to.Ptr("Heartbeat | where SourceSystem != '' | project SourceSystem"), + // SourceTable: to.Ptr("Heartbeat"), + // StartSearchTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T04:05:06.000Z"); return t}()), + // }, + // Solutions: []*string{ + // to.Ptr("LogManagement")}, + // StandardColumns: []*armoperationalinsights.Column{ + // { + // Name: to.Ptr("TenantId"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumGUID), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("SourceSystem"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("MG"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumGUID), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("ManagementGroupName"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("TimeGenerated"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumDateTime), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Computer"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }, + // { + // Name: to.Ptr("RawData"), + // Type: to.Ptr(armoperationalinsights.ColumnTypeEnumString), + // IsDefaultDisplay: to.Ptr(false), + // IsHidden: to.Ptr(false), + // }}, + // TableSubType: to.Ptr(armoperationalinsights.TableSubTypeEnumDataCollectionRuleBased), + // TableType: to.Ptr(armoperationalinsights.TableTypeEnumSearchResults), + // }, + // ArchiveRetentionInDays: to.Ptr[int32](0), + // Plan: to.Ptr(armoperationalinsights.TablePlanEnumAnalytics), + // ProvisioningState: to.Ptr(armoperationalinsights.ProvisioningStateEnumSucceeded), + // ResultStatistics: &armoperationalinsights.ResultStatistics{ + // IngestedRecords: to.Ptr[int32](5), + // Progress: to.Ptr[float32](75), + // }, + // RetentionInDays: to.Ptr[int32](50), + // TotalRetentionInDays: to.Ptr[int32](50), + // }, + // SystemData: &armoperationalinsights.SystemDataAutoGenerated{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T04:05:06.000Z"); return t}()), + // CreatedBy: to.Ptr("00000000-0000-0000-0000-00000000000"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/TablesDelete.json +func ExampleTablesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTablesClient().BeginDelete(ctx, "oiautorest6685", "oiautorest6685", "table1_CL", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/TablesMigrate.json +func ExampleTablesClient_Migrate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewTablesClient().Migrate(ctx, "oiautorest6685", "oiautorest6685", "table1_CL", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } } diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/time_rfc3339.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/time_rfc3339.go index e5446c3d567a..7bf9f575bbc2 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/time_rfc3339.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // 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+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + 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 @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + 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 { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + 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)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { 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 @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/usages_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/usages_client_example_test.go index 0d531b9d9e6c..bdb97088fdff 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/usages_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/usages_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesListUsages.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesListUsages.json func ExampleUsagesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspacepurge_client.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspacepurge_client.go index 173bcc5fd980..e9c7337958b8 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspacepurge_client.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspacepurge_client.go @@ -117,7 +117,10 @@ func (client *WorkspacePurgeClient) getPurgeStatusHandleResponse(resp *http.Resp // 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. +// to using for a purge request to verify that the results are expected. Log +// Analytics only supports purge operations required for compliance with GDPR. The Log Analytics product team reserves the +// right to reject requests for purge operations that are not for the purpose of +// GDPR compliance. In the event of a dispute, please create a support ticket // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2020-08-01 diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspacepurge_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspacepurge_client_example_test.go index 9c424567e726..12e7f600757d 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspacepurge_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspacepurge_client_example_test.go @@ -15,11 +15,11 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesPurge.json -func ExampleWorkspacePurgeClient_Purge() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesPurge.json +func ExampleWorkspacePurgeClient_Purge_workspacePurge() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -43,7 +43,32 @@ func ExampleWorkspacePurgeClient_Purge() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesPurgeOperation.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesPurgeResourceId.json +func ExampleWorkspacePurgeClient_Purge_workspacePurgeResourceId() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armoperationalinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewWorkspacePurgeClient().Purge(ctx, "OIAutoRest5123", "aztest5048", armoperationalinsights.WorkspacePurgeBody{ + Filters: []*armoperationalinsights.WorkspacePurgeBodyFilters{ + { + Column: to.Ptr("_ResourceId"), + Operator: to.Ptr("=="), + Value: "/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/SomeResourceGroup/providers/microsoft.insights/components/AppInsightResource", + }}, + Table: to.Ptr("Heartbeat"), + }, 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/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesPurgeOperation.json func ExampleWorkspacePurgeClient_GetPurgeStatus() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_client.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_client.go index a8a421390c15..571445653fbe 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_client.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_client.go @@ -47,7 +47,7 @@ func NewWorkspacesClient(subscriptionID string, credential azcore.TokenCredentia // BeginCreateOrUpdate - Create or update a workspace. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The name of the workspace. // - parameters - The parameters required to create or update a workspace. @@ -73,7 +73,7 @@ func (client *WorkspacesClient) BeginCreateOrUpdate(ctx context.Context, resourc // CreateOrUpdate - Create or update a workspace. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview func (client *WorkspacesClient) createOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, parameters Workspace, options *WorkspacesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "WorkspacesClient.BeginCreateOrUpdate" @@ -115,7 +115,7 @@ func (client *WorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -129,7 +129,7 @@ func (client *WorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, // another workspace. To remove the workspace completely and release the name, use the force flag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The name of the workspace. // - options - WorkspacesClientBeginDeleteOptions contains the optional parameters for the WorkspacesClient.BeginDelete method. @@ -155,7 +155,7 @@ func (client *WorkspacesClient) BeginDelete(ctx context.Context, resourceGroupNa // another workspace. To remove the workspace completely and release the name, use the force flag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview func (client *WorkspacesClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "WorkspacesClient.BeginDelete" @@ -197,7 +197,7 @@ func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2021-12-01-preview") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } @@ -209,7 +209,7 @@ func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourc // Get - Gets a workspace instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The name of the workspace. // - options - WorkspacesClientGetOptions contains the optional parameters for the WorkspacesClient.Get method. @@ -255,7 +255,7 @@ func (client *WorkspacesClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -272,7 +272,7 @@ func (client *WorkspacesClient) getHandleResponse(resp *http.Response) (Workspac // NewListPager - Gets the workspaces in a subscription. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview // - options - WorkspacesClientListOptions contains the optional parameters for the WorkspacesClient.NewListPager method. func (client *WorkspacesClient) NewListPager(options *WorkspacesClientListOptions) *runtime.Pager[WorkspacesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[WorkspacesClientListResponse]{ @@ -310,7 +310,7 @@ func (client *WorkspacesClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -327,7 +327,7 @@ func (client *WorkspacesClient) listHandleResponse(resp *http.Response) (Workspa // NewListByResourceGroupPager - Gets workspaces in a resource group. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - WorkspacesClientListByResourceGroupOptions contains the optional parameters for the WorkspacesClient.NewListByResourceGroupPager // method. @@ -371,7 +371,7 @@ func (client *WorkspacesClient) listByResourceGroupCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -389,7 +389,7 @@ func (client *WorkspacesClient) listByResourceGroupHandleResponse(resp *http.Res // Update - Updates a workspace. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The name of the workspace. // - parameters - The parameters required to patch a workspace. @@ -436,7 +436,7 @@ func (client *WorkspacesClient) updateCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_client_example_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_client_example_test.go index 910b92418247..26c2b65e0c71 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_client_example_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/WorkspacesSubscriptionList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/WorkspacesSubscriptionList.json func ExampleWorkspacesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -65,7 +65,7 @@ func ExampleWorkspacesClient_NewListPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/WorkspacesListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/WorkspacesListByResourceGroup.json func ExampleWorkspacesClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -112,7 +112,7 @@ func ExampleWorkspacesClient_NewListByResourceGroupPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/WorkspacesCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/WorkspacesCreate.json func ExampleWorkspacesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -166,7 +166,7 @@ func ExampleWorkspacesClient_BeginCreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/WorkspacesDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/WorkspacesDelete.json func ExampleWorkspacesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -187,7 +187,7 @@ func ExampleWorkspacesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/WorkspacesGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/WorkspacesGet.json func ExampleWorkspacesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -209,7 +209,7 @@ func ExampleWorkspacesClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/WorkspacesUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4ce13e8353a25125a41bc01705c0a7794dac32a7/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2021-12-01-preview/examples/WorkspacesUpdate.json func ExampleWorkspacesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_live_test.go b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_live_test.go index 2678e82fb8f7..645ebd37534c 100644 --- a/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_live_test.go +++ b/sdk/resourcemanager/operationalinsights/armoperationalinsights/workspaces_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights/v2" "github.com/stretchr/testify/suite" )