diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/CHANGELOG.md b/sdk/resourcemanager/resourcegraph/armresourcegraph/CHANGELOG.md index 85ae2179d301..117491b8605d 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/CHANGELOG.md +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/CHANGELOG.md @@ -1,5 +1,39 @@ # Release History +## 0.9.0 (2023-09-15) +### Breaking Changes + +- Field `Interface` of struct `ClientResourcesHistoryResponse` has been removed + +### Features Added + +- New enum type `ChangeCategory` with values `ChangeCategorySystem`, `ChangeCategoryUser` +- New enum type `ChangeType` with values `ChangeTypeCreate`, `ChangeTypeDelete`, `ChangeTypeUpdate` +- New enum type `PropertyChangeType` with values `PropertyChangeTypeInsert`, `PropertyChangeTypeRemove`, `PropertyChangeTypeUpdate` +- New enum type `Role` with values `RoleAssistant`, `RoleSystem`, `RoleUser` +- New enum type `StatusCategory` with values `StatusCategoryFailed`, `StatusCategorySucceeded` +- New enum type `Versions` with values `VersionsV20230901Preview` +- New function `*Client.ResourceChangeDetails(context.Context, ResourceChangeDetailsRequestParameters, *ClientResourceChangeDetailsOptions) (ClientResourceChangeDetailsResponse, error)` +- New function `*Client.ResourceChanges(context.Context, ResourceChangesRequestParameters, *ClientResourceChangesOptions) (ClientResourceChangesResponse, error)` +- New function `*ClientFactory.NewQueryClient() *QueryClient` +- New function `NewQueryClient(azcore.TokenCredential, *arm.ClientOptions) (*QueryClient, error)` +- New function `*QueryClient.GenerateQuery(context.Context, QueryGenerationRequest, *QueryClientGenerateQueryOptions) (QueryClientGenerateQueryResponse, error)` +- New struct `HistoryContext` +- New struct `QueryGenerationRequest` +- New struct `QueryGenerationResponse` +- New struct `ResourceChangeData` +- New struct `ResourceChangeDataAfterSnapshot` +- New struct `ResourceChangeDataBeforeSnapshot` +- New struct `ResourceChangeDetailsRequestParameters` +- New struct `ResourceChangeList` +- New struct `ResourceChangesRequestParameters` +- New struct `ResourceChangesRequestParametersInterval` +- New struct `ResourcePropertyChange` +- New struct `ResourceSnapshotData` +- New struct `StatusResponse` +- New field `Value` in struct `ClientResourcesHistoryResponse` + + ## 0.8.1 (2023-07-19) ### Bug Fixes diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/autorest.md b/sdk/resourcemanager/resourcegraph/armresourcegraph/autorest.md index 27b04f8fb7ae..9f21d155cb19 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/autorest.md +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/autorest.md @@ -5,11 +5,11 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resourcegraph/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resourcegraph/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION module: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph -module-version: 0.8.1 +module-version: 0.9.0 azcore-version: 1.8.0-beta.1 generate-fakes: true inject-spans: true diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/client.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/client.go index 46057d4fd827..4572cafaa00c 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/client.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/client.go @@ -37,10 +37,118 @@ func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (* return client, nil } +// ResourceChangeDetails - Get resource change details. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2020-09-01-preview +// - parameters - The parameters for this request for resource change details. +// - options - ClientResourceChangeDetailsOptions contains the optional parameters for the Client.ResourceChangeDetails method. +func (client *Client) ResourceChangeDetails(ctx context.Context, parameters ResourceChangeDetailsRequestParameters, options *ClientResourceChangeDetailsOptions) (ClientResourceChangeDetailsResponse, error) { + var err error + const operationName = "Client.ResourceChangeDetails" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.resourceChangeDetailsCreateRequest(ctx, parameters, options) + if err != nil { + return ClientResourceChangeDetailsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientResourceChangeDetailsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientResourceChangeDetailsResponse{}, err + } + resp, err := client.resourceChangeDetailsHandleResponse(httpResp) + return resp, err +} + +// resourceChangeDetailsCreateRequest creates the ResourceChangeDetails request. +func (client *Client) resourceChangeDetailsCreateRequest(ctx context.Context, parameters ResourceChangeDetailsRequestParameters, options *ClientResourceChangeDetailsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ResourceGraph/resourceChangeDetails" + 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", "2020-09-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 +} + +// resourceChangeDetailsHandleResponse handles the ResourceChangeDetails response. +func (client *Client) resourceChangeDetailsHandleResponse(resp *http.Response) (ClientResourceChangeDetailsResponse, error) { + result := ClientResourceChangeDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceChangeDataArray); err != nil { + return ClientResourceChangeDetailsResponse{}, err + } + return result, nil +} + +// ResourceChanges - List changes to a resource for a given time interval. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2020-09-01-preview +// - parameters - the parameters for this request for changes. +// - options - ClientResourceChangesOptions contains the optional parameters for the Client.ResourceChanges method. +func (client *Client) ResourceChanges(ctx context.Context, parameters ResourceChangesRequestParameters, options *ClientResourceChangesOptions) (ClientResourceChangesResponse, error) { + var err error + const operationName = "Client.ResourceChanges" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.resourceChangesCreateRequest(ctx, parameters, options) + if err != nil { + return ClientResourceChangesResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientResourceChangesResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientResourceChangesResponse{}, err + } + resp, err := client.resourceChangesHandleResponse(httpResp) + return resp, err +} + +// resourceChangesCreateRequest creates the ResourceChanges request. +func (client *Client) resourceChangesCreateRequest(ctx context.Context, parameters ResourceChangesRequestParameters, options *ClientResourceChangesOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ResourceGraph/resourceChanges" + 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", "2020-09-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 +} + +// resourceChangesHandleResponse handles the ResourceChanges response. +func (client *Client) resourceChangesHandleResponse(resp *http.Response) (ClientResourceChangesResponse, error) { + result := ClientResourceChangesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceChangeList); err != nil { + return ClientResourceChangesResponse{}, err + } + return result, nil +} + // Resources - Queries the resources managed by Azure Resource Manager for scopes specified in the request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01-preview +// Generated from API version 2023-09-01-preview // - query - Request specifying query and its options. // - options - ClientResourcesOptions contains the optional parameters for the Client.Resources method. func (client *Client) Resources(ctx context.Context, query QueryRequest, options *ClientResourcesOptions) (ClientResourcesResponse, error) { @@ -73,7 +181,7 @@ func (client *Client) resourcesCreateRequest(ctx context.Context, query QueryReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01-preview") + reqQP.Set("api-version", "2023-09-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, query); err != nil { @@ -139,7 +247,7 @@ func (client *Client) resourcesHistoryCreateRequest(ctx context.Context, request // resourcesHistoryHandleResponse handles the ResourcesHistory response. func (client *Client) resourcesHistoryHandleResponse(resp *http.Response) (ClientResourcesHistoryResponse, error) { result := ClientResourcesHistoryResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Interface); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { return ClientResourcesHistoryResponse{}, err } return result, nil diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/client_example_test.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/client_example_test.go deleted file mode 100644 index 70ccce94075f..000000000000 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/client_example_test.go +++ /dev/null @@ -1,858 +0,0 @@ -//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 armresourcegraph_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesPropertiesQuery.json -func ExampleClient_Resources_accessAPropertiesField() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Query: to.Ptr("Resources | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by tostring(properties.storageProfile.osDisk.osType)"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // Count: to.Ptr[int64](2), - // Data: []any{ - // map[string]any{ - // "count": float64(7), - // "properties_storageProfile_osDisk_osType": "Linux", - // }, - // map[string]any{ - // "count": float64(23), - // "properties_storageProfile_osDisk_osType": "Windows", - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](2), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesMgBasicQuery.json -func ExampleClient_Resources_basicManagementGroupQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - ManagementGroups: []*string{ - to.Ptr("e927f598-c1d4-4f72-8541-95d83a6a4ac8"), - to.Ptr("ProductionMG")}, - Query: to.Ptr("Resources | project id, name, type, location, tags | limit 3"), - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // Count: to.Ptr[int64](3), - // Data: []any{ - // map[string]any{ - // "name": "myNetworkInterface", - // "type": "microsoft.network/networkinterfaces", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Network/networkInterfaces/myNetworkInterface", - // "location": "centralus", - // "tags":map[string]any{ - // "tag1": "Value1", - // }, - // }, - // map[string]any{ - // "name": "myVnet", - // "type": "microsoft.network/virtualnetworks", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Network/virtualNetworks/myVnet", - // "location": "westus", - // "tags":map[string]any{ - // }, - // }, - // map[string]any{ - // "name": "myPublicIp", - // "type": "microsoft.network/publicipaddresses", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Network/publicIPAddresses/myPublicIp", - // "location": "westus", - // "tags":map[string]any{ - // }, - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](3), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesBasicQuery.json -func ExampleClient_Resources_basicQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Query: to.Ptr("Resources | project id, name, type, location, tags | limit 3"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // Count: to.Ptr[int64](3), - // Data: []any{ - // map[string]any{ - // "name": "myNetworkInterface", - // "type": "microsoft.network/networkinterfaces", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Network/networkInterfaces/myNetworkInterface", - // "location": "centralus", - // "tags":map[string]any{ - // "tag1": "Value1", - // }, - // }, - // map[string]any{ - // "name": "myVnet", - // "type": "microsoft.network/virtualnetworks", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Network/virtualNetworks/myVnet", - // "location": "westus", - // "tags":map[string]any{ - // }, - // }, - // map[string]any{ - // "name": "myPublicIp", - // "type": "microsoft.network/publicipaddresses", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Network/publicIPAddresses/myPublicIp", - // "location": "westus", - // "tags":map[string]any{ - // }, - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](3), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesTenantBasicQuery.json -func ExampleClient_Resources_basicTenantQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Query: to.Ptr("Resources | project id, name, type, location, tags | limit 3"), - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // Count: to.Ptr[int64](3), - // Data: []any{ - // map[string]any{ - // "name": "myNetworkInterface", - // "type": "microsoft.network/networkinterfaces", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Network/networkInterfaces/myNetworkInterface", - // "location": "centralus", - // "tags":map[string]any{ - // "tag1": "Value1", - // }, - // }, - // map[string]any{ - // "name": "myVnet", - // "type": "microsoft.network/virtualnetworks", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Network/virtualNetworks/myVnet", - // "location": "westus", - // "tags":map[string]any{ - // }, - // }, - // map[string]any{ - // "name": "myPublicIp", - // "type": "microsoft.network/publicipaddresses", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Network/publicIPAddresses/myPublicIp", - // "location": "westus", - // "tags":map[string]any{ - // }, - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](3), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesComplexQuery.json -func ExampleClient_Resources_complexQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Query: to.Ptr("Resources | project id, name, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location | top 3 by count_"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // Count: to.Ptr[int64](3), - // Data: []any{ - // map[string]any{ - // "count_": float64(11), - // "location": "centralus", - // }, - // map[string]any{ - // "count_": float64(11), - // "location": "eastus", - // }, - // map[string]any{ - // "count_": float64(3), - // "location": "southcentralus", - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](3), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesFilterQuery.json -func ExampleClient_Resources_filterResources() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Query: to.Ptr("Resources | project id, name, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | limit 3"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // Count: to.Ptr[int64](3), - // Data: []any{ - // map[string]any{ - // "name": "myVm1", - // "type": "microsoft.compute/virtualmachines", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Compute/virtualMachines/myVm1", - // "location": "centralus", - // }, - // map[string]any{ - // "name": "myVirtualMachine", - // "type": "microsoft.compute/virtualmachines", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Compute/virtualMachines/myVirtualMachine", - // "location": "eastus", - // }, - // map[string]any{ - // "name": "testVm", - // "type": "microsoft.compute/virtualmachines", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG3/providers/Microsoft.Compute/virtualMachines/testVm", - // "location": "eastus", - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](3), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesFirstPageQuery.json -func ExampleClient_Resources_firstPageQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Options: &armresourcegraph.QueryRequestOptions{ - Skip: to.Ptr[int32](0), - Top: to.Ptr[int32](3), - }, - Query: to.Ptr("Resources | where name contains 'test' | project id, name, type, location"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // SkipToken: to.Ptr("eyAibm8iOiAibHVjayIsICJidXQiOiAibmljZSIsICJ0cnkiOiAiISIgfQ=="), - // Count: to.Ptr[int64](3), - // Data: []any{ - // map[string]any{ - // "name": "yetanothertest_OsDisk_1_f396cbcb625a457bb69fe2abf5975820", - // "type": "microsoft.compute/disks", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Compute/disks/yetanothertest_OsDisk_1_f396cbcb625a457bb69fe2abf5975820", - // "location": "eastus", - // }, - // map[string]any{ - // "name": "TestAA", - // "type": "microsoft.automation/automationaccounts", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Automation/automationAccounts/TestAA", - // "location": "westcentralus", - // }, - // map[string]any{ - // "name": "TestRB", - // "type": "microsoft.automation/automationaccounts/runbooks", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Automation/automationAccounts/TestAA/runbooks/TestRB", - // "location": "westcentralus", - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](386), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesNextPageQuery.json -func ExampleClient_Resources_nextPageQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Options: &armresourcegraph.QueryRequestOptions{ - SkipToken: to.Ptr("eyAibm8iOiAibHVjayIsICJidXQiOiAibmljZSIsICJ0cnkiOiAiISIgfQ=="), - }, - Query: to.Ptr("Resources | where name contains 'test' | project id, name, type, location"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // SkipToken: to.Ptr("eyAibm8yIjogImx1Y2syIiwgImJ1dDIiOiAibmljZTIiLCAidHJ5MiI6ICIhIiB9"), - // Count: to.Ptr[int64](3), - // Data: []any{ - // map[string]any{ - // "name": "second_OsDisk_dddddbcb625a457bb69fe2abf5975820", - // "type": "microsoft.compute/disks", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Compute/disks/second_OsDisk_dddddbcb625a457bb69fe2abf5975820", - // "location": "eastus", - // }, - // map[string]any{ - // "name": "AATest", - // "type": "microsoft.automation/automationaccounts", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Automation/automationAccounts/AATest", - // "location": "westcentralus", - // }, - // map[string]any{ - // "name": "RBTest", - // "type": "microsoft.automation/automationaccounts/runbooks", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Automation/automationAccounts/TestAA/runbooks/RBTest", - // "location": "westcentralus", - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](386), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesFacetQuery.json -func ExampleClient_Resources_queryWithAFacetRequest() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Facets: []*armresourcegraph.FacetRequest{ - { - Expression: to.Ptr("location"), - Options: &armresourcegraph.FacetRequestOptions{ - Top: to.Ptr[int32](3), - SortOrder: to.Ptr(armresourcegraph.FacetSortOrderDesc), - }, - }, - { - Expression: to.Ptr("properties.storageProfile.osDisk.osType"), - Options: &armresourcegraph.FacetRequestOptions{ - Top: to.Ptr[int32](3), - SortOrder: to.Ptr(armresourcegraph.FacetSortOrderDesc), - }, - }, - { - Expression: to.Ptr("nonExistingColumn"), - Options: &armresourcegraph.FacetRequestOptions{ - Top: to.Ptr[int32](3), - SortOrder: to.Ptr(armresourcegraph.FacetSortOrderDesc), - }, - }, - { - Expression: to.Ptr("resourceGroup"), - Options: &armresourcegraph.FacetRequestOptions{ - Top: to.Ptr[int32](3), - SortBy: to.Ptr("tolower(resourceGroup)"), - SortOrder: to.Ptr(armresourcegraph.FacetSortOrderAsc), - }, - }, - { - Expression: to.Ptr("resourceGroup"), - Options: &armresourcegraph.FacetRequestOptions{ - Top: to.Ptr[int32](3), - Filter: to.Ptr("resourceGroup contains 'test'"), - }, - }}, - Query: to.Ptr("Resources | where type =~ 'Microsoft.Compute/virtualMachines' | project id, name, location, resourceGroup, properties.storageProfile.osDisk.osType | limit 5"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // Count: to.Ptr[int64](5), - // Data: []any{ - // map[string]any{ - // "name": "myTestVm", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/B-TEST-RG/providers/Microsoft.Compute/virtualMachines/myTestVm", - // "location": "eastus", - // "properties_storageProfile_osDisk_osType": "Windows", - // "resourceGroup": "B-TEST-RG", - // }, - // map[string]any{ - // "name": "myTestAccountVm", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/c-rg/providers/Microsoft.Compute/virtualMachines/myTestAccountVm", - // "location": "westcentralus", - // "properties_storageProfile_osDisk_osType": "Windows", - // "resourceGroup": "c-rg", - // }, - // map[string]any{ - // "name": "yetanothertest", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/I-RG/providers/Microsoft.Compute/virtualMachines/yetanothertest", - // "location": "eastus", - // "properties_storageProfile_osDisk_osType": "Linux", - // "resourceGroup": "I-RG", - // }, - // map[string]any{ - // "name": "drafttest1bux4cv7a7q3aw", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/x-test-rg/providers/Microsoft.Compute/virtualMachines/drafttest1bux4cv7a7q3aw", - // "location": "southcentralus", - // "properties_storageProfile_osDisk_osType": "Linux", - // "resourceGroup": "x-test-rg", - // }, - // map[string]any{ - // "name": "testvmntp25370", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/y-rg/providers/Microsoft.Compute/virtualMachines/testvmntp25370", - // "location": "eastus", - // "properties_storageProfile_osDisk_osType": "Windows", - // "resourceGroup": "y-rg", - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // &armresourcegraph.FacetResult{ - // Expression: to.Ptr("location"), - // ResultType: to.Ptr("FacetResult"), - // Count: to.Ptr[int32](3), - // Data: []any{ - // map[string]any{ - // "count": float64(3), - // "location": "eastus", - // }, - // map[string]any{ - // "count": float64(1), - // "location": "southcentralus", - // }, - // map[string]any{ - // "count": float64(1), - // "location": "westcentralus", - // }, - // }, - // TotalRecords: to.Ptr[int64](3), - // }, - // &armresourcegraph.FacetResult{ - // Expression: to.Ptr("properties.storageProfile.osDisk.osType"), - // ResultType: to.Ptr("FacetResult"), - // Count: to.Ptr[int32](2), - // Data: []any{ - // map[string]any{ - // "count": float64(2), - // "properties_storageProfile_osDisk_osType": "Linux", - // }, - // map[string]any{ - // "count": float64(3), - // "properties_storageProfile_osDisk_osType": "Windows", - // }, - // }, - // TotalRecords: to.Ptr[int64](2), - // }, - // &armresourcegraph.FacetError{ - // Expression: to.Ptr("nonExistingColumn"), - // ResultType: to.Ptr("FacetError"), - // Errors: []*armresourcegraph.ErrorDetails{ - // { - // Code: to.Ptr("NoValidColumns"), - // Message: to.Ptr("No valid columns in facet expression."), - // }, - // { - // Code: to.Ptr("InvalidColumnNames"), - // Message: to.Ptr("Invalid column names: [nonExistingColumn]."), - // }}, - // }, - // &armresourcegraph.FacetResult{ - // Expression: to.Ptr("resourceGroup"), - // ResultType: to.Ptr("FacetResult"), - // Count: to.Ptr[int32](3), - // Data: []any{ - // map[string]any{ - // "count": float64(1), - // "resourceGroup": "B-TEST-RG", - // }, - // map[string]any{ - // "count": float64(1), - // "resourceGroup": "c-rg", - // }, - // map[string]any{ - // "count": float64(1), - // "resourceGroup": "I-RG", - // }, - // }, - // TotalRecords: to.Ptr[int64](5), - // }, - // &armresourcegraph.FacetResult{ - // Expression: to.Ptr("resourceGroup"), - // ResultType: to.Ptr("FacetResult"), - // Count: to.Ptr[int32](2), - // Data: []any{ - // map[string]any{ - // "count": float64(1), - // "resourceGroup": "B-TEST-RG", - // }, - // map[string]any{ - // "count": float64(1), - // "resourceGroup": "x-test-rg", - // }, - // }, - // TotalRecords: to.Ptr[int64](2), - // }}, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](5), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesRandomPageQuery.json -func ExampleClient_Resources_randomPageQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Options: &armresourcegraph.QueryRequestOptions{ - Skip: to.Ptr[int32](10), - Top: to.Ptr[int32](2), - }, - Query: to.Ptr("Resources | where name contains 'test' | project id, name, type, location"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // SkipToken: to.Ptr("eyAibm8iOiAibHVjayIsICJidXQiOiAibmljZSIsICJ0cnkiOiAiISIgfQ=="), - // Count: to.Ptr[int64](2), - // Data: []any{ - // map[string]any{ - // "name": "third_OsDisk_dddddbcb625a457bb69fe2abf5975820", - // "type": "microsoft.compute/disks", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Compute/disks/third_OsDisk_dddddbcb625a457bb69fe2abf5975820", - // "location": "eastus", - // }, - // map[string]any{ - // "name": "CCTest", - // "type": "microsoft.automation/automationaccounts", - // "id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Automation/automationAccounts/CCTest", - // "location": "westcentralus", - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](386), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesSummarizeQuery.json -func ExampleClient_Resources_summarizeResourcesByLocation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{ - Query: to.Ptr("Resources | project id, name, type, location | summarize by location"), - Subscriptions: []*string{ - to.Ptr("cfbbd179-59d2-4052-aa06-9270a38aa9d6")}, - }, 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.QueryResponse = armresourcegraph.QueryResponse{ - // Count: to.Ptr[int64](3), - // Data: []any{ - // map[string]any{ - // "location": "centralus", - // }, - // map[string]any{ - // "location": "eastus", - // }, - // map[string]any{ - // "location": "westus", - // }, - // }, - // Facets: []armresourcegraph.FacetClassification{ - // }, - // ResultTruncated: to.Ptr(armresourcegraph.ResultTruncatedFalse), - // TotalRecords: to.Ptr[int64](3), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesHistoryMgsGet.json -func ExampleClient_ResourcesHistory_resourceHistoryManagementGroupScopeQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().ResourcesHistory(ctx, armresourcegraph.ResourcesHistoryRequest{ - ManagementGroups: []*string{ - to.Ptr("e927f598-c1d4-4f72-8541-95d83a6a4ac8"), - to.Ptr("ProductionMG")}, - Options: &armresourcegraph.ResourcesHistoryRequestOptions{ - Interval: &armresourcegraph.DateTimeInterval{ - End: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T01:25:00.0000000Z"); return t }()), - Start: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T01:00:00.0000000Z"); return t }()), - }, - }, - Query: to.Ptr("where name =~ 'cpu-utilization' | project id, name, properties"), - }, 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.Interface = map[string]any{ - // "count": float64(2), - // "snapshots":map[string]any{ - // "columns":[]any{ - // map[string]any{ - // "name": "id", - // "type": "string", - // }, - // map[string]any{ - // "name": "name", - // "type": "string", - // }, - // map[string]any{ - // "name": "properties", - // "type": "object", - // }, - // }, - // "rows":[]any{ - // []any{ - // "/subscriptions/a7f33fdb-e646-4f15-89aa-3a360210861e/resourceGroups/meya-test-rg/providers/Microsoft.Compute/virtualMachines/meya-win-eus/providers/Microsoft.WorkloadMonitor/monitors/cpu-utilization", - // "cpu-utilization", - // map[string]any{ - // "currentStateFirstObservedTimestamp": "", - // "monitorName": "", - // }, - // }, - // []any{ - // "/subscriptions/a7f33fdb-e646-4f15-89aa-3a360210861e/resourceGroups/meya-test-rg/providers/Microsoft.Compute/virtualMachines/meya-win-eus/providers/Microsoft.WorkloadMonitor/monitors/cpu-utilization", - // "cpu-utilization", - // map[string]any{ - // "currentStateFirstObservedTimestamp": "", - // "monitorName": "test", - // }, - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/ResourcesHistoryGet.json -func ExampleClient_ResourcesHistory_resourceHistoryQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().ResourcesHistory(ctx, armresourcegraph.ResourcesHistoryRequest{ - Options: &armresourcegraph.ResourcesHistoryRequestOptions{ - Interval: &armresourcegraph.DateTimeInterval{ - End: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T01:25:00.0000000Z"); return t }()), - Start: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T01:00:00.0000000Z"); return t }()), - }, - }, - Query: to.Ptr("where name =~ 'cpu-utilization' | project id, name, properties"), - Subscriptions: []*string{ - to.Ptr("a7f33fdb-e646-4f15-89aa-3a360210861e")}, - }, 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.Interface = map[string]any{ - // "count": float64(2), - // "snapshots":map[string]any{ - // "columns":[]any{ - // map[string]any{ - // "name": "id", - // "type": "string", - // }, - // map[string]any{ - // "name": "name", - // "type": "string", - // }, - // map[string]any{ - // "name": "properties", - // "type": "object", - // }, - // }, - // "rows":[]any{ - // []any{ - // "/subscriptions/a7f33fdb-e646-4f15-89aa-3a360210861e/resourceGroups/meya-test-rg/providers/Microsoft.Compute/virtualMachines/meya-win-eus/providers/Microsoft.WorkloadMonitor/monitors/cpu-utilization", - // "cpu-utilization", - // map[string]any{ - // "currentStateFirstObservedTimestamp": "", - // "monitorName": "", - // }, - // }, - // []any{ - // "/subscriptions/a7f33fdb-e646-4f15-89aa-3a360210861e/resourceGroups/meya-test-rg/providers/Microsoft.Compute/virtualMachines/meya-win-eus/providers/Microsoft.WorkloadMonitor/monitors/cpu-utilization", - // "cpu-utilization", - // map[string]any{ - // "currentStateFirstObservedTimestamp": "", - // "monitorName": "test", - // }, - // }, - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/client_factory.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/client_factory.go index 9abcebc38f58..c173ced2f9bf 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/client_factory.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/client_factory.go @@ -44,3 +44,8 @@ func (c *ClientFactory) NewOperationsClient() *OperationsClient { subClient, _ := NewOperationsClient(c.credential, c.options) return subClient } + +func (c *ClientFactory) NewQueryClient() *QueryClient { + subClient, _ := NewQueryClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/constants.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/constants.go index 01c7d228c228..c11ccdeb5cb9 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/constants.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/constants.go @@ -10,7 +10,7 @@ package armresourcegraph const ( moduleName = "armresourcegraph" - moduleVersion = "v0.8.1" + moduleVersion = "v0.9.0" ) // AuthorizationScopeFilter - Defines what level of authorization resources should be returned based on the which subscriptions @@ -34,6 +34,40 @@ func PossibleAuthorizationScopeFilterValues() []AuthorizationScopeFilter { } } +// ChangeCategory - The change category. +type ChangeCategory string + +const ( + ChangeCategorySystem ChangeCategory = "System" + ChangeCategoryUser ChangeCategory = "User" +) + +// PossibleChangeCategoryValues returns the possible values for the ChangeCategory const type. +func PossibleChangeCategoryValues() []ChangeCategory { + return []ChangeCategory{ + ChangeCategorySystem, + ChangeCategoryUser, + } +} + +// ChangeType - The change type for snapshot. PropertyChanges will be provided in case of Update change type +type ChangeType string + +const ( + ChangeTypeCreate ChangeType = "Create" + ChangeTypeDelete ChangeType = "Delete" + ChangeTypeUpdate ChangeType = "Update" +) + +// PossibleChangeTypeValues returns the possible values for the ChangeType const type. +func PossibleChangeTypeValues() []ChangeType { + return []ChangeType{ + ChangeTypeCreate, + ChangeTypeDelete, + ChangeTypeUpdate, + } +} + // ColumnDataType - Data type of a column in a table. type ColumnDataType string @@ -74,6 +108,24 @@ func PossibleFacetSortOrderValues() []FacetSortOrder { } } +// PropertyChangeType - The property change Type +type PropertyChangeType string + +const ( + PropertyChangeTypeInsert PropertyChangeType = "Insert" + PropertyChangeTypeRemove PropertyChangeType = "Remove" + PropertyChangeTypeUpdate PropertyChangeType = "Update" +) + +// PossiblePropertyChangeTypeValues returns the possible values for the PropertyChangeType const type. +func PossiblePropertyChangeTypeValues() []PropertyChangeType { + return []PropertyChangeType{ + PropertyChangeTypeInsert, + PropertyChangeTypeRemove, + PropertyChangeTypeUpdate, + } +} + // ResultFormat - Defines in which format query result returned. type ResultFormat string @@ -105,3 +157,57 @@ func PossibleResultTruncatedValues() []ResultTruncated { ResultTruncatedTrue, } } + +// Role - The role which generates a specific message. Restricted to the user or assistant role. +type Role string + +const ( + // RoleAssistant - If a message was generated by ARG Query Generation service, then the role should be assistant + RoleAssistant Role = "assistant" + // RoleSystem - If a message provides high level instructions for the query generation, then the role should be system + RoleSystem Role = "system" + // RoleUser - If a message was generated by a human, the role should be assigned user + RoleUser Role = "user" +) + +// PossibleRoleValues returns the possible values for the Role const type. +func PossibleRoleValues() []Role { + return []Role{ + RoleAssistant, + RoleSystem, + RoleUser, + } +} + +// StatusCategory - Status Category +type StatusCategory string + +const ( + // StatusCategoryFailed - Failed when query was not generated + StatusCategoryFailed StatusCategory = "Failed" + // StatusCategorySucceeded - Succeeded when query was generated successfully + StatusCategorySucceeded StatusCategory = "Succeeded" +) + +// PossibleStatusCategoryValues returns the possible values for the StatusCategory const type. +func PossibleStatusCategoryValues() []StatusCategory { + return []StatusCategory{ + StatusCategoryFailed, + StatusCategorySucceeded, + } +} + +// Versions - Versions Info. +type Versions string + +const ( + // VersionsV20230901Preview - The 2023-09-01-preview version. + VersionsV20230901Preview Versions = "2023-09-01-preview" +) + +// PossibleVersionsValues returns the possible values for the Versions const type. +func PossibleVersionsValues() []Versions { + return []Versions{ + VersionsV20230901Preview, + } +} diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/fake/query_server.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/fake/query_server.go new file mode 100644 index 000000000000..70cd5734f96b --- /dev/null +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/fake/query_server.go @@ -0,0 +1,88 @@ +//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/resourcemanager/resourcegraph/armresourcegraph" + "net/http" +) + +// QueryServer is a fake server for instances of the armresourcegraph.QueryClient type. +type QueryServer struct { + // GenerateQuery is the fake for method QueryClient.GenerateQuery + // HTTP status codes to indicate success: http.StatusOK + GenerateQuery func(ctx context.Context, body armresourcegraph.QueryGenerationRequest, options *armresourcegraph.QueryClientGenerateQueryOptions) (resp azfake.Responder[armresourcegraph.QueryClientGenerateQueryResponse], errResp azfake.ErrorResponder) +} + +// NewQueryServerTransport creates a new instance of QueryServerTransport with the provided implementation. +// The returned QueryServerTransport instance is connected to an instance of armresourcegraph.QueryClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewQueryServerTransport(srv *QueryServer) *QueryServerTransport { + return &QueryServerTransport{srv: srv} +} + +// QueryServerTransport connects instances of armresourcegraph.QueryClient to instances of QueryServer. +// Don't use this type directly, use NewQueryServerTransport instead. +type QueryServerTransport struct { + srv *QueryServer +} + +// Do implements the policy.Transporter interface for QueryServerTransport. +func (q *QueryServerTransport) 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 "QueryClient.GenerateQuery": + resp, err = q.dispatchGenerateQuery(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (q *QueryServerTransport) dispatchGenerateQuery(req *http.Request) (*http.Response, error) { + if q.srv.GenerateQuery == nil { + return nil, &nonRetriableError{errors.New("fake for method GenerateQuery not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armresourcegraph.QueryGenerationRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.GenerateQuery(req.Context(), 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).QueryGenerationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/fake/server.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/fake/server.go index 9c3d9b6ec297..ee1df639d3b3 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/fake/server.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/fake/server.go @@ -21,6 +21,14 @@ import ( // Server is a fake server for instances of the armresourcegraph.Client type. type Server struct { + // ResourceChangeDetails is the fake for method Client.ResourceChangeDetails + // HTTP status codes to indicate success: http.StatusOK + ResourceChangeDetails func(ctx context.Context, parameters armresourcegraph.ResourceChangeDetailsRequestParameters, options *armresourcegraph.ClientResourceChangeDetailsOptions) (resp azfake.Responder[armresourcegraph.ClientResourceChangeDetailsResponse], errResp azfake.ErrorResponder) + + // ResourceChanges is the fake for method Client.ResourceChanges + // HTTP status codes to indicate success: http.StatusOK + ResourceChanges func(ctx context.Context, parameters armresourcegraph.ResourceChangesRequestParameters, options *armresourcegraph.ClientResourceChangesOptions) (resp azfake.Responder[armresourcegraph.ClientResourceChangesResponse], errResp azfake.ErrorResponder) + // Resources is the fake for method Client.Resources // HTTP status codes to indicate success: http.StatusOK Resources func(ctx context.Context, query armresourcegraph.QueryRequest, options *armresourcegraph.ClientResourcesOptions) (resp azfake.Responder[armresourcegraph.ClientResourcesResponse], errResp azfake.ErrorResponder) @@ -55,6 +63,10 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { var err error switch method { + case "Client.ResourceChangeDetails": + resp, err = s.dispatchResourceChangeDetails(req) + case "Client.ResourceChanges": + resp, err = s.dispatchResourceChanges(req) case "Client.Resources": resp, err = s.dispatchResources(req) case "Client.ResourcesHistory": @@ -70,6 +82,52 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { return resp, nil } +func (s *ServerTransport) dispatchResourceChangeDetails(req *http.Request) (*http.Response, error) { + if s.srv.ResourceChangeDetails == nil { + return nil, &nonRetriableError{errors.New("fake for method ResourceChangeDetails not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armresourcegraph.ResourceChangeDetailsRequestParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ResourceChangeDetails(req.Context(), 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).ResourceChangeDataArray, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchResourceChanges(req *http.Request) (*http.Response, error) { + if s.srv.ResourceChanges == nil { + return nil, &nonRetriableError{errors.New("fake for method ResourceChanges not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armresourcegraph.ResourceChangesRequestParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ResourceChanges(req.Context(), 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).ResourceChangeList, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (s *ServerTransport) dispatchResources(req *http.Request) (*http.Response, error) { if s.srv.Resources == nil { return nil, &nonRetriableError{errors.New("fake for method Resources not implemented")} @@ -109,7 +167,7 @@ func (s *ServerTransport) dispatchResourcesHistory(req *http.Request) (*http.Res 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).Interface, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Value, req) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/go.mod b/sdk/resourcemanager/resourcegraph/armresourcegraph/go.mod index fdb93d15018b..a6c5da6818ce 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/go.mod +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armre go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0-beta.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0-beta.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/go.sum b/sdk/resourcemanager/resourcegraph/armresourcegraph/go.sum index 3cb20742c931..1af13ba1bd8a 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/go.sum +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/go.sum @@ -1,31 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0-beta.1 h1:8t6ZZtkOCl+rx7uBn40Nj62ABVGkXK69U/En44wJIlE= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0-beta.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/models.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/models.go index d7a29d9ac329..66c7f622d93a 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/models.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/models.go @@ -144,6 +144,15 @@ func (f *FacetResult) GetFacet() *Facet { } } +// HistoryContext - History content generated by a user, assistant or system role +type HistoryContext struct { + // REQUIRED; Content generated by a given role + Content *string + + // REQUIRED; Role which generates the content e.g., user, assistant or system + Role *Role +} + // Operation - Resource Graph REST API operation definition. type Operation struct { // Display metadata associated with the operation. @@ -178,6 +187,24 @@ type OperationListResult struct { Value []*Operation } +// QueryGenerationRequest - Query Generation Request +type QueryGenerationRequest struct { + // REQUIRED; Prompt text from user + Prompt *string + + // A collection of chat history to provide context in query generation + History []*HistoryContext +} + +// QueryGenerationResponse - Query Generation Response +type QueryGenerationResponse struct { + // REQUIRED; Query generated for a given user prompt text + Query *string + + // REQUIRED; Status for the query generation result + Status *StatusResponse +} + // QueryRequest - Describes a query to be executed. type QueryRequest struct { // REQUIRED; The resources query. @@ -243,6 +270,149 @@ type QueryResponse struct { SkipToken *string } +// ResourceChangeData - Data on a specific change, represented by a pair of before and after resource snapshots. +type ResourceChangeData struct { + // REQUIRED; The snapshot after the change. + AfterSnapshot *ResourceChangeDataAfterSnapshot + + // REQUIRED; The snapshot before the change. + BeforeSnapshot *ResourceChangeDataBeforeSnapshot + + // REQUIRED; The change ID. Valid and unique within the specified resource only. + ChangeID *string + + // The change type for snapshot. PropertyChanges will be provided in case of Update change type + ChangeType *ChangeType + + // An array of resource property change + PropertyChanges []*ResourcePropertyChange + + // The resource for a change. + ResourceID *string +} + +// ResourceChangeDataAfterSnapshot - The snapshot after the change. +type ResourceChangeDataAfterSnapshot struct { + // REQUIRED; The time when the snapshot was created. The snapshot timestamp provides an approximation as to when a modification + // to a resource was detected. There can be a difference between the actual modification + // time and the detection time. This is due to differences in how operations that modify a resource are processed, versus + // how operation that record resource snapshots are processed. + Timestamp *time.Time + + // The resource snapshot content (in resourceChangeDetails response only). + Content any + + // The ID of the snapshot. + SnapshotID *string +} + +// ResourceChangeDataBeforeSnapshot - The snapshot before the change. +type ResourceChangeDataBeforeSnapshot struct { + // REQUIRED; The time when the snapshot was created. The snapshot timestamp provides an approximation as to when a modification + // to a resource was detected. There can be a difference between the actual modification + // time and the detection time. This is due to differences in how operations that modify a resource are processed, versus + // how operation that record resource snapshots are processed. + Timestamp *time.Time + + // The resource snapshot content (in resourceChangeDetails response only). + Content any + + // The ID of the snapshot. + SnapshotID *string +} + +// ResourceChangeDetailsRequestParameters - The parameters for a specific change details request. +type ResourceChangeDetailsRequestParameters struct { + // REQUIRED; Specifies the list of change IDs for a change details request. + ChangeIDs []*string + + // REQUIRED; Specifies the list of resources for a change details request. + ResourceIDs []*string +} + +// ResourceChangeList - A list of changes associated with a resource over a specific time interval. +type ResourceChangeList struct { + // The pageable value returned by the operation, i.e. a list of changes to the resource. + // * The list is ordered from the most recent changes to the least recent changes. + // * This list will be empty if there were no changes during the requested interval. + // * The Before snapshot timestamp value of the oldest change can be outside of the specified time interval. + Changes []*ResourceChangeData + + // Skip token that encodes the skip information while executing the current request + SkipToken any +} + +// ResourceChangesRequestParameters - The parameters for a specific changes request. +type ResourceChangesRequestParameters struct { + // REQUIRED; Specifies the date and time interval for a changes request. + Interval *ResourceChangesRequestParametersInterval + + // The flag if set to true will fetch property changes + FetchPropertyChanges *bool + + // The flag if set to true will fetch change snapshots + FetchSnapshots *bool + + // Specifies the list of resources for a changes request. + ResourceIDs []*string + + // Acts as the continuation token for paged responses. + SkipToken *string + + // The subscription id of resources to query the changes from. + SubscriptionID *string + + // The table name to query resources from. + Table *string + + // The maximum number of changes the client can accept in a paged response. + Top *int32 +} + +// ResourceChangesRequestParametersInterval - Specifies the date and time interval for a changes request. +type ResourceChangesRequestParametersInterval struct { + // REQUIRED; A datetime indicating the exclusive/open end of the time interval, i.e. [start,end). Specifying an end that occurs + // chronologically before start will result in an error. + End *time.Time + + // REQUIRED; A datetime indicating the inclusive/closed start of the time interval, i.e. [start, end). Specifying a start + // that occurs chronologically after end will result in an error. + Start *time.Time +} + +// ResourcePropertyChange - The resource property change +type ResourcePropertyChange struct { + // REQUIRED; The change category. + ChangeCategory *ChangeCategory + + // REQUIRED; The property change Type + PropertyChangeType *PropertyChangeType + + // REQUIRED; The property name + PropertyName *string + + // The property value in after snapshot + AfterValue *string + + // The property value in before snapshot + BeforeValue *string +} + +// ResourceSnapshotData - Data on a specific resource snapshot. +type ResourceSnapshotData struct { + // REQUIRED; The time when the snapshot was created. The snapshot timestamp provides an approximation as to when a modification + // to a resource was detected. There can be a difference between the actual modification + // time and the detection time. This is due to differences in how operations that modify a resource are processed, versus + // how operation that record resource snapshots are processed. + Timestamp *time.Time + + // The resource snapshot content (in resourceChangeDetails response only). + Content any + + // The ID of the snapshot. + SnapshotID *string +} + // ResourcesHistoryRequest - Describes a history request to be executed. type ResourcesHistoryRequest struct { // Azure management groups against which to execute the query. Example: [ 'mg1', 'mg2' ] @@ -277,6 +447,15 @@ type ResourcesHistoryRequestOptions struct { Top *int32 } +// StatusResponse - Status +type StatusResponse struct { + // REQUIRED; Status category for query generation result + Category *StatusCategory + + // REQUIRED; Status message for query generation result + Message *string +} + // Table - Query output in tabular format. type Table struct { // REQUIRED; Query result column descriptors. diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/models_serde.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/models_serde.go index 193a2d4c0b51..3f9f303c6241 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/models_serde.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/models_serde.go @@ -364,6 +364,37 @@ func (f *FacetResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type HistoryContext. +func (h HistoryContext) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "content", h.Content) + populate(objectMap, "role", h.Role) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HistoryContext. +func (h *HistoryContext) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "content": + err = unpopulate(val, "Content", &h.Content) + delete(rawMsg, key) + case "role": + err = unpopulate(val, "Role", &h.Role) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -465,6 +496,68 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type QueryGenerationRequest. +func (q QueryGenerationRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "history", q.History) + populate(objectMap, "prompt", q.Prompt) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryGenerationRequest. +func (q *QueryGenerationRequest) 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 "history": + err = unpopulate(val, "History", &q.History) + delete(rawMsg, key) + case "prompt": + err = unpopulate(val, "Prompt", &q.Prompt) + 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 QueryGenerationResponse. +func (q QueryGenerationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "query", q.Query) + populate(objectMap, "status", q.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryGenerationResponse. +func (q *QueryGenerationResponse) 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 "query": + err = unpopulate(val, "Query", &q.Query) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &q.Status) + 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 QueryRequest. func (q QueryRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -602,6 +695,349 @@ func (q *QueryResponse) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ResourceChangeData. +func (r ResourceChangeData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "afterSnapshot", r.AfterSnapshot) + populate(objectMap, "beforeSnapshot", r.BeforeSnapshot) + populate(objectMap, "changeId", r.ChangeID) + populate(objectMap, "changeType", r.ChangeType) + populate(objectMap, "propertyChanges", r.PropertyChanges) + populate(objectMap, "resourceId", r.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceChangeData. +func (r *ResourceChangeData) 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 "afterSnapshot": + err = unpopulate(val, "AfterSnapshot", &r.AfterSnapshot) + delete(rawMsg, key) + case "beforeSnapshot": + err = unpopulate(val, "BeforeSnapshot", &r.BeforeSnapshot) + delete(rawMsg, key) + case "changeId": + err = unpopulate(val, "ChangeID", &r.ChangeID) + delete(rawMsg, key) + case "changeType": + err = unpopulate(val, "ChangeType", &r.ChangeType) + delete(rawMsg, key) + case "propertyChanges": + err = unpopulate(val, "PropertyChanges", &r.PropertyChanges) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &r.ResourceID) + 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 ResourceChangeDataAfterSnapshot. +func (r ResourceChangeDataAfterSnapshot) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "content", r.Content) + populate(objectMap, "snapshotId", r.SnapshotID) + populateTimeRFC3339(objectMap, "timestamp", r.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceChangeDataAfterSnapshot. +func (r *ResourceChangeDataAfterSnapshot) 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 "content": + err = unpopulate(val, "Content", &r.Content) + delete(rawMsg, key) + case "snapshotId": + err = unpopulate(val, "SnapshotID", &r.SnapshotID) + delete(rawMsg, key) + case "timestamp": + err = unpopulateTimeRFC3339(val, "Timestamp", &r.Timestamp) + 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 ResourceChangeDataBeforeSnapshot. +func (r ResourceChangeDataBeforeSnapshot) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "content", r.Content) + populate(objectMap, "snapshotId", r.SnapshotID) + populateTimeRFC3339(objectMap, "timestamp", r.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceChangeDataBeforeSnapshot. +func (r *ResourceChangeDataBeforeSnapshot) 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 "content": + err = unpopulate(val, "Content", &r.Content) + delete(rawMsg, key) + case "snapshotId": + err = unpopulate(val, "SnapshotID", &r.SnapshotID) + delete(rawMsg, key) + case "timestamp": + err = unpopulateTimeRFC3339(val, "Timestamp", &r.Timestamp) + 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 ResourceChangeDetailsRequestParameters. +func (r ResourceChangeDetailsRequestParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "changeIds", r.ChangeIDs) + populate(objectMap, "resourceIds", r.ResourceIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceChangeDetailsRequestParameters. +func (r *ResourceChangeDetailsRequestParameters) 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 "changeIds": + err = unpopulate(val, "ChangeIDs", &r.ChangeIDs) + delete(rawMsg, key) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &r.ResourceIDs) + 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 ResourceChangeList. +func (r ResourceChangeList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "changes", r.Changes) + populateAny(objectMap, "$skipToken", r.SkipToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceChangeList. +func (r *ResourceChangeList) 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 "changes": + err = unpopulate(val, "Changes", &r.Changes) + delete(rawMsg, key) + case "$skipToken": + err = unpopulate(val, "SkipToken", &r.SkipToken) + 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 ResourceChangesRequestParameters. +func (r ResourceChangesRequestParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "fetchPropertyChanges", r.FetchPropertyChanges) + populate(objectMap, "fetchSnapshots", r.FetchSnapshots) + populate(objectMap, "interval", r.Interval) + populate(objectMap, "resourceIds", r.ResourceIDs) + populate(objectMap, "$skipToken", r.SkipToken) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "table", r.Table) + populate(objectMap, "$top", r.Top) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceChangesRequestParameters. +func (r *ResourceChangesRequestParameters) 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 "fetchPropertyChanges": + err = unpopulate(val, "FetchPropertyChanges", &r.FetchPropertyChanges) + delete(rawMsg, key) + case "fetchSnapshots": + err = unpopulate(val, "FetchSnapshots", &r.FetchSnapshots) + delete(rawMsg, key) + case "interval": + err = unpopulate(val, "Interval", &r.Interval) + delete(rawMsg, key) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &r.ResourceIDs) + delete(rawMsg, key) + case "$skipToken": + err = unpopulate(val, "SkipToken", &r.SkipToken) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "table": + err = unpopulate(val, "Table", &r.Table) + delete(rawMsg, key) + case "$top": + err = unpopulate(val, "Top", &r.Top) + 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 ResourceChangesRequestParametersInterval. +func (r ResourceChangesRequestParametersInterval) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "end", r.End) + populateTimeRFC3339(objectMap, "start", r.Start) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceChangesRequestParametersInterval. +func (r *ResourceChangesRequestParametersInterval) 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 "end": + err = unpopulateTimeRFC3339(val, "End", &r.End) + delete(rawMsg, key) + case "start": + err = unpopulateTimeRFC3339(val, "Start", &r.Start) + 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 ResourcePropertyChange. +func (r ResourcePropertyChange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "afterValue", r.AfterValue) + populate(objectMap, "beforeValue", r.BeforeValue) + populate(objectMap, "changeCategory", r.ChangeCategory) + populate(objectMap, "propertyChangeType", r.PropertyChangeType) + populate(objectMap, "propertyName", r.PropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourcePropertyChange. +func (r *ResourcePropertyChange) 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 "afterValue": + err = unpopulate(val, "AfterValue", &r.AfterValue) + delete(rawMsg, key) + case "beforeValue": + err = unpopulate(val, "BeforeValue", &r.BeforeValue) + delete(rawMsg, key) + case "changeCategory": + err = unpopulate(val, "ChangeCategory", &r.ChangeCategory) + delete(rawMsg, key) + case "propertyChangeType": + err = unpopulate(val, "PropertyChangeType", &r.PropertyChangeType) + delete(rawMsg, key) + case "propertyName": + err = unpopulate(val, "PropertyName", &r.PropertyName) + 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 ResourceSnapshotData. +func (r ResourceSnapshotData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "content", r.Content) + populate(objectMap, "snapshotId", r.SnapshotID) + populateTimeRFC3339(objectMap, "timestamp", r.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceSnapshotData. +func (r *ResourceSnapshotData) 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 "content": + err = unpopulate(val, "Content", &r.Content) + delete(rawMsg, key) + case "snapshotId": + err = unpopulate(val, "SnapshotID", &r.SnapshotID) + delete(rawMsg, key) + case "timestamp": + err = unpopulateTimeRFC3339(val, "Timestamp", &r.Timestamp) + 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 ResourcesHistoryRequest. func (r ResourcesHistoryRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -684,6 +1120,37 @@ func (r *ResourcesHistoryRequestOptions) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type StatusResponse. +func (s StatusResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "category", s.Category) + populate(objectMap, "message", s.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StatusResponse. +func (s *StatusResponse) 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 "category": + err = unpopulate(val, "Category", &s.Category) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &s.Message) + 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) diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/operations_client.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/operations_client.go index 72e68d3d957d..f2af5051abb8 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/operations_client.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available REST API operations. // -// Generated from API version 2021-06-01-preview +// Generated from API version 2023-09-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]{ @@ -73,7 +73,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01-preview") + reqQP.Set("api-version", "2023-09-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/operations_client_example_test.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/operations_client_example_test.go deleted file mode 100644 index 1495cbeeda17..000000000000 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/operations_client_example_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//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 armresourcegraph_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2021-06-01-preview/examples/OperationsList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresourcegraph.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armresourcegraph.OperationListResult{ - // Value: []*armresourcegraph.Operation{ - // { - // Name: to.Ptr("Microsoft.ResourceGraph/operations/read"), - // Display: &armresourcegraph.OperationDisplay{ - // Description: to.Ptr("Gets the list of supported operations"), - // Operation: to.Ptr("Get Operations"), - // Provider: to.Ptr("Microsoft Resource Graph"), - // Resource: to.Ptr("Operation"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ResourceGraph/resources/read"), - // Display: &armresourcegraph.OperationDisplay{ - // Description: to.Ptr("Submits a query on resources within specified subscriptions, the specified management groups, or against all access granted in the tenant."), - // Operation: to.Ptr("Query resources"), - // Provider: to.Ptr("Microsoft Resource Graph"), - // Resource: to.Ptr("Resources"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/options.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/options.go index 43016398f4d0..d3d7b97763cc 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/options.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/options.go @@ -8,6 +8,16 @@ package armresourcegraph +// ClientResourceChangeDetailsOptions contains the optional parameters for the Client.ResourceChangeDetails method. +type ClientResourceChangeDetailsOptions struct { + // placeholder for future optional parameters +} + +// ClientResourceChangesOptions contains the optional parameters for the Client.ResourceChanges method. +type ClientResourceChangesOptions struct { + // placeholder for future optional parameters +} + // ClientResourcesHistoryOptions contains the optional parameters for the Client.ResourcesHistory method. type ClientResourcesHistoryOptions struct { // placeholder for future optional parameters @@ -22,3 +32,8 @@ type ClientResourcesOptions struct { type OperationsClientListOptions struct { // placeholder for future optional parameters } + +// QueryClientGenerateQueryOptions contains the optional parameters for the QueryClient.GenerateQuery method. +type QueryClientGenerateQueryOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/query_client.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/query_client.go new file mode 100644 index 000000000000..3c539a7a1261 --- /dev/null +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/query_client.go @@ -0,0 +1,91 @@ +//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 armresourcegraph + +import ( + "context" + "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" +) + +// QueryClient contains the methods for the Query group. +// Don't use this type directly, use NewQueryClient() instead. +type QueryClient struct { + internal *arm.Client +} + +// NewQueryClient creates a new instance of QueryClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewQueryClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*QueryClient, error) { + cl, err := arm.NewClient(moduleName+".QueryClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &QueryClient{ + internal: cl, + } + return client, nil +} + +// GenerateQuery - Generates ARG query for a given user prompt. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-09-01-preview +// - options - QueryClientGenerateQueryOptions contains the optional parameters for the QueryClient.GenerateQuery method. +func (client *QueryClient) GenerateQuery(ctx context.Context, body QueryGenerationRequest, options *QueryClientGenerateQueryOptions) (QueryClientGenerateQueryResponse, error) { + var err error + const operationName = "QueryClient.GenerateQuery" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateQueryCreateRequest(ctx, body, options) + if err != nil { + return QueryClientGenerateQueryResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return QueryClientGenerateQueryResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueryClientGenerateQueryResponse{}, err + } + resp, err := client.generateQueryHandleResponse(httpResp) + return resp, err +} + +// generateQueryCreateRequest creates the GenerateQuery request. +func (client *QueryClient) generateQueryCreateRequest(ctx context.Context, body QueryGenerationRequest, options *QueryClientGenerateQueryOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ResourceGraph/generateQuery" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// generateQueryHandleResponse handles the GenerateQuery response. +func (client *QueryClient) generateQueryHandleResponse(resp *http.Response) (QueryClientGenerateQueryResponse, error) { + result := QueryClientGenerateQueryResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.QueryGenerationResponse); err != nil { + return QueryClientGenerateQueryResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resourcegraph/armresourcegraph/response_types.go b/sdk/resourcemanager/resourcegraph/armresourcegraph/response_types.go index ce6fde39784e..8bddb49bf854 100644 --- a/sdk/resourcemanager/resourcegraph/armresourcegraph/response_types.go +++ b/sdk/resourcemanager/resourcegraph/armresourcegraph/response_types.go @@ -8,10 +8,22 @@ package armresourcegraph +// ClientResourceChangeDetailsResponse contains the response from method Client.ResourceChangeDetails. +type ClientResourceChangeDetailsResponse struct { + // A list of change details associated with a resource over a specific time interval. + ResourceChangeDataArray []*ResourceChangeData +} + +// ClientResourceChangesResponse contains the response from method Client.ResourceChanges. +type ClientResourceChangesResponse struct { + // A list of changes associated with a resource over a specific time interval. + ResourceChangeList +} + // ClientResourcesHistoryResponse contains the response from method Client.ResourcesHistory. type ClientResourcesHistoryResponse struct { - // Anything - Interface any + // Dictionary of + Value map[string]any } // ClientResourcesResponse contains the response from method Client.Resources. @@ -26,3 +38,9 @@ type OperationsClientListResponse struct { // set of results. OperationListResult } + +// QueryClientGenerateQueryResponse contains the response from method QueryClient.GenerateQuery. +type QueryClientGenerateQueryResponse struct { + // Query Generation Response + QueryGenerationResponse +}