diff --git a/sdk/resourcemanager/dashboard/armdashboard/CHANGELOG.md b/sdk/resourcemanager/dashboard/armdashboard/CHANGELOG.md index b852af4737f5..b8bf80352326 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/CHANGELOG.md +++ b/sdk/resourcemanager/dashboard/armdashboard/CHANGELOG.md @@ -1,5 +1,41 @@ # Release History +## 1.3.0-beta.1 (2025-05-07) +### Features Added + +- New function `*ClientFactory.NewDashboardsClient() *DashboardsClient` +- New function `*ClientFactory.NewIntegrationFabricsClient() *IntegrationFabricsClient` +- New function `*ClientFactory.NewManagedDashboardsClient() *ManagedDashboardsClient` +- New function `NewDashboardsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DashboardsClient, error)` +- New function `*DashboardsClient.Get(context.Context, string, string, *DashboardsClientGetOptions) (DashboardsClientGetResponse, error)` +- New function `*DashboardsClient.NewListBySubscriptionPager(*DashboardsClientListBySubscriptionOptions) *runtime.Pager[DashboardsClientListBySubscriptionResponse]` +- New function `*DashboardsClient.NewListPager(string, *DashboardsClientListOptions) *runtime.Pager[DashboardsClientListResponse]` +- New function `NewIntegrationFabricsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*IntegrationFabricsClient, error)` +- New function `*IntegrationFabricsClient.BeginCreate(context.Context, string, string, string, IntegrationFabric, *IntegrationFabricsClientBeginCreateOptions) (*runtime.Poller[IntegrationFabricsClientCreateResponse], error)` +- New function `*IntegrationFabricsClient.BeginDelete(context.Context, string, string, string, *IntegrationFabricsClientBeginDeleteOptions) (*runtime.Poller[IntegrationFabricsClientDeleteResponse], error)` +- New function `*IntegrationFabricsClient.Get(context.Context, string, string, string, *IntegrationFabricsClientGetOptions) (IntegrationFabricsClientGetResponse, error)` +- New function `*IntegrationFabricsClient.NewListPager(string, string, *IntegrationFabricsClientListOptions) *runtime.Pager[IntegrationFabricsClientListResponse]` +- New function `*IntegrationFabricsClient.BeginUpdate(context.Context, string, string, string, IntegrationFabricUpdateParameters, *IntegrationFabricsClientBeginUpdateOptions) (*runtime.Poller[IntegrationFabricsClientUpdateResponse], error)` +- New function `NewManagedDashboardsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ManagedDashboardsClient, error)` +- New function `*ManagedDashboardsClient.BeginCreate(context.Context, string, string, ManagedDashboard, *ManagedDashboardsClientBeginCreateOptions) (*runtime.Poller[ManagedDashboardsClientCreateResponse], error)` +- New function `*ManagedDashboardsClient.Delete(context.Context, string, string, *ManagedDashboardsClientDeleteOptions) (ManagedDashboardsClientDeleteResponse, error)` +- New function `*ManagedDashboardsClient.Update(context.Context, string, string, ManagedDashboardUpdateParameters, *ManagedDashboardsClientUpdateOptions) (ManagedDashboardsClientUpdateResponse, error)` +- New struct `IntegrationFabric` +- New struct `IntegrationFabricListResponse` +- New struct `IntegrationFabricProperties` +- New struct `IntegrationFabricPropertiesUpdateParameters` +- New struct `IntegrationFabricUpdateParameters` +- New struct `ManagedDashboard` +- New struct `ManagedDashboardListResponse` +- New struct `ManagedDashboardProperties` +- New struct `ManagedDashboardUpdateParameters` +- New struct `Security` +- New struct `Snapshots` +- New struct `UnifiedAlertingScreenshots` +- New struct `Users` +- New field `Security`, `Snapshots`, `UnifiedAlertingScreenshots`, `Users` in struct `GrafanaConfigurations` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/dashboard/armdashboard/README.md b/sdk/resourcemanager/dashboard/armdashboard/README.md index b3e0a6813ce2..4114147e3030 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/README.md +++ b/sdk/resourcemanager/dashboard/armdashboard/README.md @@ -55,7 +55,7 @@ clientFactory, err := armdashboard.NewClientFactory(, cred, &op A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewGrafanaClient() +client := clientFactory.NewDashboardsClient() ``` ## Fakes diff --git a/sdk/resourcemanager/dashboard/armdashboard/autorest.md b/sdk/resourcemanager/dashboard/armdashboard/autorest.md index 133f51f52d50..8ae0d867088f 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/autorest.md +++ b/sdk/resourcemanager/dashboard/armdashboard/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/dashboard/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/dashboard/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 -tag: package-2023-09-01 +module-version: 1.3.0-beta.1 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/dashboard/armdashboard/client_factory.go b/sdk/resourcemanager/dashboard/armdashboard/client_factory.go index 29ac072fec7d..c9e25b10037d 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/client_factory.go +++ b/sdk/resourcemanager/dashboard/armdashboard/client_factory.go @@ -1,6 +1,3 @@ -//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. @@ -17,8 +14,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,42 +23,75 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } +// NewDashboardsClient creates a new instance of DashboardsClient. +func (c *ClientFactory) NewDashboardsClient() *DashboardsClient { + return &DashboardsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + // NewGrafanaClient creates a new instance of GrafanaClient. func (c *ClientFactory) NewGrafanaClient() *GrafanaClient { - subClient, _ := NewGrafanaClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GrafanaClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewIntegrationFabricsClient creates a new instance of IntegrationFabricsClient. +func (c *ClientFactory) NewIntegrationFabricsClient() *IntegrationFabricsClient { + return &IntegrationFabricsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewManagedDashboardsClient creates a new instance of ManagedDashboardsClient. +func (c *ClientFactory) NewManagedDashboardsClient() *ManagedDashboardsClient { + return &ManagedDashboardsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewManagedPrivateEndpointsClient creates a new instance of ManagedPrivateEndpointsClient. func (c *ClientFactory) NewManagedPrivateEndpointsClient() *ManagedPrivateEndpointsClient { - subClient, _ := NewManagedPrivateEndpointsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ManagedPrivateEndpointsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { - subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateEndpointConnectionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { - subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateLinkResourcesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/dashboard/armdashboard/constants.go b/sdk/resourcemanager/dashboard/armdashboard/constants.go index 050bb13668d8..12aeb42ad1f6 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/constants.go +++ b/sdk/resourcemanager/dashboard/armdashboard/constants.go @@ -1,6 +1,3 @@ -//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. @@ -10,7 +7,7 @@ package armdashboard const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard" - moduleVersion = "v1.2.0" + moduleVersion = "v1.3.0-beta.1" ) type APIKey string diff --git a/sdk/resourcemanager/dashboard/armdashboard/dashboards_client.go b/sdk/resourcemanager/dashboard/armdashboard/dashboards_client.go new file mode 100644 index 000000000000..a9d6d8290a8c --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/dashboards_client.go @@ -0,0 +1,219 @@ +// 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 armdashboard + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DashboardsClient contains the methods for the Dashboards group. +// Don't use this type directly, use NewDashboardsClient() instead. +type DashboardsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDashboardsClient creates a new instance of DashboardsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDashboardsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DashboardsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DashboardsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get the properties of a specific dashboard for grafana resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dashboardName - The name of the Azure Managed Dashboard. +// - options - DashboardsClientGetOptions contains the optional parameters for the DashboardsClient.Get method. +func (client *DashboardsClient) Get(ctx context.Context, resourceGroupName string, dashboardName string, options *DashboardsClientGetOptions) (DashboardsClientGetResponse, error) { + var err error + const operationName = "DashboardsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, dashboardName, options) + if err != nil { + return DashboardsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DashboardsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DashboardsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DashboardsClient) getCreateRequest(ctx context.Context, resourceGroupName string, dashboardName string, _ *DashboardsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dashboardName == "" { + return nil, errors.New("parameter dashboardName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dashboardName}", url.PathEscape(dashboardName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DashboardsClient) getHandleResponse(resp *http.Response) (DashboardsClientGetResponse, error) { + result := DashboardsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagedDashboard); err != nil { + return DashboardsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all resources of dashboards under the specified resource group. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DashboardsClientListOptions contains the optional parameters for the DashboardsClient.NewListPager method. +func (client *DashboardsClient) NewListPager(resourceGroupName string, options *DashboardsClientListOptions) *runtime.Pager[DashboardsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[DashboardsClientListResponse]{ + More: func(page DashboardsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DashboardsClientListResponse) (DashboardsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DashboardsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return DashboardsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *DashboardsClient) listCreateRequest(ctx context.Context, resourceGroupName string, _ *DashboardsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DashboardsClient) listHandleResponse(resp *http.Response) (DashboardsClientListResponse, error) { + result := DashboardsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagedDashboardListResponse); err != nil { + return DashboardsClientListResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List all resources of dashboards under the specified subscription. +// +// Generated from API version 2024-11-01-preview +// - options - DashboardsClientListBySubscriptionOptions contains the optional parameters for the DashboardsClient.NewListBySubscriptionPager +// method. +func (client *DashboardsClient) NewListBySubscriptionPager(options *DashboardsClientListBySubscriptionOptions) *runtime.Pager[DashboardsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[DashboardsClientListBySubscriptionResponse]{ + More: func(page DashboardsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DashboardsClientListBySubscriptionResponse) (DashboardsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DashboardsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return DashboardsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DashboardsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *DashboardsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/dashboards" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DashboardsClient) listBySubscriptionHandleResponse(resp *http.Response) (DashboardsClientListBySubscriptionResponse, error) { + result := DashboardsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagedDashboardListResponse); err != nil { + return DashboardsClientListBySubscriptionResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/dashboards_server.go b/sdk/resourcemanager/dashboard/armdashboard/fake/dashboards_server.go new file mode 100644 index 000000000000..566894473f77 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/dashboards_server.go @@ -0,0 +1,211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard" + "net/http" + "net/url" + "regexp" +) + +// DashboardsServer is a fake server for instances of the armdashboard.DashboardsClient type. +type DashboardsServer struct { + // Get is the fake for method DashboardsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, dashboardName string, options *armdashboard.DashboardsClientGetOptions) (resp azfake.Responder[armdashboard.DashboardsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DashboardsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, options *armdashboard.DashboardsClientListOptions) (resp azfake.PagerResponder[armdashboard.DashboardsClientListResponse]) + + // NewListBySubscriptionPager is the fake for method DashboardsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armdashboard.DashboardsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armdashboard.DashboardsClientListBySubscriptionResponse]) +} + +// NewDashboardsServerTransport creates a new instance of DashboardsServerTransport with the provided implementation. +// The returned DashboardsServerTransport instance is connected to an instance of armdashboard.DashboardsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDashboardsServerTransport(srv *DashboardsServer) *DashboardsServerTransport { + return &DashboardsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdashboard.DashboardsClientListResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armdashboard.DashboardsClientListBySubscriptionResponse]](), + } +} + +// DashboardsServerTransport connects instances of armdashboard.DashboardsClient to instances of DashboardsServer. +// Don't use this type directly, use NewDashboardsServerTransport instead. +type DashboardsServerTransport struct { + srv *DashboardsServer + newListPager *tracker[azfake.PagerResponder[armdashboard.DashboardsClientListResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armdashboard.DashboardsClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for DashboardsServerTransport. +func (d *DashboardsServerTransport) 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")} + } + + return d.dispatchToMethodFake(req, method) +} + +func (d *DashboardsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if dashboardsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = dashboardsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DashboardsClient.Get": + res.resp, res.err = d.dispatchGet(req) + case "DashboardsClient.NewListPager": + res.resp, res.err = d.dispatchNewListPager(req) + case "DashboardsClient.NewListBySubscriptionPager": + res.resp, res.err = d.dispatchNewListBySubscriptionPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (d *DashboardsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/dashboards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dashboardNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dashboardName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, dashboardNameParam, 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).ManagedDashboard, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DashboardsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/dashboards` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListPager(resourceGroupNameParam, nil) + newListPager = &resp + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdashboard.DashboardsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} + +func (d *DashboardsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := d.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/dashboards` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := d.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + d.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armdashboard.DashboardsClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + d.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to DashboardsServerTransport +var dashboardsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/grafana_server.go b/sdk/resourcemanager/dashboard/armdashboard/fake/grafana_server.go index abb2f2751c6f..5e023767c745 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/fake/grafana_server.go +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/grafana_server.go @@ -1,6 +1,3 @@ -//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. @@ -88,35 +85,54 @@ func (g *GrafanaServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "GrafanaClient.CheckEnterpriseDetails": - resp, err = g.dispatchCheckEnterpriseDetails(req) - case "GrafanaClient.BeginCreate": - resp, err = g.dispatchBeginCreate(req) - case "GrafanaClient.BeginDelete": - resp, err = g.dispatchBeginDelete(req) - case "GrafanaClient.FetchAvailablePlugins": - resp, err = g.dispatchFetchAvailablePlugins(req) - case "GrafanaClient.Get": - resp, err = g.dispatchGet(req) - case "GrafanaClient.NewListPager": - resp, err = g.dispatchNewListPager(req) - case "GrafanaClient.NewListByResourceGroupPager": - resp, err = g.dispatchNewListByResourceGroupPager(req) - case "GrafanaClient.Update": - resp, err = g.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return g.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (g *GrafanaServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - return resp, nil + go func() { + var intercepted bool + var res result + if grafanaServerTransportInterceptor != nil { + res.resp, res.err, intercepted = grafanaServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GrafanaClient.CheckEnterpriseDetails": + res.resp, res.err = g.dispatchCheckEnterpriseDetails(req) + case "GrafanaClient.BeginCreate": + res.resp, res.err = g.dispatchBeginCreate(req) + case "GrafanaClient.BeginDelete": + res.resp, res.err = g.dispatchBeginDelete(req) + case "GrafanaClient.FetchAvailablePlugins": + res.resp, res.err = g.dispatchFetchAvailablePlugins(req) + case "GrafanaClient.Get": + res.resp, res.err = g.dispatchGet(req) + case "GrafanaClient.NewListPager": + res.resp, res.err = g.dispatchNewListPager(req) + case "GrafanaClient.NewListByResourceGroupPager": + res.resp, res.err = g.dispatchNewListByResourceGroupPager(req) + case "GrafanaClient.Update": + res.resp, res.err = g.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GrafanaServerTransport) dispatchCheckEnterpriseDetails(req *http.Request) (*http.Response, error) { @@ -419,3 +435,9 @@ func (g *GrafanaServerTransport) dispatchUpdate(req *http.Request) (*http.Respon } return resp, nil } + +// set this to conditionally intercept incoming requests to GrafanaServerTransport +var grafanaServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/integrationfabrics_server.go b/sdk/resourcemanager/dashboard/armdashboard/fake/integrationfabrics_server.go new file mode 100644 index 000000000000..d84fe6ec5dbb --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/integrationfabrics_server.go @@ -0,0 +1,354 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard" + "net/http" + "net/url" + "regexp" +) + +// IntegrationFabricsServer is a fake server for instances of the armdashboard.IntegrationFabricsClient type. +type IntegrationFabricsServer struct { + // BeginCreate is the fake for method IntegrationFabricsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, requestBodyParameters armdashboard.IntegrationFabric, options *armdashboard.IntegrationFabricsClientBeginCreateOptions) (resp azfake.PollerResponder[armdashboard.IntegrationFabricsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method IntegrationFabricsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, options *armdashboard.IntegrationFabricsClientBeginDeleteOptions) (resp azfake.PollerResponder[armdashboard.IntegrationFabricsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationFabricsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, options *armdashboard.IntegrationFabricsClientGetOptions) (resp azfake.Responder[armdashboard.IntegrationFabricsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationFabricsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workspaceName string, options *armdashboard.IntegrationFabricsClientListOptions) (resp azfake.PagerResponder[armdashboard.IntegrationFabricsClientListResponse]) + + // BeginUpdate is the fake for method IntegrationFabricsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, requestBodyParameters armdashboard.IntegrationFabricUpdateParameters, options *armdashboard.IntegrationFabricsClientBeginUpdateOptions) (resp azfake.PollerResponder[armdashboard.IntegrationFabricsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationFabricsServerTransport creates a new instance of IntegrationFabricsServerTransport with the provided implementation. +// The returned IntegrationFabricsServerTransport instance is connected to an instance of armdashboard.IntegrationFabricsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationFabricsServerTransport(srv *IntegrationFabricsServer) *IntegrationFabricsServerTransport { + return &IntegrationFabricsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armdashboard.IntegrationFabricsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armdashboard.IntegrationFabricsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armdashboard.IntegrationFabricsClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armdashboard.IntegrationFabricsClientUpdateResponse]](), + } +} + +// IntegrationFabricsServerTransport connects instances of armdashboard.IntegrationFabricsClient to instances of IntegrationFabricsServer. +// Don't use this type directly, use NewIntegrationFabricsServerTransport instead. +type IntegrationFabricsServerTransport struct { + srv *IntegrationFabricsServer + beginCreate *tracker[azfake.PollerResponder[armdashboard.IntegrationFabricsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armdashboard.IntegrationFabricsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armdashboard.IntegrationFabricsClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armdashboard.IntegrationFabricsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationFabricsServerTransport. +func (i *IntegrationFabricsServerTransport) 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")} + } + + return i.dispatchToMethodFake(req, method) +} + +func (i *IntegrationFabricsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if integrationFabricsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = integrationFabricsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "IntegrationFabricsClient.BeginCreate": + res.resp, res.err = i.dispatchBeginCreate(req) + case "IntegrationFabricsClient.BeginDelete": + res.resp, res.err = i.dispatchBeginDelete(req) + case "IntegrationFabricsClient.Get": + res.resp, res.err = i.dispatchGet(req) + case "IntegrationFabricsClient.NewListPager": + res.resp, res.err = i.dispatchNewListPager(req) + case "IntegrationFabricsClient.BeginUpdate": + res.resp, res.err = i.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (i *IntegrationFabricsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if i.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := i.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/grafana/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/integrationFabrics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdashboard.IntegrationFabric](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceName")]) + if err != nil { + return nil, err + } + integrationFabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationFabricName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginCreate(req.Context(), resourceGroupNameParam, workspaceNameParam, integrationFabricNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + i.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + i.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + i.beginCreate.remove(req) + } + + return resp, nil +} + +func (i *IntegrationFabricsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if i.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := i.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/grafana/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/integrationFabrics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceName")]) + if err != nil { + return nil, err + } + integrationFabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationFabricName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginDelete(req.Context(), resourceGroupNameParam, workspaceNameParam, integrationFabricNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + i.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + i.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + i.beginDelete.remove(req) + } + + return resp, nil +} + +func (i *IntegrationFabricsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/grafana/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/integrationFabrics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceName")]) + if err != nil { + return nil, err + } + integrationFabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationFabricName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, workspaceNameParam, integrationFabricNameParam, 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).IntegrationFabric, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationFabricsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/grafana/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/integrationFabrics` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceName")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListPager(resourceGroupNameParam, workspaceNameParam, nil) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdashboard.IntegrationFabricsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationFabricsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if i.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := i.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/grafana/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/integrationFabrics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdashboard.IntegrationFabricUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceName")]) + if err != nil { + return nil, err + } + integrationFabricNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationFabricName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginUpdate(req.Context(), resourceGroupNameParam, workspaceNameParam, integrationFabricNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + i.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + i.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + i.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to IntegrationFabricsServerTransport +var integrationFabricsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/internal.go b/sdk/resourcemanager/dashboard/armdashboard/fake/internal.go index 5f75802a569e..4b65adc76adb 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/fake/internal.go +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/internal.go @@ -1,6 +1,3 @@ -//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. @@ -14,6 +11,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/manageddashboards_server.go b/sdk/resourcemanager/dashboard/armdashboard/fake/manageddashboards_server.go new file mode 100644 index 000000000000..150b6afea2d3 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/manageddashboards_server.go @@ -0,0 +1,223 @@ +// 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/dashboard/armdashboard" + "net/http" + "net/url" + "regexp" +) + +// ManagedDashboardsServer is a fake server for instances of the armdashboard.ManagedDashboardsClient type. +type ManagedDashboardsServer struct { + // BeginCreate is the fake for method ManagedDashboardsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, dashboardName string, requestBodyParameters armdashboard.ManagedDashboard, options *armdashboard.ManagedDashboardsClientBeginCreateOptions) (resp azfake.PollerResponder[armdashboard.ManagedDashboardsClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ManagedDashboardsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, dashboardName string, options *armdashboard.ManagedDashboardsClientDeleteOptions) (resp azfake.Responder[armdashboard.ManagedDashboardsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method ManagedDashboardsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, dashboardName string, requestBodyParameters armdashboard.ManagedDashboardUpdateParameters, options *armdashboard.ManagedDashboardsClientUpdateOptions) (resp azfake.Responder[armdashboard.ManagedDashboardsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewManagedDashboardsServerTransport creates a new instance of ManagedDashboardsServerTransport with the provided implementation. +// The returned ManagedDashboardsServerTransport instance is connected to an instance of armdashboard.ManagedDashboardsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewManagedDashboardsServerTransport(srv *ManagedDashboardsServer) *ManagedDashboardsServerTransport { + return &ManagedDashboardsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armdashboard.ManagedDashboardsClientCreateResponse]](), + } +} + +// ManagedDashboardsServerTransport connects instances of armdashboard.ManagedDashboardsClient to instances of ManagedDashboardsServer. +// Don't use this type directly, use NewManagedDashboardsServerTransport instead. +type ManagedDashboardsServerTransport struct { + srv *ManagedDashboardsServer + beginCreate *tracker[azfake.PollerResponder[armdashboard.ManagedDashboardsClientCreateResponse]] +} + +// Do implements the policy.Transporter interface for ManagedDashboardsServerTransport. +func (m *ManagedDashboardsServerTransport) 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")} + } + + return m.dispatchToMethodFake(req, method) +} + +func (m *ManagedDashboardsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if managedDashboardsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = managedDashboardsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ManagedDashboardsClient.BeginCreate": + res.resp, res.err = m.dispatchBeginCreate(req) + case "ManagedDashboardsClient.Delete": + res.resp, res.err = m.dispatchDelete(req) + case "ManagedDashboardsClient.Update": + res.resp, res.err = m.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (m *ManagedDashboardsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if m.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := m.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/dashboards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdashboard.ManagedDashboard](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dashboardNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dashboardName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginCreate(req.Context(), resourceGroupNameParam, dashboardNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + m.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + m.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + m.beginCreate.remove(req) + } + + return resp, nil +} + +func (m *ManagedDashboardsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if m.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/dashboards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dashboardNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dashboardName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Delete(req.Context(), resourceGroupNameParam, dashboardNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedDashboardsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if m.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Dashboard/dashboards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdashboard.ManagedDashboardUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dashboardNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dashboardName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Update(req.Context(), resourceGroupNameParam, dashboardNameParam, 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).ManagedDashboard, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ManagedDashboardsServerTransport +var managedDashboardsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/managedprivateendpoints_server.go b/sdk/resourcemanager/dashboard/armdashboard/fake/managedprivateendpoints_server.go index 3f9b236bd1e9..063a33c76a85 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/fake/managedprivateendpoints_server.go +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/managedprivateendpoints_server.go @@ -1,6 +1,3 @@ -//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. @@ -41,7 +38,7 @@ type ManagedPrivateEndpointsServer struct { NewListPager func(resourceGroupName string, workspaceName string, options *armdashboard.ManagedPrivateEndpointsClientListOptions) (resp azfake.PagerResponder[armdashboard.ManagedPrivateEndpointsClientListResponse]) // BeginRefresh is the fake for method ManagedPrivateEndpointsClient.BeginRefresh - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent BeginRefresh func(ctx context.Context, resourceGroupName string, workspaceName string, options *armdashboard.ManagedPrivateEndpointsClientBeginRefreshOptions) (resp azfake.PollerResponder[armdashboard.ManagedPrivateEndpointsClientRefreshResponse], errResp azfake.ErrorResponder) // BeginUpdate is the fake for method ManagedPrivateEndpointsClient.BeginUpdate @@ -82,31 +79,50 @@ func (m *ManagedPrivateEndpointsServerTransport) Do(req *http.Request) (*http.Re return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return m.dispatchToMethodFake(req, method) +} - switch method { - case "ManagedPrivateEndpointsClient.BeginCreate": - resp, err = m.dispatchBeginCreate(req) - case "ManagedPrivateEndpointsClient.BeginDelete": - resp, err = m.dispatchBeginDelete(req) - case "ManagedPrivateEndpointsClient.Get": - resp, err = m.dispatchGet(req) - case "ManagedPrivateEndpointsClient.NewListPager": - resp, err = m.dispatchNewListPager(req) - case "ManagedPrivateEndpointsClient.BeginRefresh": - resp, err = m.dispatchBeginRefresh(req) - case "ManagedPrivateEndpointsClient.BeginUpdate": - resp, err = m.dispatchBeginUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (m *ManagedPrivateEndpointsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if managedPrivateEndpointsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = managedPrivateEndpointsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ManagedPrivateEndpointsClient.BeginCreate": + res.resp, res.err = m.dispatchBeginCreate(req) + case "ManagedPrivateEndpointsClient.BeginDelete": + res.resp, res.err = m.dispatchBeginDelete(req) + case "ManagedPrivateEndpointsClient.Get": + res.resp, res.err = m.dispatchGet(req) + case "ManagedPrivateEndpointsClient.NewListPager": + res.resp, res.err = m.dispatchNewListPager(req) + case "ManagedPrivateEndpointsClient.BeginRefresh": + res.resp, res.err = m.dispatchBeginRefresh(req) + case "ManagedPrivateEndpointsClient.BeginUpdate": + res.resp, res.err = m.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (m *ManagedPrivateEndpointsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { @@ -320,9 +336,9 @@ func (m *ManagedPrivateEndpointsServerTransport) dispatchBeginRefresh(req *http. return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { m.beginRefresh.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginRefresh) { m.beginRefresh.remove(req) @@ -382,3 +398,9 @@ func (m *ManagedPrivateEndpointsServerTransport) dispatchBeginUpdate(req *http.R return resp, nil } + +// set this to conditionally intercept incoming requests to ManagedPrivateEndpointsServerTransport +var managedPrivateEndpointsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/operations_server.go b/sdk/resourcemanager/dashboard/armdashboard/fake/operations_server.go index 551a63568610..acf7cd79c20b 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/fake/operations_server.go +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/operations_server.go @@ -1,6 +1,3 @@ -//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. @@ -51,21 +48,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/privateendpointconnections_server.go b/sdk/resourcemanager/dashboard/armdashboard/fake/privateendpointconnections_server.go index a1ebf53cf063..2ee95c47b1bf 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/fake/privateendpointconnections_server.go +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/privateendpointconnections_server.go @@ -1,6 +1,3 @@ -//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. @@ -25,11 +22,11 @@ import ( // PrivateEndpointConnectionsServer is a fake server for instances of the armdashboard.PrivateEndpointConnectionsClient type. type PrivateEndpointConnectionsServer struct { // BeginApprove is the fake for method PrivateEndpointConnectionsClient.BeginApprove - // HTTP status codes to indicate success: http.StatusCreated + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated BeginApprove func(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, body armdashboard.PrivateEndpointConnection, options *armdashboard.PrivateEndpointConnectionsClientBeginApproveOptions) (resp azfake.PollerResponder[armdashboard.PrivateEndpointConnectionsClientApproveResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method PrivateEndpointConnectionsClient.BeginDelete - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *armdashboard.PrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armdashboard.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method PrivateEndpointConnectionsClient.Get @@ -70,27 +67,46 @@ func (p *PrivateEndpointConnectionsServerTransport) Do(req *http.Request) (*http return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PrivateEndpointConnectionsClient.BeginApprove": - resp, err = p.dispatchBeginApprove(req) - case "PrivateEndpointConnectionsClient.BeginDelete": - resp, err = p.dispatchBeginDelete(req) - case "PrivateEndpointConnectionsClient.Get": - resp, err = p.dispatchGet(req) - case "PrivateEndpointConnectionsClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PrivateEndpointConnectionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if privateEndpointConnectionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = privateEndpointConnectionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrivateEndpointConnectionsClient.BeginApprove": + res.resp, res.err = p.dispatchBeginApprove(req) + case "PrivateEndpointConnectionsClient.BeginDelete": + res.resp, res.err = p.dispatchBeginDelete(req) + case "PrivateEndpointConnectionsClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.NewListPager": + res.resp, res.err = p.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginApprove(req *http.Request) (*http.Response, error) { @@ -134,9 +150,9 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginApprove(req *ht return nil, err } - if !contains([]int{http.StatusCreated}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { p.beginApprove.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusCreated", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginApprove) { p.beginApprove.remove(req) @@ -182,9 +198,9 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *htt return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { p.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { p.beginDelete.remove(req) @@ -270,3 +286,9 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *ht } return resp, nil } + +// set this to conditionally intercept incoming requests to PrivateEndpointConnectionsServerTransport +var privateEndpointConnectionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/privatelinkresources_server.go b/sdk/resourcemanager/dashboard/armdashboard/fake/privatelinkresources_server.go index 1ccc7aee9216..bbd927791070 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/fake/privatelinkresources_server.go +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/privatelinkresources_server.go @@ -1,6 +1,3 @@ -//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. @@ -58,23 +55,42 @@ func (p *PrivateLinkResourcesServerTransport) Do(req *http.Request) (*http.Respo return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PrivateLinkResourcesClient.Get": - resp, err = p.dispatchGet(req) - case "PrivateLinkResourcesClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PrivateLinkResourcesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if privateLinkResourcesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = privateLinkResourcesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrivateLinkResourcesClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PrivateLinkResourcesClient.NewListPager": + res.resp, res.err = p.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -154,3 +170,9 @@ func (p *PrivateLinkResourcesServerTransport) dispatchNewListPager(req *http.Req } return resp, nil } + +// set this to conditionally intercept incoming requests to PrivateLinkResourcesServerTransport +var privateLinkResourcesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/server_factory.go b/sdk/resourcemanager/dashboard/armdashboard/fake/server_factory.go index fb4bb5a0681b..35ea20761760 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/fake/server_factory.go +++ b/sdk/resourcemanager/dashboard/armdashboard/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. @@ -19,11 +16,29 @@ import ( // ServerFactory is a fake server for instances of the armdashboard.ClientFactory type. type ServerFactory struct { - GrafanaServer GrafanaServer - ManagedPrivateEndpointsServer ManagedPrivateEndpointsServer - OperationsServer OperationsServer + // DashboardsServer contains the fakes for client DashboardsClient + DashboardsServer DashboardsServer + + // GrafanaServer contains the fakes for client GrafanaClient + GrafanaServer GrafanaServer + + // IntegrationFabricsServer contains the fakes for client IntegrationFabricsClient + IntegrationFabricsServer IntegrationFabricsServer + + // ManagedDashboardsServer contains the fakes for client ManagedDashboardsClient + ManagedDashboardsServer ManagedDashboardsServer + + // ManagedPrivateEndpointsServer contains the fakes for client ManagedPrivateEndpointsClient + ManagedPrivateEndpointsServer ManagedPrivateEndpointsServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // PrivateEndpointConnectionsServer contains the fakes for client PrivateEndpointConnectionsClient PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer - PrivateLinkResourcesServer PrivateLinkResourcesServer + + // PrivateLinkResourcesServer contains the fakes for client PrivateLinkResourcesClient + PrivateLinkResourcesServer PrivateLinkResourcesServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -40,7 +55,10 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { type ServerFactoryTransport struct { srv *ServerFactory trMu sync.Mutex + trDashboardsServer *DashboardsServerTransport trGrafanaServer *GrafanaServerTransport + trIntegrationFabricsServer *IntegrationFabricsServerTransport + trManagedDashboardsServer *ManagedDashboardsServerTransport trManagedPrivateEndpointsServer *ManagedPrivateEndpointsServerTransport trOperationsServer *OperationsServerTransport trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport @@ -60,9 +78,22 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { + case "DashboardsClient": + initServer(s, &s.trDashboardsServer, func() *DashboardsServerTransport { return NewDashboardsServerTransport(&s.srv.DashboardsServer) }) + resp, err = s.trDashboardsServer.Do(req) case "GrafanaClient": initServer(s, &s.trGrafanaServer, func() *GrafanaServerTransport { return NewGrafanaServerTransport(&s.srv.GrafanaServer) }) resp, err = s.trGrafanaServer.Do(req) + case "IntegrationFabricsClient": + initServer(s, &s.trIntegrationFabricsServer, func() *IntegrationFabricsServerTransport { + return NewIntegrationFabricsServerTransport(&s.srv.IntegrationFabricsServer) + }) + resp, err = s.trIntegrationFabricsServer.Do(req) + case "ManagedDashboardsClient": + initServer(s, &s.trManagedDashboardsServer, func() *ManagedDashboardsServerTransport { + return NewManagedDashboardsServerTransport(&s.srv.ManagedDashboardsServer) + }) + resp, err = s.trManagedDashboardsServer.Do(req) case "ManagedPrivateEndpointsClient": initServer(s, &s.trManagedPrivateEndpointsServer, func() *ManagedPrivateEndpointsServerTransport { return NewManagedPrivateEndpointsServerTransport(&s.srv.ManagedPrivateEndpointsServer) diff --git a/sdk/resourcemanager/dashboard/armdashboard/fake/time_rfc3339.go b/sdk/resourcemanager/dashboard/armdashboard/fake/time_rfc3339.go deleted file mode 100644 index b0535a7b63e6..000000000000 --- a/sdk/resourcemanager/dashboard/armdashboard/fake/time_rfc3339.go +++ /dev/null @@ -1,86 +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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) - -const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { - layout = dateTimeJSON - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { - layout = time.RFC3339Nano - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/dashboard/armdashboard/go.mod b/sdk/resourcemanager/dashboard/armdashboard/go.mod index b7f335395ffc..6e1e1b025251 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/go.mod +++ b/sdk/resourcemanager/dashboard/armdashboard/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashbo go 1.23.0 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.36.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect ) diff --git a/sdk/resourcemanager/dashboard/armdashboard/go.sum b/sdk/resourcemanager/dashboard/armdashboard/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/go.sum +++ b/sdk/resourcemanager/dashboard/armdashboard/go.sum @@ -1,44 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -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-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/dashboard/armdashboard/grafana_client.go b/sdk/resourcemanager/dashboard/armdashboard/grafana_client.go index a15bc7935d8d..396068ba9508 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/grafana_client.go +++ b/sdk/resourcemanager/dashboard/armdashboard/grafana_client.go @@ -1,6 +1,3 @@ -//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. @@ -46,7 +43,7 @@ func NewGrafanaClient(subscriptionID string, credential azcore.TokenCredential, // CheckEnterpriseDetails - Retrieve enterprise add-on details information // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - GrafanaClientCheckEnterpriseDetailsOptions contains the optional parameters for the GrafanaClient.CheckEnterpriseDetails @@ -74,7 +71,7 @@ func (client *GrafanaClient) CheckEnterpriseDetails(ctx context.Context, resourc } // checkEnterpriseDetailsCreateRequest creates the CheckEnterpriseDetails request. -func (client *GrafanaClient) checkEnterpriseDetailsCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *GrafanaClientCheckEnterpriseDetailsOptions) (*policy.Request, error) { +func (client *GrafanaClient) checkEnterpriseDetailsCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *GrafanaClientCheckEnterpriseDetailsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/checkEnterpriseDetails" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -93,7 +90,7 @@ func (client *GrafanaClient) checkEnterpriseDetailsCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -112,7 +109,7 @@ func (client *GrafanaClient) checkEnterpriseDetailsHandleResponse(resp *http.Res // grafana or update an existing grafana. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - GrafanaClientBeginCreateOptions contains the optional parameters for the GrafanaClient.BeginCreate method. @@ -138,7 +135,7 @@ func (client *GrafanaClient) BeginCreate(ctx context.Context, resourceGroupName // or update an existing grafana. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview func (client *GrafanaClient) create(ctx context.Context, resourceGroupName string, workspaceName string, requestBodyParameters ManagedGrafana, options *GrafanaClientBeginCreateOptions) (*http.Response, error) { var err error const operationName = "GrafanaClient.BeginCreate" @@ -161,7 +158,7 @@ func (client *GrafanaClient) create(ctx context.Context, resourceGroupName strin } // createCreateRequest creates the Create request. -func (client *GrafanaClient) createCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, requestBodyParameters ManagedGrafana, options *GrafanaClientBeginCreateOptions) (*policy.Request, error) { +func (client *GrafanaClient) createCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, requestBodyParameters ManagedGrafana, _ *GrafanaClientBeginCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -180,7 +177,7 @@ func (client *GrafanaClient) createCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, requestBodyParameters); err != nil { @@ -192,7 +189,7 @@ func (client *GrafanaClient) createCreateRequest(ctx context.Context, resourceGr // BeginDelete - Delete a workspace for Grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - GrafanaClientBeginDeleteOptions contains the optional parameters for the GrafanaClient.BeginDelete method. @@ -217,7 +214,7 @@ func (client *GrafanaClient) BeginDelete(ctx context.Context, resourceGroupName // Delete - Delete a workspace for Grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview func (client *GrafanaClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, options *GrafanaClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "GrafanaClient.BeginDelete" @@ -240,7 +237,7 @@ func (client *GrafanaClient) deleteOperation(ctx context.Context, resourceGroupN } // deleteCreateRequest creates the Delete request. -func (client *GrafanaClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *GrafanaClientBeginDeleteOptions) (*policy.Request, error) { +func (client *GrafanaClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *GrafanaClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -259,7 +256,7 @@ func (client *GrafanaClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -268,7 +265,7 @@ func (client *GrafanaClient) deleteCreateRequest(ctx context.Context, resourceGr // FetchAvailablePlugins - // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - GrafanaClientFetchAvailablePluginsOptions contains the optional parameters for the GrafanaClient.FetchAvailablePlugins @@ -296,7 +293,7 @@ func (client *GrafanaClient) FetchAvailablePlugins(ctx context.Context, resource } // fetchAvailablePluginsCreateRequest creates the FetchAvailablePlugins request. -func (client *GrafanaClient) fetchAvailablePluginsCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *GrafanaClientFetchAvailablePluginsOptions) (*policy.Request, error) { +func (client *GrafanaClient) fetchAvailablePluginsCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *GrafanaClientFetchAvailablePluginsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/fetchAvailablePlugins" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -315,7 +312,7 @@ func (client *GrafanaClient) fetchAvailablePluginsCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -333,7 +330,7 @@ func (client *GrafanaClient) fetchAvailablePluginsHandleResponse(resp *http.Resp // Get - Get the properties of a specific workspace for Grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - GrafanaClientGetOptions contains the optional parameters for the GrafanaClient.Get method. @@ -360,7 +357,7 @@ func (client *GrafanaClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *GrafanaClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *GrafanaClientGetOptions) (*policy.Request, error) { +func (client *GrafanaClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *GrafanaClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -379,7 +376,7 @@ func (client *GrafanaClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -396,7 +393,7 @@ func (client *GrafanaClient) getHandleResponse(resp *http.Response) (GrafanaClie // NewListPager - List all resources of workspaces for Grafana under the specified subscription. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - options - GrafanaClientListOptions contains the optional parameters for the GrafanaClient.NewListPager method. func (client *GrafanaClient) NewListPager(options *GrafanaClientListOptions) *runtime.Pager[GrafanaClientListResponse] { return runtime.NewPager(runtime.PagingHandler[GrafanaClientListResponse]{ @@ -422,7 +419,7 @@ func (client *GrafanaClient) NewListPager(options *GrafanaClientListOptions) *ru } // listCreateRequest creates the List request. -func (client *GrafanaClient) listCreateRequest(ctx context.Context, options *GrafanaClientListOptions) (*policy.Request, error) { +func (client *GrafanaClient) listCreateRequest(ctx context.Context, _ *GrafanaClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -433,7 +430,7 @@ func (client *GrafanaClient) listCreateRequest(ctx context.Context, options *Gra return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -450,7 +447,7 @@ func (client *GrafanaClient) listHandleResponse(resp *http.Response) (GrafanaCli // NewListByResourceGroupPager - List all resources of workspaces for Grafana under the specified resource group. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - GrafanaClientListByResourceGroupOptions contains the optional parameters for the GrafanaClient.NewListByResourceGroupPager // method. @@ -478,7 +475,7 @@ func (client *GrafanaClient) NewListByResourceGroupPager(resourceGroupName strin } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *GrafanaClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *GrafanaClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *GrafanaClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *GrafanaClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -493,7 +490,7 @@ func (client *GrafanaClient) listByResourceGroupCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -511,7 +508,7 @@ func (client *GrafanaClient) listByResourceGroupHandleResponse(resp *http.Respon // Update - Update a workspace for Grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - GrafanaClientUpdateOptions contains the optional parameters for the GrafanaClient.Update method. @@ -538,7 +535,7 @@ func (client *GrafanaClient) Update(ctx context.Context, resourceGroupName strin } // updateCreateRequest creates the Update request. -func (client *GrafanaClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, requestBodyParameters ManagedGrafanaUpdateParameters, options *GrafanaClientUpdateOptions) (*policy.Request, error) { +func (client *GrafanaClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, requestBodyParameters ManagedGrafanaUpdateParameters, _ *GrafanaClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -557,7 +554,7 @@ func (client *GrafanaClient) updateCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, requestBodyParameters); err != nil { diff --git a/sdk/resourcemanager/dashboard/armdashboard/grafana_client_example_test.go b/sdk/resourcemanager/dashboard/armdashboard/grafana_client_example_test.go deleted file mode 100644 index 802f85f7120d..000000000000 --- a/sdk/resourcemanager/dashboard/armdashboard/grafana_client_example_test.go +++ /dev/null @@ -1,588 +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 armdashboard_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_List.json -func ExampleGrafanaClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGrafanaClient().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.ManagedGrafanaListResponse = armdashboard.ManagedGrafanaListResponse{ - // Value: []*armdashboard.ManagedGrafana{ - // { - // Name: to.Ptr("myWorkspace"), - // Type: to.Ptr("Microsoft.Dashboard/grafana"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/grafana/myWorkspace"), - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedGrafanaProperties{ - // APIKey: to.Ptr(armdashboard.APIKeyEnabled), - // AutoGeneratedDomainNameLabelScope: to.Ptr(armdashboard.AutoGeneratedDomainNameLabelScopeTenantReuse), - // DeterministicOutboundIP: to.Ptr(armdashboard.DeterministicOutboundIPEnabled), - // Endpoint: to.Ptr("https://myworkspace-abcdefghijklmnop.wus.grafana.azure.com"), - // EnterpriseConfigurations: &armdashboard.EnterpriseConfigurations{ - // MarketplaceAutoRenew: to.Ptr(armdashboard.MarketplaceAutoRenewEnabled), - // MarketplacePlanID: to.Ptr("myPlanId"), - // }, - // GrafanaConfigurations: &armdashboard.GrafanaConfigurations{ - // SMTP: &armdashboard.SMTP{ - // Enabled: to.Ptr(true), - // FromAddress: to.Ptr("test@sendemail.com"), - // FromName: to.Ptr("emailsender"), - // Host: to.Ptr("smtp.sendemail.com:587"), - // SkipVerify: to.Ptr(true), - // StartTLSPolicy: to.Ptr(armdashboard.StartTLSPolicyOpportunisticStartTLS), - // User: to.Ptr("username"), - // }, - // }, - // GrafanaIntegrations: &armdashboard.GrafanaIntegrations{ - // AzureMonitorWorkspaceIntegrations: []*armdashboard.AzureMonitorWorkspaceIntegration{ - // { - // AzureMonitorWorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), - // }}, - // }, - // GrafanaMajorVersion: to.Ptr("9"), - // GrafanaPlugins: map[string]*armdashboard.GrafanaPlugin{ - // "sample-plugin-id": &armdashboard.GrafanaPlugin{ - // PluginID: to.Ptr("sample-plugin-id"), - // }, - // }, - // GrafanaVersion: to.Ptr("9.4.5"), - // OutboundIPs: []*string{ - // to.Ptr("192.168.0.1"), - // to.Ptr("192.168.0.2")}, - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // PublicNetworkAccess: to.Ptr(armdashboard.PublicNetworkAccessEnabled), - // ZoneRedundancy: to.Ptr(armdashboard.ZoneRedundancyEnabled), - // }, - // SKU: &armdashboard.ResourceSKU{ - // Name: to.Ptr("Standard"), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_ListByResourceGroup.json -func ExampleGrafanaClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGrafanaClient().NewListByResourceGroupPager("myResourceGroup", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ManagedGrafanaListResponse = armdashboard.ManagedGrafanaListResponse{ - // Value: []*armdashboard.ManagedGrafana{ - // { - // Name: to.Ptr("myWorkspace"), - // Type: to.Ptr("Microsoft.Dashboard/grafana"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/grafana/myWorkspace"), - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedGrafanaProperties{ - // APIKey: to.Ptr(armdashboard.APIKeyEnabled), - // AutoGeneratedDomainNameLabelScope: to.Ptr(armdashboard.AutoGeneratedDomainNameLabelScopeTenantReuse), - // DeterministicOutboundIP: to.Ptr(armdashboard.DeterministicOutboundIPEnabled), - // Endpoint: to.Ptr("https://myworkspace-abcdefghijklmnop.wus.grafana.azure.com"), - // EnterpriseConfigurations: &armdashboard.EnterpriseConfigurations{ - // MarketplaceAutoRenew: to.Ptr(armdashboard.MarketplaceAutoRenewEnabled), - // MarketplacePlanID: to.Ptr("myPlanId"), - // }, - // GrafanaConfigurations: &armdashboard.GrafanaConfigurations{ - // SMTP: &armdashboard.SMTP{ - // Enabled: to.Ptr(true), - // FromAddress: to.Ptr("test@sendemail.com"), - // FromName: to.Ptr("emailsender"), - // Host: to.Ptr("smtp.sendemail.com:587"), - // SkipVerify: to.Ptr(true), - // StartTLSPolicy: to.Ptr(armdashboard.StartTLSPolicyOpportunisticStartTLS), - // User: to.Ptr("username"), - // }, - // }, - // GrafanaIntegrations: &armdashboard.GrafanaIntegrations{ - // AzureMonitorWorkspaceIntegrations: []*armdashboard.AzureMonitorWorkspaceIntegration{ - // { - // AzureMonitorWorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), - // }}, - // }, - // GrafanaMajorVersion: to.Ptr("9"), - // GrafanaPlugins: map[string]*armdashboard.GrafanaPlugin{ - // "sample-plugin-id": &armdashboard.GrafanaPlugin{ - // PluginID: to.Ptr("sample-plugin-id"), - // }, - // }, - // GrafanaVersion: to.Ptr("9.4.5"), - // OutboundIPs: []*string{ - // to.Ptr("192.168.0.1"), - // to.Ptr("192.168.0.2")}, - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // PublicNetworkAccess: to.Ptr(armdashboard.PublicNetworkAccessEnabled), - // ZoneRedundancy: to.Ptr(armdashboard.ZoneRedundancyEnabled), - // }, - // SKU: &armdashboard.ResourceSKU{ - // Name: to.Ptr("Standard"), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Get.json -func ExampleGrafanaClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGrafanaClient().Get(ctx, "myResourceGroup", "myWorkspace", 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.ManagedGrafana = armdashboard.ManagedGrafana{ - // Name: to.Ptr("myWorkspace"), - // Type: to.Ptr("Microsoft.Dashboard/grafana"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/grafana/myWorkspace"), - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedGrafanaProperties{ - // APIKey: to.Ptr(armdashboard.APIKeyEnabled), - // AutoGeneratedDomainNameLabelScope: to.Ptr(armdashboard.AutoGeneratedDomainNameLabelScopeTenantReuse), - // DeterministicOutboundIP: to.Ptr(armdashboard.DeterministicOutboundIPEnabled), - // Endpoint: to.Ptr("https://myworkspace-abcdefghijklmnop.wus.grafana.azure.com"), - // EnterpriseConfigurations: &armdashboard.EnterpriseConfigurations{ - // MarketplaceAutoRenew: to.Ptr(armdashboard.MarketplaceAutoRenewEnabled), - // MarketplacePlanID: to.Ptr("myPlanId"), - // }, - // GrafanaConfigurations: &armdashboard.GrafanaConfigurations{ - // SMTP: &armdashboard.SMTP{ - // Enabled: to.Ptr(true), - // FromAddress: to.Ptr("test@sendemail.com"), - // FromName: to.Ptr("emailsender"), - // Host: to.Ptr("smtp.sendemail.com:587"), - // SkipVerify: to.Ptr(true), - // StartTLSPolicy: to.Ptr(armdashboard.StartTLSPolicyOpportunisticStartTLS), - // User: to.Ptr("username"), - // }, - // }, - // GrafanaIntegrations: &armdashboard.GrafanaIntegrations{ - // AzureMonitorWorkspaceIntegrations: []*armdashboard.AzureMonitorWorkspaceIntegration{ - // { - // AzureMonitorWorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), - // }}, - // }, - // GrafanaMajorVersion: to.Ptr("9"), - // GrafanaPlugins: map[string]*armdashboard.GrafanaPlugin{ - // "sample-plugin-id": &armdashboard.GrafanaPlugin{ - // PluginID: to.Ptr("sample-plugin-id"), - // }, - // }, - // GrafanaVersion: to.Ptr("9.4.5"), - // OutboundIPs: []*string{ - // to.Ptr("192.168.0.1"), - // to.Ptr("192.168.0.2")}, - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // PublicNetworkAccess: to.Ptr(armdashboard.PublicNetworkAccessEnabled), - // ZoneRedundancy: to.Ptr(armdashboard.ZoneRedundancyEnabled), - // }, - // SKU: &armdashboard.ResourceSKU{ - // Name: to.Ptr("Standard"), - // }, - // SystemData: &armdashboard.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Create.json -func ExampleGrafanaClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGrafanaClient().BeginCreate(ctx, "myResourceGroup", "myWorkspace", armdashboard.ManagedGrafana{ - Identity: &armdashboard.ManagedServiceIdentity{ - Type: to.Ptr(armdashboard.ManagedServiceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("West US"), - Properties: &armdashboard.ManagedGrafanaProperties{ - APIKey: to.Ptr(armdashboard.APIKeyEnabled), - DeterministicOutboundIP: to.Ptr(armdashboard.DeterministicOutboundIPEnabled), - EnterpriseConfigurations: &armdashboard.EnterpriseConfigurations{ - MarketplaceAutoRenew: to.Ptr(armdashboard.MarketplaceAutoRenewEnabled), - MarketplacePlanID: to.Ptr("myPlanId"), - }, - GrafanaConfigurations: &armdashboard.GrafanaConfigurations{ - SMTP: &armdashboard.SMTP{ - Enabled: to.Ptr(true), - FromAddress: to.Ptr("test@sendemail.com"), - FromName: to.Ptr("emailsender"), - Host: to.Ptr("smtp.sendemail.com:587"), - Password: to.Ptr(""), - SkipVerify: to.Ptr(true), - StartTLSPolicy: to.Ptr(armdashboard.StartTLSPolicyOpportunisticStartTLS), - User: to.Ptr("username"), - }, - }, - GrafanaIntegrations: &armdashboard.GrafanaIntegrations{ - AzureMonitorWorkspaceIntegrations: []*armdashboard.AzureMonitorWorkspaceIntegration{ - { - AzureMonitorWorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), - }}, - }, - GrafanaMajorVersion: to.Ptr("9"), - GrafanaPlugins: map[string]*armdashboard.GrafanaPlugin{ - "sample-plugin-id": {}, - }, - PublicNetworkAccess: to.Ptr(armdashboard.PublicNetworkAccessEnabled), - ZoneRedundancy: to.Ptr(armdashboard.ZoneRedundancyEnabled), - }, - SKU: &armdashboard.ResourceSKU{ - Name: to.Ptr("Standard"), - }, - Tags: map[string]*string{ - "Environment": to.Ptr("Dev"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ManagedGrafana = armdashboard.ManagedGrafana{ - // Name: to.Ptr("myWorkspace"), - // Type: to.Ptr("Microsoft.Dashboard/grafana"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/grafana/myWorkspace"), - // Identity: &armdashboard.ManagedServiceIdentity{ - // Type: to.Ptr(armdashboard.ManagedServiceIdentityTypeSystemAssigned), - // }, - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedGrafanaProperties{ - // APIKey: to.Ptr(armdashboard.APIKeyEnabled), - // AutoGeneratedDomainNameLabelScope: to.Ptr(armdashboard.AutoGeneratedDomainNameLabelScopeTenantReuse), - // DeterministicOutboundIP: to.Ptr(armdashboard.DeterministicOutboundIPEnabled), - // Endpoint: to.Ptr("https://myworkspace-abcdefghijklmnop.wus.grafana.azure.com"), - // EnterpriseConfigurations: &armdashboard.EnterpriseConfigurations{ - // MarketplaceAutoRenew: to.Ptr(armdashboard.MarketplaceAutoRenewEnabled), - // MarketplacePlanID: to.Ptr("myPlanId"), - // }, - // GrafanaConfigurations: &armdashboard.GrafanaConfigurations{ - // SMTP: &armdashboard.SMTP{ - // Enabled: to.Ptr(true), - // FromAddress: to.Ptr("test@sendemail.com"), - // FromName: to.Ptr("emailsender"), - // Host: to.Ptr("smtp.sendemail.com:587"), - // SkipVerify: to.Ptr(true), - // StartTLSPolicy: to.Ptr(armdashboard.StartTLSPolicyOpportunisticStartTLS), - // User: to.Ptr("username"), - // }, - // }, - // GrafanaIntegrations: &armdashboard.GrafanaIntegrations{ - // AzureMonitorWorkspaceIntegrations: []*armdashboard.AzureMonitorWorkspaceIntegration{ - // { - // AzureMonitorWorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), - // }}, - // }, - // GrafanaMajorVersion: to.Ptr("9"), - // GrafanaPlugins: map[string]*armdashboard.GrafanaPlugin{ - // "sample-plugin-id": &armdashboard.GrafanaPlugin{ - // PluginID: to.Ptr("sample-plugin-id"), - // }, - // }, - // GrafanaVersion: to.Ptr("9.4.5"), - // OutboundIPs: []*string{ - // to.Ptr("192.168.0.1"), - // to.Ptr("192.168.0.2")}, - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // PublicNetworkAccess: to.Ptr(armdashboard.PublicNetworkAccessEnabled), - // ZoneRedundancy: to.Ptr(armdashboard.ZoneRedundancyEnabled), - // }, - // SKU: &armdashboard.ResourceSKU{ - // Name: to.Ptr("Standard"), - // }, - // SystemData: &armdashboard.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Update.json -func ExampleGrafanaClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGrafanaClient().Update(ctx, "myResourceGroup", "myWorkspace", armdashboard.ManagedGrafanaUpdateParameters{ - Properties: &armdashboard.ManagedGrafanaPropertiesUpdateParameters{ - APIKey: to.Ptr(armdashboard.APIKeyEnabled), - DeterministicOutboundIP: to.Ptr(armdashboard.DeterministicOutboundIPEnabled), - EnterpriseConfigurations: &armdashboard.EnterpriseConfigurations{ - MarketplaceAutoRenew: to.Ptr(armdashboard.MarketplaceAutoRenewEnabled), - MarketplacePlanID: to.Ptr("myPlanId"), - }, - GrafanaConfigurations: &armdashboard.GrafanaConfigurations{ - SMTP: &armdashboard.SMTP{ - Enabled: to.Ptr(true), - FromAddress: to.Ptr("test@sendemail.com"), - FromName: to.Ptr("emailsender"), - Host: to.Ptr("smtp.sendemail.com:587"), - Password: to.Ptr(""), - SkipVerify: to.Ptr(true), - StartTLSPolicy: to.Ptr(armdashboard.StartTLSPolicyOpportunisticStartTLS), - User: to.Ptr("username"), - }, - }, - GrafanaIntegrations: &armdashboard.GrafanaIntegrations{ - AzureMonitorWorkspaceIntegrations: []*armdashboard.AzureMonitorWorkspaceIntegration{ - { - AzureMonitorWorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), - }}, - }, - GrafanaMajorVersion: to.Ptr("9"), - GrafanaPlugins: map[string]*armdashboard.GrafanaPlugin{ - "sample-plugin-id": {}, - }, - }, - SKU: &armdashboard.ResourceSKU{ - Name: to.Ptr("Standard"), - }, - Tags: map[string]*string{ - "Environment": to.Ptr("Dev 2"), - }, - }, 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.ManagedGrafana = armdashboard.ManagedGrafana{ - // Name: to.Ptr("myWorkspace"), - // Type: to.Ptr("Microsoft.Dashboard/grafana"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/grafana/myWorkspace"), - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedGrafanaProperties{ - // APIKey: to.Ptr(armdashboard.APIKeyEnabled), - // AutoGeneratedDomainNameLabelScope: to.Ptr(armdashboard.AutoGeneratedDomainNameLabelScopeTenantReuse), - // DeterministicOutboundIP: to.Ptr(armdashboard.DeterministicOutboundIPEnabled), - // Endpoint: to.Ptr("https://myworkspace-abcdefghijklmnop.wus.grafana.azure.com"), - // EnterpriseConfigurations: &armdashboard.EnterpriseConfigurations{ - // MarketplaceAutoRenew: to.Ptr(armdashboard.MarketplaceAutoRenewEnabled), - // MarketplacePlanID: to.Ptr("myPlanId"), - // }, - // GrafanaConfigurations: &armdashboard.GrafanaConfigurations{ - // SMTP: &armdashboard.SMTP{ - // Enabled: to.Ptr(true), - // FromAddress: to.Ptr("test@sendemail.com"), - // FromName: to.Ptr("emailsender"), - // Host: to.Ptr("smtp.sendemail.com:587"), - // SkipVerify: to.Ptr(true), - // StartTLSPolicy: to.Ptr(armdashboard.StartTLSPolicyOpportunisticStartTLS), - // User: to.Ptr("username"), - // }, - // }, - // GrafanaIntegrations: &armdashboard.GrafanaIntegrations{ - // AzureMonitorWorkspaceIntegrations: []*armdashboard.AzureMonitorWorkspaceIntegration{ - // { - // AzureMonitorWorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), - // }}, - // }, - // GrafanaMajorVersion: to.Ptr("9"), - // GrafanaPlugins: map[string]*armdashboard.GrafanaPlugin{ - // "sample-plugin-id": &armdashboard.GrafanaPlugin{ - // PluginID: to.Ptr("sample-plugin-id"), - // }, - // }, - // GrafanaVersion: to.Ptr("9.4.5"), - // OutboundIPs: []*string{ - // to.Ptr("192.168.0.1"), - // to.Ptr("192.168.0.2")}, - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // PublicNetworkAccess: to.Ptr(armdashboard.PublicNetworkAccessEnabled), - // ZoneRedundancy: to.Ptr(armdashboard.ZoneRedundancyEnabled), - // }, - // SKU: &armdashboard.ResourceSKU{ - // Name: to.Ptr("Standard"), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev 2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Delete.json -func ExampleGrafanaClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGrafanaClient().BeginDelete(ctx, "myResourceGroup", "myWorkspace", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/EnterpriseDetails_Post.json -func ExampleGrafanaClient_CheckEnterpriseDetails() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGrafanaClient().CheckEnterpriseDetails(ctx, "myResourceGroup", "myWorkspace", 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.EnterpriseDetails = armdashboard.EnterpriseDetails{ - // MarketplaceTrialQuota: &armdashboard.MarketplaceTrialQuota{ - // AvailablePromotion: to.Ptr(armdashboard.AvailablePromotionNone), - // GrafanaResourceID: to.Ptr("/subscriptions/e1e3b30d-e7ec-4e25-8587-db037bcb9a4d/resourcegroups/amg-local-script-test-rg/providers/microsoft.dashboard/grafana/eus2-enterprise-1001-07"), - // TrialEndAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-03T01:06:00.447Z"); return t}()), - // TrialStartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-04T01:06:00.447Z"); return t}()), - // }, - // SaasSubscriptionDetails: &armdashboard.SaasSubscriptionDetails{ - // OfferID: to.Ptr("amg_test"), - // PlanID: to.Ptr("amg_globalplan"), - // PublisherID: to.Ptr("isvtestuklegacy"), - // Term: &armdashboard.SubscriptionTerm{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-03T00:00:00.000Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-04T00:00:00.000Z"); return t}()), - // TermUnit: to.Ptr("P1M"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_FetchAvailablePlugins.json -func ExampleGrafanaClient_FetchAvailablePlugins() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGrafanaClient().FetchAvailablePlugins(ctx, "myResourceGroup", "myWorkspace", 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.GrafanaAvailablePluginListResponse = armdashboard.GrafanaAvailablePluginListResponse{ - // Value: []*armdashboard.GrafanaAvailablePlugin{ - // { - // Name: to.Ptr("Plugin A"), - // PluginID: to.Ptr("plugin-a"), - // }, - // { - // Name: to.Ptr("Plugin B"), - // PluginID: to.Ptr("plugin-b"), - // }}, - // } -} diff --git a/sdk/resourcemanager/dashboard/armdashboard/integrationfabrics_client.go b/sdk/resourcemanager/dashboard/armdashboard/integrationfabrics_client.go new file mode 100644 index 000000000000..b393f8dbc339 --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/integrationfabrics_client.go @@ -0,0 +1,415 @@ +// 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 armdashboard + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// IntegrationFabricsClient contains the methods for the IntegrationFabrics group. +// Don't use this type directly, use NewIntegrationFabricsClient() instead. +type IntegrationFabricsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewIntegrationFabricsClient creates a new instance of IntegrationFabricsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewIntegrationFabricsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationFabricsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &IntegrationFabricsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The workspace name of Azure Managed Grafana. +// - integrationFabricName - The integration fabric name of Azure Managed Grafana. +// - options - IntegrationFabricsClientBeginCreateOptions contains the optional parameters for the IntegrationFabricsClient.BeginCreate +// method. +func (client *IntegrationFabricsClient) BeginCreate(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, requestBodyParameters IntegrationFabric, options *IntegrationFabricsClientBeginCreateOptions) (*runtime.Poller[IntegrationFabricsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, workspaceName, integrationFabricName, requestBodyParameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationFabricsClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[IntegrationFabricsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *IntegrationFabricsClient) create(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, requestBodyParameters IntegrationFabric, options *IntegrationFabricsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "IntegrationFabricsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, workspaceName, integrationFabricName, requestBodyParameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *IntegrationFabricsClient) createCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, requestBodyParameters IntegrationFabric, _ *IntegrationFabricsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if integrationFabricName == "" { + return nil, errors.New("parameter integrationFabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{integrationFabricName}", url.PathEscape(integrationFabricName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBodyParameters); err != nil { + return nil, err + } + return req, nil +} + +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The workspace name of Azure Managed Grafana. +// - integrationFabricName - The integration fabric name of Azure Managed Grafana. +// - options - IntegrationFabricsClientBeginDeleteOptions contains the optional parameters for the IntegrationFabricsClient.BeginDelete +// method. +func (client *IntegrationFabricsClient) BeginDelete(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, options *IntegrationFabricsClientBeginDeleteOptions) (*runtime.Poller[IntegrationFabricsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, workspaceName, integrationFabricName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationFabricsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[IntegrationFabricsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *IntegrationFabricsClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, options *IntegrationFabricsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "IntegrationFabricsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, integrationFabricName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *IntegrationFabricsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, _ *IntegrationFabricsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if integrationFabricName == "" { + return nil, errors.New("parameter integrationFabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{integrationFabricName}", url.PathEscape(integrationFabricName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The workspace name of Azure Managed Grafana. +// - integrationFabricName - The integration fabric name of Azure Managed Grafana. +// - options - IntegrationFabricsClientGetOptions contains the optional parameters for the IntegrationFabricsClient.Get method. +func (client *IntegrationFabricsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, options *IntegrationFabricsClientGetOptions) (IntegrationFabricsClientGetResponse, error) { + var err error + const operationName = "IntegrationFabricsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, integrationFabricName, options) + if err != nil { + return IntegrationFabricsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IntegrationFabricsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationFabricsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *IntegrationFabricsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, _ *IntegrationFabricsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if integrationFabricName == "" { + return nil, errors.New("parameter integrationFabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{integrationFabricName}", url.PathEscape(integrationFabricName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *IntegrationFabricsClient) getHandleResponse(resp *http.Response) (IntegrationFabricsClientGetResponse, error) { + result := IntegrationFabricsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IntegrationFabric); err != nil { + return IntegrationFabricsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The workspace name of Azure Managed Grafana. +// - options - IntegrationFabricsClientListOptions contains the optional parameters for the IntegrationFabricsClient.NewListPager +// method. +func (client *IntegrationFabricsClient) NewListPager(resourceGroupName string, workspaceName string, options *IntegrationFabricsClientListOptions) *runtime.Pager[IntegrationFabricsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[IntegrationFabricsClientListResponse]{ + More: func(page IntegrationFabricsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *IntegrationFabricsClientListResponse) (IntegrationFabricsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationFabricsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, workspaceName, options) + }, nil) + if err != nil { + return IntegrationFabricsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *IntegrationFabricsClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *IntegrationFabricsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *IntegrationFabricsClient) listHandleResponse(resp *http.Response) (IntegrationFabricsClientListResponse, error) { + result := IntegrationFabricsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IntegrationFabricListResponse); err != nil { + return IntegrationFabricsClientListResponse{}, err + } + return result, nil +} + +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - workspaceName - The workspace name of Azure Managed Grafana. +// - integrationFabricName - The integration fabric name of Azure Managed Grafana. +// - options - IntegrationFabricsClientBeginUpdateOptions contains the optional parameters for the IntegrationFabricsClient.BeginUpdate +// method. +func (client *IntegrationFabricsClient) BeginUpdate(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, requestBodyParameters IntegrationFabricUpdateParameters, options *IntegrationFabricsClientBeginUpdateOptions) (*runtime.Poller[IntegrationFabricsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, workspaceName, integrationFabricName, requestBodyParameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationFabricsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[IntegrationFabricsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *IntegrationFabricsClient) update(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, requestBodyParameters IntegrationFabricUpdateParameters, options *IntegrationFabricsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "IntegrationFabricsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, workspaceName, integrationFabricName, requestBodyParameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *IntegrationFabricsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, integrationFabricName string, requestBodyParameters IntegrationFabricUpdateParameters, _ *IntegrationFabricsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/integrationFabrics/{integrationFabricName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if integrationFabricName == "" { + return nil, errors.New("parameter integrationFabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{integrationFabricName}", url.PathEscape(integrationFabricName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBodyParameters); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/manageddashboards_client.go b/sdk/resourcemanager/dashboard/armdashboard/manageddashboards_client.go new file mode 100644 index 000000000000..93a35b97bfbc --- /dev/null +++ b/sdk/resourcemanager/dashboard/armdashboard/manageddashboards_client.go @@ -0,0 +1,246 @@ +// 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 armdashboard + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ManagedDashboardsClient contains the methods for the ManagedDashboards group. +// Don't use this type directly, use NewManagedDashboardsClient() instead. +type ManagedDashboardsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewManagedDashboardsClient creates a new instance of ManagedDashboardsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewManagedDashboardsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagedDashboardsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ManagedDashboardsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create or update a dashboard for grafana resource. This API is idempotent, so user can either create a new +// dashboard or update an existing dashboard. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dashboardName - The name of the Azure Managed Dashboard. +// - options - ManagedDashboardsClientBeginCreateOptions contains the optional parameters for the ManagedDashboardsClient.BeginCreate +// method. +func (client *ManagedDashboardsClient) BeginCreate(ctx context.Context, resourceGroupName string, dashboardName string, requestBodyParameters ManagedDashboard, options *ManagedDashboardsClientBeginCreateOptions) (*runtime.Poller[ManagedDashboardsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, dashboardName, requestBodyParameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagedDashboardsClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagedDashboardsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create or update a dashboard for grafana resource. This API is idempotent, so user can either create a new dashboard +// or update an existing dashboard. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +func (client *ManagedDashboardsClient) create(ctx context.Context, resourceGroupName string, dashboardName string, requestBodyParameters ManagedDashboard, options *ManagedDashboardsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "ManagedDashboardsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, dashboardName, requestBodyParameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *ManagedDashboardsClient) createCreateRequest(ctx context.Context, resourceGroupName string, dashboardName string, requestBodyParameters ManagedDashboard, _ *ManagedDashboardsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dashboardName == "" { + return nil, errors.New("parameter dashboardName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dashboardName}", url.PathEscape(dashboardName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBodyParameters); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Delete a dashboard for Grafana resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dashboardName - The name of the Azure Managed Dashboard. +// - options - ManagedDashboardsClientDeleteOptions contains the optional parameters for the ManagedDashboardsClient.Delete +// method. +func (client *ManagedDashboardsClient) Delete(ctx context.Context, resourceGroupName string, dashboardName string, options *ManagedDashboardsClientDeleteOptions) (ManagedDashboardsClientDeleteResponse, error) { + var err error + const operationName = "ManagedDashboardsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dashboardName, options) + if err != nil { + return ManagedDashboardsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ManagedDashboardsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ManagedDashboardsClientDeleteResponse{}, err + } + return ManagedDashboardsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ManagedDashboardsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dashboardName string, _ *ManagedDashboardsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dashboardName == "" { + return nil, errors.New("parameter dashboardName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dashboardName}", url.PathEscape(dashboardName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Update - Update a dashboard for Grafana resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dashboardName - The name of the Azure Managed Dashboard. +// - options - ManagedDashboardsClientUpdateOptions contains the optional parameters for the ManagedDashboardsClient.Update +// method. +func (client *ManagedDashboardsClient) Update(ctx context.Context, resourceGroupName string, dashboardName string, requestBodyParameters ManagedDashboardUpdateParameters, options *ManagedDashboardsClientUpdateOptions) (ManagedDashboardsClientUpdateResponse, error) { + var err error + const operationName = "ManagedDashboardsClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, dashboardName, requestBodyParameters, options) + if err != nil { + return ManagedDashboardsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ManagedDashboardsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ManagedDashboardsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *ManagedDashboardsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, dashboardName string, requestBodyParameters ManagedDashboardUpdateParameters, _ *ManagedDashboardsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/dashboards/{dashboardName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dashboardName == "" { + return nil, errors.New("parameter dashboardName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dashboardName}", url.PathEscape(dashboardName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-11-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBodyParameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *ManagedDashboardsClient) updateHandleResponse(resp *http.Response) (ManagedDashboardsClientUpdateResponse, error) { + result := ManagedDashboardsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagedDashboard); err != nil { + return ManagedDashboardsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/managedprivateendpoints_client.go b/sdk/resourcemanager/dashboard/armdashboard/managedprivateendpoints_client.go index 2d47ebb70713..23f517ebb15a 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/managedprivateendpoints_client.go +++ b/sdk/resourcemanager/dashboard/armdashboard/managedprivateendpoints_client.go @@ -1,6 +1,3 @@ -//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. @@ -46,7 +43,7 @@ func NewManagedPrivateEndpointsClient(subscriptionID string, credential azcore.T // BeginCreate - Create or update a managed private endpoint for a grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - managedPrivateEndpointName - The managed private endpoint name of Azure Managed Grafana. @@ -74,7 +71,7 @@ func (client *ManagedPrivateEndpointsClient) BeginCreate(ctx context.Context, re // Create - Create or update a managed private endpoint for a grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview func (client *ManagedPrivateEndpointsClient) create(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, requestBodyParameters ManagedPrivateEndpointModel, options *ManagedPrivateEndpointsClientBeginCreateOptions) (*http.Response, error) { var err error const operationName = "ManagedPrivateEndpointsClient.BeginCreate" @@ -97,7 +94,7 @@ func (client *ManagedPrivateEndpointsClient) create(ctx context.Context, resourc } // createCreateRequest creates the Create request. -func (client *ManagedPrivateEndpointsClient) createCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, requestBodyParameters ManagedPrivateEndpointModel, options *ManagedPrivateEndpointsClientBeginCreateOptions) (*policy.Request, error) { +func (client *ManagedPrivateEndpointsClient) createCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, requestBodyParameters ManagedPrivateEndpointModel, _ *ManagedPrivateEndpointsClientBeginCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -120,7 +117,7 @@ func (client *ManagedPrivateEndpointsClient) createCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, requestBodyParameters); err != nil { @@ -132,7 +129,7 @@ func (client *ManagedPrivateEndpointsClient) createCreateRequest(ctx context.Con // BeginDelete - Delete a managed private endpoint for a grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - managedPrivateEndpointName - The managed private endpoint name of Azure Managed Grafana. @@ -159,7 +156,7 @@ func (client *ManagedPrivateEndpointsClient) BeginDelete(ctx context.Context, re // Delete - Delete a managed private endpoint for a grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview func (client *ManagedPrivateEndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ManagedPrivateEndpointsClient.BeginDelete" @@ -182,7 +179,7 @@ func (client *ManagedPrivateEndpointsClient) deleteOperation(ctx context.Context } // deleteCreateRequest creates the Delete request. -func (client *ManagedPrivateEndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *ManagedPrivateEndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, _ *ManagedPrivateEndpointsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -205,7 +202,7 @@ func (client *ManagedPrivateEndpointsClient) deleteCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -214,7 +211,7 @@ func (client *ManagedPrivateEndpointsClient) deleteCreateRequest(ctx context.Con // Get - Get a specific managed private endpoint of a grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - managedPrivateEndpointName - The managed private endpoint name of Azure Managed Grafana. @@ -243,7 +240,7 @@ func (client *ManagedPrivateEndpointsClient) Get(ctx context.Context, resourceGr } // getCreateRequest creates the Get request. -func (client *ManagedPrivateEndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsClientGetOptions) (*policy.Request, error) { +func (client *ManagedPrivateEndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, _ *ManagedPrivateEndpointsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -266,7 +263,7 @@ func (client *ManagedPrivateEndpointsClient) getCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -283,7 +280,7 @@ func (client *ManagedPrivateEndpointsClient) getHandleResponse(resp *http.Respon // NewListPager - List all managed private endpoints of a grafana resource. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - ManagedPrivateEndpointsClientListOptions contains the optional parameters for the ManagedPrivateEndpointsClient.NewListPager @@ -312,7 +309,7 @@ func (client *ManagedPrivateEndpointsClient) NewListPager(resourceGroupName stri } // listCreateRequest creates the List request. -func (client *ManagedPrivateEndpointsClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *ManagedPrivateEndpointsClientListOptions) (*policy.Request, error) { +func (client *ManagedPrivateEndpointsClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *ManagedPrivateEndpointsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -331,7 +328,7 @@ func (client *ManagedPrivateEndpointsClient) listCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -349,7 +346,7 @@ func (client *ManagedPrivateEndpointsClient) listHandleResponse(resp *http.Respo // BeginRefresh - Refresh and sync managed private endpoints of a grafana resource to latest state. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - ManagedPrivateEndpointsClientBeginRefreshOptions contains the optional parameters for the ManagedPrivateEndpointsClient.BeginRefresh @@ -375,7 +372,7 @@ func (client *ManagedPrivateEndpointsClient) BeginRefresh(ctx context.Context, r // Refresh - Refresh and sync managed private endpoints of a grafana resource to latest state. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview func (client *ManagedPrivateEndpointsClient) refresh(ctx context.Context, resourceGroupName string, workspaceName string, options *ManagedPrivateEndpointsClientBeginRefreshOptions) (*http.Response, error) { var err error const operationName = "ManagedPrivateEndpointsClient.BeginRefresh" @@ -398,7 +395,7 @@ func (client *ManagedPrivateEndpointsClient) refresh(ctx context.Context, resour } // refreshCreateRequest creates the Refresh request. -func (client *ManagedPrivateEndpointsClient) refreshCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *ManagedPrivateEndpointsClientBeginRefreshOptions) (*policy.Request, error) { +func (client *ManagedPrivateEndpointsClient) refreshCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *ManagedPrivateEndpointsClientBeginRefreshOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/refreshManagedPrivateEndpoints" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -417,7 +414,7 @@ func (client *ManagedPrivateEndpointsClient) refreshCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -426,7 +423,7 @@ func (client *ManagedPrivateEndpointsClient) refreshCreateRequest(ctx context.Co // BeginUpdate - Update a managed private endpoint for an existing grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - managedPrivateEndpointName - The managed private endpoint name of Azure Managed Grafana. @@ -454,7 +451,7 @@ func (client *ManagedPrivateEndpointsClient) BeginUpdate(ctx context.Context, re // Update - Update a managed private endpoint for an existing grafana resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview func (client *ManagedPrivateEndpointsClient) update(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, requestBodyParameters ManagedPrivateEndpointUpdateParameters, options *ManagedPrivateEndpointsClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "ManagedPrivateEndpointsClient.BeginUpdate" @@ -477,7 +474,7 @@ func (client *ManagedPrivateEndpointsClient) update(ctx context.Context, resourc } // updateCreateRequest creates the Update request. -func (client *ManagedPrivateEndpointsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, requestBodyParameters ManagedPrivateEndpointUpdateParameters, options *ManagedPrivateEndpointsClientBeginUpdateOptions) (*policy.Request, error) { +func (client *ManagedPrivateEndpointsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, managedPrivateEndpointName string, requestBodyParameters ManagedPrivateEndpointUpdateParameters, _ *ManagedPrivateEndpointsClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/managedPrivateEndpoints/{managedPrivateEndpointName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -500,7 +497,7 @@ func (client *ManagedPrivateEndpointsClient) updateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, requestBodyParameters); err != nil { diff --git a/sdk/resourcemanager/dashboard/armdashboard/managedprivateendpoints_client_example_test.go b/sdk/resourcemanager/dashboard/armdashboard/managedprivateendpoints_client_example_test.go deleted file mode 100644 index e80ab588d9c5..000000000000 --- a/sdk/resourcemanager/dashboard/armdashboard/managedprivateendpoints_client_example_test.go +++ /dev/null @@ -1,282 +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 armdashboard_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_List.json -func ExampleManagedPrivateEndpointsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagedPrivateEndpointsClient().NewListPager("myResourceGroup", "myWorkspace", 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.ManagedPrivateEndpointModelListResponse = armdashboard.ManagedPrivateEndpointModelListResponse{ - // Value: []*armdashboard.ManagedPrivateEndpointModel{ - // { - // Name: to.Ptr("myMPEName"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/managedPrivateEndpoint"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/managedPrivateEndpoints/myPrivateEndpointName"), - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedPrivateEndpointModelProperties{ - // ConnectionState: &armdashboard.ManagedPrivateEndpointConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // Status: to.Ptr(armdashboard.ManagedPrivateEndpointConnectionStatusApproved), - // }, - // GroupIDs: []*string{ - // to.Ptr("grafana")}, - // PrivateLinkResourceID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-000000000000/resourceGroups/xx-rg/providers/Microsoft.Kusto/Clusters/sampleKustoResource1"), - // PrivateLinkResourceRegion: to.Ptr("West US"), - // PrivateLinkServicePrivateIP: to.Ptr("10.0.0.5"), - // PrivateLinkServiceURL: to.Ptr("my-self-hosted-influxdb.westus.mydomain.com"), - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // RequestMessage: to.Ptr("Example Request Message"), - // }, - // }, - // { - // Name: to.Ptr("myMPEName2"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/managedPrivateEndpoint"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/managedPrivateEndpoints/myPrivateEndpointName2"), - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedPrivateEndpointModelProperties{ - // ConnectionState: &armdashboard.ManagedPrivateEndpointConnectionState{ - // Description: to.Ptr("Example Reject Reason"), - // Status: to.Ptr(armdashboard.ManagedPrivateEndpointConnectionStatusRejected), - // }, - // GroupIDs: []*string{ - // to.Ptr("grafana")}, - // PrivateLinkResourceID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-000000000000/resourceGroups/xx-rg/providers/Microsoft.Kusto/Clusters/sampleKustoResource2"), - // PrivateLinkResourceRegion: to.Ptr("West US"), - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // RequestMessage: to.Ptr("Example Request Message 2"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Refresh.json -func ExampleManagedPrivateEndpointsClient_BeginRefresh() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewManagedPrivateEndpointsClient().BeginRefresh(ctx, "myResourceGroup", "myWorkspace", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Get.json -func ExampleManagedPrivateEndpointsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagedPrivateEndpointsClient().Get(ctx, "myResourceGroup", "myWorkspace", "myMPEName", 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.ManagedPrivateEndpointModel = armdashboard.ManagedPrivateEndpointModel{ - // Name: to.Ptr("myMPEName"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/managedPrivateEndpoint"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/managedPrivateEndpoints/myPrivateEndpointName"), - // SystemData: &armdashboard.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // }, - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedPrivateEndpointModelProperties{ - // ConnectionState: &armdashboard.ManagedPrivateEndpointConnectionState{ - // Description: to.Ptr("Auto-Approved"), - // Status: to.Ptr(armdashboard.ManagedPrivateEndpointConnectionStatusApproved), - // }, - // GroupIDs: []*string{ - // to.Ptr("grafana")}, - // PrivateLinkResourceID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-000000000000/resourceGroups/xx-rg/providers/Microsoft.Kusto/Clusters/sampleKustoResource"), - // PrivateLinkResourceRegion: to.Ptr("West US"), - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // RequestMessage: to.Ptr("Example Request Message"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Create.json -func ExampleManagedPrivateEndpointsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewManagedPrivateEndpointsClient().BeginCreate(ctx, "myResourceGroup", "myWorkspace", "myMPEName", armdashboard.ManagedPrivateEndpointModel{ - Location: to.Ptr("West US"), - Properties: &armdashboard.ManagedPrivateEndpointModelProperties{ - GroupIDs: []*string{ - to.Ptr("grafana")}, - PrivateLinkResourceID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-000000000000/resourceGroups/xx-rg/providers/Microsoft.Kusto/Clusters/sampleKustoResource"), - PrivateLinkResourceRegion: to.Ptr("West US"), - PrivateLinkServiceURL: to.Ptr("my-self-hosted-influxdb.westus.mydomain.com"), - RequestMessage: to.Ptr("Example Request Message"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ManagedPrivateEndpointModel = armdashboard.ManagedPrivateEndpointModel{ - // Name: to.Ptr("myMPEName"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/managedPrivateEndpoint"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/managedPrivateEndpoints/myPrivateEndpointName"), - // SystemData: &armdashboard.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // }, - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedPrivateEndpointModelProperties{ - // GroupIDs: []*string{ - // to.Ptr("grafana")}, - // PrivateLinkResourceID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-000000000000/resourceGroups/xx-rg/providers/Microsoft.Kusto/Clusters/sampleKustoResource"), - // PrivateLinkResourceRegion: to.Ptr("West US"), - // PrivateLinkServiceURL: to.Ptr("my-self-hosted-influxdb.westus.mydomain.com"), - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // RequestMessage: to.Ptr("Example Request Message"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Patch.json -func ExampleManagedPrivateEndpointsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewManagedPrivateEndpointsClient().BeginUpdate(ctx, "myResourceGroup", "myWorkspace", "myMPEName", armdashboard.ManagedPrivateEndpointUpdateParameters{ - Tags: map[string]*string{ - "Environment": to.Ptr("Dev 2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ManagedPrivateEndpointModel = armdashboard.ManagedPrivateEndpointModel{ - // Name: to.Ptr("myMPEName"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/managedPrivateEndpoint"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/managedPrivateEndpoints/myPrivateEndpointName"), - // SystemData: &armdashboard.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdashboard.CreatedByTypeUser), - // }, - // Location: to.Ptr("West US"), - // Properties: &armdashboard.ManagedPrivateEndpointModelProperties{ - // GroupIDs: []*string{ - // to.Ptr("grafana")}, - // PrivateLinkResourceID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-000000000000/resourceGroups/xx-rg/providers/Microsoft.Kusto/Clusters/sampleKustoResource"), - // PrivateLinkResourceRegion: to.Ptr("West US"), - // PrivateLinkServicePrivateIP: to.Ptr("10.0.0.5"), - // PrivateLinkServiceURL: to.Ptr("my-self-hosted-influxdb.westus.mydomain.com"), - // ProvisioningState: to.Ptr(armdashboard.ProvisioningStateSucceeded), - // RequestMessage: to.Ptr("Example Request Message"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Delete.json -func ExampleManagedPrivateEndpointsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewManagedPrivateEndpointsClient().BeginDelete(ctx, "myResourceGroup", "myWorkspace", "myMPEName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/dashboard/armdashboard/models.go b/sdk/resourcemanager/dashboard/armdashboard/models.go index 58fb34b61f1d..b401c0215e6e 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/models.go +++ b/sdk/resourcemanager/dashboard/armdashboard/models.go @@ -1,6 +1,3 @@ -//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. @@ -52,6 +49,18 @@ type GrafanaAvailablePluginListResponse struct { type GrafanaConfigurations struct { // Email server settings. https://grafana.com/docs/grafana/v9.0/setup-grafana/configure-grafana/#smtp SMTP *SMTP + + // Grafana security settings + Security *Security + + // Grafana Snapshots settings + Snapshots *Snapshots + + // Grafana Unified Alerting Screenshots settings + UnifiedAlertingScreenshots *UnifiedAlertingScreenshots + + // Grafana users settings + Users *Users } // GrafanaIntegrations is a bundled observability experience (e.g. pre-configured data source, tailored Grafana dashboards, @@ -66,6 +75,103 @@ type GrafanaPlugin struct { PluginID *string } +// IntegrationFabric - The integration fabric resource type. +type IntegrationFabric struct { + // REQUIRED; The geo-location where the resource lives + Location *string + Properties *IntegrationFabricProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +type IntegrationFabricListResponse struct { + NextLink *string + Value []*IntegrationFabric +} + +type IntegrationFabricProperties struct { + // The resource Id of the Azure resource which is used to configure Grafana data source. E.g., an Azure Monitor Workspace, + // an Azure Data Explorer cluster, etc. + DataSourceResourceID *string + + // A list of integration scenarios covered by this integration fabric + Scenarios []*string + + // The resource Id of the Azure resource being integrated with Azure Managed Grafana. E.g., an Azure Kubernetes Service cluster. + TargetResourceID *string + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState +} + +type IntegrationFabricPropertiesUpdateParameters struct { + // The new integration scenarios covered by this integration fabric. + Scenarios []*string +} + +// IntegrationFabricUpdateParameters - The parameters for a PATCH request to a Integration Fabric resource. +type IntegrationFabricUpdateParameters struct { + // The new properties of this Integration Fabric resource + Properties *IntegrationFabricPropertiesUpdateParameters + + // The new tags of the Integration Fabric resource. + Tags map[string]*string +} + +// ManagedDashboard - The managed dashboard resource type. +type ManagedDashboard struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Properties specific to the managed dashboard resource. + Properties *ManagedDashboardProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +type ManagedDashboardListResponse struct { + NextLink *string + Value []*ManagedDashboard +} + +// ManagedDashboardProperties - Properties specific to the grafana resource. +type ManagedDashboardProperties struct { + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState +} + +// ManagedDashboardUpdateParameters - The parameters for a PATCH request to a managed dashboard resource. +type ManagedDashboardUpdateParameters struct { + // The new tags of the managed dashboard resource. + Tags map[string]*string +} + // ManagedGrafana - The grafana resource type. type ManagedGrafana struct { // The managed identity of the grafana resource. @@ -502,6 +608,18 @@ type SaasSubscriptionDetails struct { Term *SubscriptionTerm } +// Security - Grafana security settings +type Security struct { + // Set to true to execute the CSRF check even if the login cookie is not in a request (default false). + CsrfAlwaysCheck *bool +} + +// Snapshots - Grafana Snapshots settings +type Snapshots struct { + // Set to false to disable external snapshot publish endpoint + ExternalEnabled *bool +} + // SubscriptionTerm - The current billing term of the SaaS Subscription. type SubscriptionTerm struct { // The date and time in UTC of when the billing term ends. @@ -535,6 +653,12 @@ type SystemData struct { LastModifiedByType *CreatedByType } +// UnifiedAlertingScreenshots - Grafana Unified Alerting Screenshots settings +type UnifiedAlertingScreenshots struct { + // Set to false to disable capture screenshot in Unified Alert due to performance issue. + CaptureEnabled *bool +} + // UserAssignedIdentity - User assigned identity properties type UserAssignedIdentity struct { // READ-ONLY; The client ID of the assigned identity. @@ -543,3 +667,13 @@ type UserAssignedIdentity struct { // READ-ONLY; The principal ID of the assigned identity. PrincipalID *string } + +// Users - Grafana users settings +type Users struct { + // Set to true so editors can administrate dashboards, folders and teams they create. + EditorsCanAdmin *bool + + // Set to true so viewers can access and use explore and perform temporary edits on panels in dashboards they have access + // to. They cannot save their changes. + ViewersCanEdit *bool +} diff --git a/sdk/resourcemanager/dashboard/armdashboard/models_serde.go b/sdk/resourcemanager/dashboard/armdashboard/models_serde.go index 9137b6a79f07..ba4046bfbade 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/models_serde.go +++ b/sdk/resourcemanager/dashboard/armdashboard/models_serde.go @@ -1,6 +1,3 @@ -//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. @@ -170,6 +167,10 @@ func (g *GrafanaAvailablePluginListResponse) UnmarshalJSON(data []byte) error { func (g GrafanaConfigurations) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "smtp", g.SMTP) + populate(objectMap, "security", g.Security) + populate(objectMap, "snapshots", g.Snapshots) + populate(objectMap, "unifiedAlertingScreenshots", g.UnifiedAlertingScreenshots) + populate(objectMap, "users", g.Users) return json.Marshal(objectMap) } @@ -185,6 +186,18 @@ func (g *GrafanaConfigurations) UnmarshalJSON(data []byte) error { case "smtp": err = unpopulate(val, "SMTP", &g.SMTP) delete(rawMsg, key) + case "security": + err = unpopulate(val, "Security", &g.Security) + delete(rawMsg, key) + case "snapshots": + err = unpopulate(val, "Snapshots", &g.Snapshots) + delete(rawMsg, key) + case "unifiedAlertingScreenshots": + err = unpopulate(val, "UnifiedAlertingScreenshots", &g.UnifiedAlertingScreenshots) + delete(rawMsg, key) + case "users": + err = unpopulate(val, "Users", &g.Users) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -247,6 +260,321 @@ func (g *GrafanaPlugin) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type IntegrationFabric. +func (i IntegrationFabric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + populate(objectMap, "location", i.Location) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "tags", i.Tags) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IntegrationFabric. +func (i *IntegrationFabric) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &i.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IntegrationFabricListResponse. +func (i IntegrationFabricListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IntegrationFabricListResponse. +func (i *IntegrationFabricListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IntegrationFabricProperties. +func (i IntegrationFabricProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataSourceResourceId", i.DataSourceResourceID) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "scenarios", i.Scenarios) + populate(objectMap, "targetResourceId", i.TargetResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IntegrationFabricProperties. +func (i *IntegrationFabricProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataSourceResourceId": + err = unpopulate(val, "DataSourceResourceID", &i.DataSourceResourceID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "scenarios": + err = unpopulate(val, "Scenarios", &i.Scenarios) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, "TargetResourceID", &i.TargetResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IntegrationFabricPropertiesUpdateParameters. +func (i IntegrationFabricPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "scenarios", i.Scenarios) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IntegrationFabricPropertiesUpdateParameters. +func (i *IntegrationFabricPropertiesUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "scenarios": + err = unpopulate(val, "Scenarios", &i.Scenarios) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IntegrationFabricUpdateParameters. +func (i IntegrationFabricUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "tags", i.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IntegrationFabricUpdateParameters. +func (i *IntegrationFabricUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedDashboard. +func (m ManagedDashboard) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + populate(objectMap, "location", m.Location) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "systemData", m.SystemData) + populate(objectMap, "tags", m.Tags) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedDashboard. +func (m *ManagedDashboard) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &m.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedDashboardListResponse. +func (m ManagedDashboardListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedDashboardListResponse. +func (m *ManagedDashboardListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedDashboardProperties. +func (m ManagedDashboardProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", m.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedDashboardProperties. +func (m *ManagedDashboardProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedDashboardUpdateParameters. +func (m ManagedDashboardUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", m.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedDashboardUpdateParameters. +func (m *ManagedDashboardUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ManagedGrafana. func (m ManagedGrafana) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1313,6 +1641,60 @@ func (s *SaasSubscriptionDetails) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Security. +func (s Security) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "csrfAlwaysCheck", s.CsrfAlwaysCheck) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Security. +func (s *Security) 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 "csrfAlwaysCheck": + err = unpopulate(val, "CsrfAlwaysCheck", &s.CsrfAlwaysCheck) + 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 Snapshots. +func (s Snapshots) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "externalEnabled", s.ExternalEnabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Snapshots. +func (s *Snapshots) 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 "externalEnabled": + err = unpopulate(val, "ExternalEnabled", &s.ExternalEnabled) + 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 SubscriptionTerm. func (s SubscriptionTerm) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1395,6 +1777,33 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type UnifiedAlertingScreenshots. +func (u UnifiedAlertingScreenshots) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "captureEnabled", u.CaptureEnabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UnifiedAlertingScreenshots. +func (u *UnifiedAlertingScreenshots) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "captureEnabled": + err = unpopulate(val, "CaptureEnabled", &u.CaptureEnabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1426,6 +1835,37 @@ func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Users. +func (u Users) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "editorsCanAdmin", u.EditorsCanAdmin) + populate(objectMap, "viewersCanEdit", u.ViewersCanEdit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Users. +func (u *Users) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "editorsCanAdmin": + err = unpopulate(val, "EditorsCanAdmin", &u.EditorsCanAdmin) + delete(rawMsg, key) + case "viewersCanEdit": + err = unpopulate(val, "ViewersCanEdit", &u.ViewersCanEdit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + func populate(m map[string]any, k string, v any) { if v == nil { return @@ -1437,7 +1877,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/dashboard/armdashboard/operations_client.go b/sdk/resourcemanager/dashboard/armdashboard/operations_client.go index 4fc1be89fa16..b8ff2bcc5c79 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/operations_client.go +++ b/sdk/resourcemanager/dashboard/armdashboard/operations_client.go @@ -1,6 +1,3 @@ -//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. @@ -39,7 +36,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - List all available API operations provided by Microsoft.Dashboard. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -65,14 +62,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Dashboard/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dashboard/armdashboard/operations_client_example_test.go b/sdk/resourcemanager/dashboard/armdashboard/operations_client_example_test.go deleted file mode 100644 index 0e4fd282bb81..000000000000 --- a/sdk/resourcemanager/dashboard/armdashboard/operations_client_example_test.go +++ /dev/null @@ -1,57 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the 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 armdashboard_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.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 = armdashboard.OperationListResult{ - // Value: []*armdashboard.Operation{ - // { - // Name: to.Ptr("Microsoft.Dashboard/grafana/write"), - // ActionType: to.Ptr(armdashboard.ActionTypeInternal), - // Display: &armdashboard.OperationDisplay{ - // Description: to.Ptr("Write grafana workspace resource"), - // Operation: to.Ptr("write"), - // Provider: to.Ptr("Microsoft.Dashboard"), - // Resource: to.Ptr("grafana"), - // }, - // Origin: to.Ptr(armdashboard.OriginUser), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/dashboard/armdashboard/options.go b/sdk/resourcemanager/dashboard/armdashboard/options.go index cbab7e05a8bf..0e7282dbc6d7 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/options.go +++ b/sdk/resourcemanager/dashboard/armdashboard/options.go @@ -1,6 +1,3 @@ -//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. @@ -8,15 +5,31 @@ package armdashboard +// DashboardsClientGetOptions contains the optional parameters for the DashboardsClient.Get method. +type DashboardsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DashboardsClientListBySubscriptionOptions contains the optional parameters for the DashboardsClient.NewListBySubscriptionPager +// method. +type DashboardsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// DashboardsClientListOptions contains the optional parameters for the DashboardsClient.NewListPager method. +type DashboardsClientListOptions struct { + // placeholder for future optional parameters +} + // GrafanaClientBeginCreateOptions contains the optional parameters for the GrafanaClient.BeginCreate method. type GrafanaClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // GrafanaClientBeginDeleteOptions contains the optional parameters for the GrafanaClient.BeginDelete method. type GrafanaClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -53,31 +66,79 @@ type GrafanaClientUpdateOptions struct { // placeholder for future optional parameters } +// IntegrationFabricsClientBeginCreateOptions contains the optional parameters for the IntegrationFabricsClient.BeginCreate +// method. +type IntegrationFabricsClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// IntegrationFabricsClientBeginDeleteOptions contains the optional parameters for the IntegrationFabricsClient.BeginDelete +// method. +type IntegrationFabricsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// IntegrationFabricsClientBeginUpdateOptions contains the optional parameters for the IntegrationFabricsClient.BeginUpdate +// method. +type IntegrationFabricsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// IntegrationFabricsClientGetOptions contains the optional parameters for the IntegrationFabricsClient.Get method. +type IntegrationFabricsClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationFabricsClientListOptions contains the optional parameters for the IntegrationFabricsClient.NewListPager method. +type IntegrationFabricsClientListOptions struct { + // placeholder for future optional parameters +} + +// ManagedDashboardsClientBeginCreateOptions contains the optional parameters for the ManagedDashboardsClient.BeginCreate +// method. +type ManagedDashboardsClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ManagedDashboardsClientDeleteOptions contains the optional parameters for the ManagedDashboardsClient.Delete method. +type ManagedDashboardsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ManagedDashboardsClientUpdateOptions contains the optional parameters for the ManagedDashboardsClient.Update method. +type ManagedDashboardsClientUpdateOptions struct { + // placeholder for future optional parameters +} + // ManagedPrivateEndpointsClientBeginCreateOptions contains the optional parameters for the ManagedPrivateEndpointsClient.BeginCreate // method. type ManagedPrivateEndpointsClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ManagedPrivateEndpointsClientBeginDeleteOptions contains the optional parameters for the ManagedPrivateEndpointsClient.BeginDelete // method. type ManagedPrivateEndpointsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ManagedPrivateEndpointsClientBeginRefreshOptions contains the optional parameters for the ManagedPrivateEndpointsClient.BeginRefresh // method. type ManagedPrivateEndpointsClientBeginRefreshOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ManagedPrivateEndpointsClientBeginUpdateOptions contains the optional parameters for the ManagedPrivateEndpointsClient.BeginUpdate // method. type ManagedPrivateEndpointsClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -100,14 +161,14 @@ type OperationsClientListOptions struct { // PrivateEndpointConnectionsClientBeginApproveOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginApprove // method. type PrivateEndpointConnectionsClientBeginApproveOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // PrivateEndpointConnectionsClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginDelete // method. type PrivateEndpointConnectionsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } diff --git a/sdk/resourcemanager/dashboard/armdashboard/privateendpointconnections_client.go b/sdk/resourcemanager/dashboard/armdashboard/privateendpointconnections_client.go index 5080c6689276..5945e03cac31 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/privateendpointconnections_client.go +++ b/sdk/resourcemanager/dashboard/armdashboard/privateendpointconnections_client.go @@ -1,6 +1,3 @@ -//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. @@ -46,7 +43,7 @@ func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcor // BeginApprove - Manual approve private endpoint connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - privateEndpointConnectionName - The private endpoint connection name of Azure Managed Grafana. @@ -73,7 +70,7 @@ func (client *PrivateEndpointConnectionsClient) BeginApprove(ctx context.Context // Approve - Manual approve private endpoint connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview func (client *PrivateEndpointConnectionsClient) approve(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, body PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginApproveOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionsClient.BeginApprove" @@ -96,7 +93,7 @@ func (client *PrivateEndpointConnectionsClient) approve(ctx context.Context, res } // approveCreateRequest creates the Approve request. -func (client *PrivateEndpointConnectionsClient) approveCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, body PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginApproveOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) approveCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, body PrivateEndpointConnection, _ *PrivateEndpointConnectionsClientBeginApproveOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -119,7 +116,7 @@ func (client *PrivateEndpointConnectionsClient) approveCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { @@ -131,7 +128,7 @@ func (client *PrivateEndpointConnectionsClient) approveCreateRequest(ctx context // BeginDelete - Delete private endpoint connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - privateEndpointConnectionName - The private endpoint connection name of Azure Managed Grafana. @@ -158,7 +155,7 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // Delete - Delete private endpoint connection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionsClient.BeginDelete" @@ -181,7 +178,7 @@ func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Cont } // deleteCreateRequest creates the Delete request. -func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -204,7 +201,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -213,7 +210,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Get private endpoint connections. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - privateEndpointConnectionName - The private endpoint connection name of Azure Managed Grafana. @@ -242,7 +239,7 @@ func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourc } // getCreateRequest creates the Get request. -func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -265,7 +262,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -282,7 +279,7 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res // NewListPager - Get private endpoint connection // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListPager @@ -311,7 +308,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s } // listCreateRequest creates the List request. -func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *PrivateEndpointConnectionsClientListOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *PrivateEndpointConnectionsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateEndpointConnections" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -330,7 +327,7 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dashboard/armdashboard/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/dashboard/armdashboard/privateendpointconnections_client_example_test.go deleted file mode 100644 index e9f0b1c60b03..000000000000 --- a/sdk/resourcemanager/dashboard/armdashboard/privateendpointconnections_client_example_test.go +++ /dev/null @@ -1,144 +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 armdashboard_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Get.json -func ExamplePrivateEndpointConnectionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "myResourceGroup", "myWorkspace", "myConnection", 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.PrivateEndpointConnection = armdashboard.PrivateEndpointConnection{ - // Name: to.Ptr("myConnection"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/privateEndpointConnections/myConnection"), - // Properties: &armdashboard.PrivateEndpointConnectionProperties{ - // GroupIDs: []*string{ - // to.Ptr("grafana")}, - // PrivateEndpoint: &armdashboard.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Network/privateEndpoint/myEndpoint"), - // }, - // PrivateLinkServiceConnectionState: &armdashboard.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("string"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armdashboard.PrivateEndpointServiceConnectionStatusPending), - // }, - // ProvisioningState: to.Ptr(armdashboard.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Approve.json -func ExamplePrivateEndpointConnectionsClient_BeginApprove() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginApprove(ctx, "myResourceGroup", "myWorkspace", "myConnection", armdashboard.PrivateEndpointConnection{}, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Delete.json -func ExamplePrivateEndpointConnectionsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginDelete(ctx, "myResourceGroup", "myWorkspace", "myConnection", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_List.json -func ExamplePrivateEndpointConnectionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListPager("myResourceGroup", "myWorkspace", 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.PrivateEndpointConnectionListResult = armdashboard.PrivateEndpointConnectionListResult{ - // Value: []*armdashboard.PrivateEndpointConnection{ - // { - // Name: to.Ptr("myConnection"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/privateEndpointConnections/myConnection"), - // Properties: &armdashboard.PrivateEndpointConnectionProperties{ - // GroupIDs: []*string{ - // to.Ptr("grafana")}, - // PrivateEndpoint: &armdashboard.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Network/privateEndpoint/myEndpoint"), - // }, - // PrivateLinkServiceConnectionState: &armdashboard.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("string"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armdashboard.PrivateEndpointServiceConnectionStatusPending), - // }, - // ProvisioningState: to.Ptr(armdashboard.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/dashboard/armdashboard/privatelinkresources_client.go b/sdk/resourcemanager/dashboard/armdashboard/privatelinkresources_client.go index 383fd8610b51..e762616f3feb 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/privatelinkresources_client.go +++ b/sdk/resourcemanager/dashboard/armdashboard/privatelinkresources_client.go @@ -1,6 +1,3 @@ -//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. @@ -46,7 +43,7 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // Get - Get specific private link resource information for this grafana resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get @@ -74,7 +71,7 @@ func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroup } // getCreateRequest creates the Get request. -func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateLinkResourceName string, options *PrivateLinkResourcesClientGetOptions) (*policy.Request, error) { +func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, privateLinkResourceName string, _ *PrivateLinkResourcesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources/{privateLinkResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -97,7 +94,7 @@ func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -114,7 +111,7 @@ func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) // NewListPager - List all private link resources information for this grafana resource // -// Generated from API version 2023-09-01 +// Generated from API version 2024-11-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workspaceName - The workspace name of Azure Managed Grafana. // - options - PrivateLinkResourcesClientListOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListPager @@ -143,7 +140,7 @@ func (client *PrivateLinkResourcesClient) NewListPager(resourceGroupName string, } // listCreateRequest creates the List request. -func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *PrivateLinkResourcesClientListOptions) (*policy.Request, error) { +func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, _ *PrivateLinkResourcesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}/privateLinkResources" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -162,7 +159,7 @@ func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-09-01") + reqQP.Set("api-version", "2024-11-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dashboard/armdashboard/privatelinkresources_client_example_test.go b/sdk/resourcemanager/dashboard/armdashboard/privatelinkresources_client_example_test.go deleted file mode 100644 index 523b90efd24b..000000000000 --- a/sdk/resourcemanager/dashboard/armdashboard/privatelinkresources_client_example_test.go +++ /dev/null @@ -1,90 +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 armdashboard_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dashboard/armdashboard" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateLinkResources_List.json -func ExamplePrivateLinkResourcesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPrivateLinkResourcesClient().NewListPager("myResourceGroup", "myWorkspace", 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.PrivateLinkResourceListResult = armdashboard.PrivateLinkResourceListResult{ - // Value: []*armdashboard.PrivateLinkResource{ - // { - // Name: to.Ptr("grafana"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/PrivateLinkResources"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/privateLinkResources/grafana"), - // Properties: &armdashboard.PrivateLinkResourceProperties{ - // GroupID: to.Ptr("grafana"), - // RequiredMembers: []*string{ - // to.Ptr("grafana")}, - // RequiredZoneNames: []*string{ - // to.Ptr("grafana-test.azure.com")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateLinkResources_Get.json -func ExamplePrivateLinkResourcesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdashboard.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateLinkResourcesClient().Get(ctx, "myResourceGroup", "myWorkspace", "grafana", 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.PrivateLinkResource = armdashboard.PrivateLinkResource{ - // Name: to.Ptr("grafana"), - // Type: to.Ptr("Microsoft.Dashboard/grafana/PrivateLinkResources"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/Microsoft.Dashboard/grafana/myWorkspace/privateLinkResources/grafana"), - // Properties: &armdashboard.PrivateLinkResourceProperties{ - // GroupID: to.Ptr("grafana"), - // RequiredMembers: []*string{ - // to.Ptr("grafana")}, - // RequiredZoneNames: []*string{ - // to.Ptr("grafana-test.azure.com")}, - // }, - // } -} diff --git a/sdk/resourcemanager/dashboard/armdashboard/response_types.go b/sdk/resourcemanager/dashboard/armdashboard/responses.go similarity index 69% rename from sdk/resourcemanager/dashboard/armdashboard/response_types.go rename to sdk/resourcemanager/dashboard/armdashboard/responses.go index fe95e5df4887..3f3b2d4e9de4 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/response_types.go +++ b/sdk/resourcemanager/dashboard/armdashboard/responses.go @@ -1,6 +1,3 @@ -//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. @@ -8,6 +5,22 @@ package armdashboard +// DashboardsClientGetResponse contains the response from method DashboardsClient.Get. +type DashboardsClientGetResponse struct { + // The managed dashboard resource type. + ManagedDashboard +} + +// DashboardsClientListBySubscriptionResponse contains the response from method DashboardsClient.NewListBySubscriptionPager. +type DashboardsClientListBySubscriptionResponse struct { + ManagedDashboardListResponse +} + +// DashboardsClientListResponse contains the response from method DashboardsClient.NewListPager. +type DashboardsClientListResponse struct { + ManagedDashboardListResponse +} + // GrafanaClientCheckEnterpriseDetailsResponse contains the response from method GrafanaClient.CheckEnterpriseDetails. type GrafanaClientCheckEnterpriseDetailsResponse struct { // Enterprise details of a Grafana instance @@ -55,6 +68,51 @@ type GrafanaClientUpdateResponse struct { AzureAsyncOperation *string } +// IntegrationFabricsClientCreateResponse contains the response from method IntegrationFabricsClient.BeginCreate. +type IntegrationFabricsClientCreateResponse struct { + // The integration fabric resource type. + IntegrationFabric +} + +// IntegrationFabricsClientDeleteResponse contains the response from method IntegrationFabricsClient.BeginDelete. +type IntegrationFabricsClientDeleteResponse struct { + // placeholder for future response values +} + +// IntegrationFabricsClientGetResponse contains the response from method IntegrationFabricsClient.Get. +type IntegrationFabricsClientGetResponse struct { + // The integration fabric resource type. + IntegrationFabric +} + +// IntegrationFabricsClientListResponse contains the response from method IntegrationFabricsClient.NewListPager. +type IntegrationFabricsClientListResponse struct { + IntegrationFabricListResponse +} + +// IntegrationFabricsClientUpdateResponse contains the response from method IntegrationFabricsClient.BeginUpdate. +type IntegrationFabricsClientUpdateResponse struct { + // The integration fabric resource type. + IntegrationFabric +} + +// ManagedDashboardsClientCreateResponse contains the response from method ManagedDashboardsClient.BeginCreate. +type ManagedDashboardsClientCreateResponse struct { + // The managed dashboard resource type. + ManagedDashboard +} + +// ManagedDashboardsClientDeleteResponse contains the response from method ManagedDashboardsClient.Delete. +type ManagedDashboardsClientDeleteResponse struct { + // placeholder for future response values +} + +// ManagedDashboardsClientUpdateResponse contains the response from method ManagedDashboardsClient.Update. +type ManagedDashboardsClientUpdateResponse struct { + // The managed dashboard resource type. + ManagedDashboard +} + // ManagedPrivateEndpointsClientCreateResponse contains the response from method ManagedPrivateEndpointsClient.BeginCreate. type ManagedPrivateEndpointsClientCreateResponse struct { // The managed private endpoint resource type. diff --git a/sdk/resourcemanager/dashboard/armdashboard/time_rfc3339.go b/sdk/resourcemanager/dashboard/armdashboard/time_rfc3339.go index 186c0b81648f..c06103cd11f6 100644 --- a/sdk/resourcemanager/dashboard/armdashboard/time_rfc3339.go +++ b/sdk/resourcemanager/dashboard/armdashboard/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. @@ -19,12 +16,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +41,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339