diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/CHANGELOG.md b/sdk/resourcemanager/hybridcompute/armhybridcompute/CHANGELOG.md index 07943bf92e93..e8a875343893 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/CHANGELOG.md +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 1.1.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/README.md b/sdk/resourcemanager/hybridcompute/armhybridcompute/README.md index 2544a800c07a..d897c66997fc 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/README.md +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewMachinesClient() ``` +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + ## Provide Feedback If you encounter bugs or have suggestions, please diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/autorest.md b/sdk/resourcemanager/hybridcompute/armhybridcompute/autorest.md index 2de0ae740f4e..06f39f908314 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/autorest.md +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hybridcompute/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hybridcompute/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.1 +module-version: 1.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/client_factory.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/client_factory.go index 9c1de7e1a4e2..85fe42876fc8 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/client_factory.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/client_factory.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -28,7 +27,7 @@ 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,37 +37,44 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } -func (c *ClientFactory) NewMachinesClient() *MachinesClient { - subClient, _ := NewMachinesClient(c.subscriptionID, c.credential, c.options) +// NewMachineExtensionsClient creates a new instance of MachineExtensionsClient. +func (c *ClientFactory) NewMachineExtensionsClient() *MachineExtensionsClient { + subClient, _ := NewMachineExtensionsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewMachineExtensionsClient() *MachineExtensionsClient { - subClient, _ := NewMachineExtensionsClient(c.subscriptionID, c.credential, c.options) +// NewMachinesClient creates a new instance of MachinesClient. +func (c *ClientFactory) NewMachinesClient() *MachinesClient { + subClient, _ := NewMachinesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewManagementClient creates a new instance of ManagementClient. func (c *ClientFactory) NewManagementClient() *ManagementClient { subClient, _ := NewManagementClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { subClient, _ := NewOperationsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewPrivateLinkScopesClient() *PrivateLinkScopesClient { - subClient, _ := NewPrivateLinkScopesClient(c.subscriptionID, c.credential, c.options) +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. +func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { + subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { - subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) +// NewPrivateLinkScopesClient creates a new instance of PrivateLinkScopesClient. +func (c *ClientFactory) NewPrivateLinkScopesClient() *PrivateLinkScopesClient { + subClient, _ := NewPrivateLinkScopesClient(c.subscriptionID, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/constants.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/constants.go index e405334a18ee..f0698f8fa027 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/constants.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/constants.go @@ -3,15 +3,14 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute const ( - moduleName = "armhybridcompute" - moduleVersion = "v1.1.1" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridcompute/armhybridcompute" + moduleVersion = "v1.2.0" ) // AssessmentModeTypes - Specifies the assessment mode. diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/internal.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/internal.go new file mode 100644 index 000000000000..94e060e89dbd --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/internal.go @@ -0,0 +1,72 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/machineextensions_server.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/machineextensions_server.go new file mode 100644 index 000000000000..a2e80b0d2955 --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/machineextensions_server.go @@ -0,0 +1,344 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. 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/hybridcompute/armhybridcompute" + "net/http" + "net/url" + "regexp" +) + +// MachineExtensionsServer is a fake server for instances of the armhybridcompute.MachineExtensionsClient type. +type MachineExtensionsServer struct { + // BeginCreateOrUpdate is the fake for method MachineExtensionsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, machineName string, extensionName string, extensionParameters armhybridcompute.MachineExtension, options *armhybridcompute.MachineExtensionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armhybridcompute.MachineExtensionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method MachineExtensionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, machineName string, extensionName string, options *armhybridcompute.MachineExtensionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armhybridcompute.MachineExtensionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method MachineExtensionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, machineName string, extensionName string, options *armhybridcompute.MachineExtensionsClientGetOptions) (resp azfake.Responder[armhybridcompute.MachineExtensionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method MachineExtensionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, machineName string, options *armhybridcompute.MachineExtensionsClientListOptions) (resp azfake.PagerResponder[armhybridcompute.MachineExtensionsClientListResponse]) + + // BeginUpdate is the fake for method MachineExtensionsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, machineName string, extensionName string, extensionParameters armhybridcompute.MachineExtensionUpdate, options *armhybridcompute.MachineExtensionsClientBeginUpdateOptions) (resp azfake.PollerResponder[armhybridcompute.MachineExtensionsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewMachineExtensionsServerTransport creates a new instance of MachineExtensionsServerTransport with the provided implementation. +// The returned MachineExtensionsServerTransport instance is connected to an instance of armhybridcompute.MachineExtensionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMachineExtensionsServerTransport(srv *MachineExtensionsServer) *MachineExtensionsServerTransport { + return &MachineExtensionsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armhybridcompute.MachineExtensionsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armhybridcompute.MachineExtensionsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armhybridcompute.MachineExtensionsClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armhybridcompute.MachineExtensionsClientUpdateResponse]](), + } +} + +// MachineExtensionsServerTransport connects instances of armhybridcompute.MachineExtensionsClient to instances of MachineExtensionsServer. +// Don't use this type directly, use NewMachineExtensionsServerTransport instead. +type MachineExtensionsServerTransport struct { + srv *MachineExtensionsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armhybridcompute.MachineExtensionsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armhybridcompute.MachineExtensionsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armhybridcompute.MachineExtensionsClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armhybridcompute.MachineExtensionsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for MachineExtensionsServerTransport. +func (m *MachineExtensionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "MachineExtensionsClient.BeginCreateOrUpdate": + resp, err = m.dispatchBeginCreateOrUpdate(req) + case "MachineExtensionsClient.BeginDelete": + resp, err = m.dispatchBeginDelete(req) + case "MachineExtensionsClient.Get": + resp, err = m.dispatchGet(req) + case "MachineExtensionsClient.NewListPager": + resp, err = m.dispatchNewListPager(req) + case "MachineExtensionsClient.BeginUpdate": + resp, err = m.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MachineExtensionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if m.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := m.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?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[armhybridcompute.MachineExtension](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, machineNameParam, extensionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + m.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + m.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + m.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (m *MachineExtensionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if m.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := m.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?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 + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginDelete(req.Context(), resourceGroupNameParam, machineNameParam, extensionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + m.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + m.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + m.beginDelete.remove(req) + } + + return resp, nil +} + +func (m *MachineExtensionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?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 + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, machineNameParam, extensionNameParam, 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).MachineExtension, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *MachineExtensionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := m.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armhybridcompute.MachineExtensionsClientListOptions + if expandParam != nil { + options = &armhybridcompute.MachineExtensionsClientListOptions{ + Expand: expandParam, + } + } + resp := m.srv.NewListPager(resourceGroupNameParam, machineNameParam, options) + newListPager = &resp + m.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armhybridcompute.MachineExtensionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + m.newListPager.remove(req) + } + return resp, nil +} + +func (m *MachineExtensionsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if m.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := m.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?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[armhybridcompute.MachineExtensionUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginUpdate(req.Context(), resourceGroupNameParam, machineNameParam, extensionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + m.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) { + m.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) { + m.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/machines_server.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/machines_server.go new file mode 100644 index 000000000000..8046c7bee22a --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/machines_server.go @@ -0,0 +1,326 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridcompute/armhybridcompute" + "net/http" + "net/url" + "regexp" +) + +// MachinesServer is a fake server for instances of the armhybridcompute.MachinesClient type. +type MachinesServer struct { + // CreateOrUpdate is the fake for method MachinesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, machineName string, parameters armhybridcompute.Machine, options *armhybridcompute.MachinesClientCreateOrUpdateOptions) (resp azfake.Responder[armhybridcompute.MachinesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method MachinesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, machineName string, options *armhybridcompute.MachinesClientDeleteOptions) (resp azfake.Responder[armhybridcompute.MachinesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method MachinesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, machineName string, options *armhybridcompute.MachinesClientGetOptions) (resp azfake.Responder[armhybridcompute.MachinesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method MachinesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armhybridcompute.MachinesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armhybridcompute.MachinesClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method MachinesClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armhybridcompute.MachinesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armhybridcompute.MachinesClientListBySubscriptionResponse]) + + // Update is the fake for method MachinesClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, machineName string, parameters armhybridcompute.MachineUpdate, options *armhybridcompute.MachinesClientUpdateOptions) (resp azfake.Responder[armhybridcompute.MachinesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewMachinesServerTransport creates a new instance of MachinesServerTransport with the provided implementation. +// The returned MachinesServerTransport instance is connected to an instance of armhybridcompute.MachinesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMachinesServerTransport(srv *MachinesServer) *MachinesServerTransport { + return &MachinesServerTransport{ + srv: srv, + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armhybridcompute.MachinesClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armhybridcompute.MachinesClientListBySubscriptionResponse]](), + } +} + +// MachinesServerTransport connects instances of armhybridcompute.MachinesClient to instances of MachinesServer. +// Don't use this type directly, use NewMachinesServerTransport instead. +type MachinesServerTransport struct { + srv *MachinesServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armhybridcompute.MachinesClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armhybridcompute.MachinesClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for MachinesServerTransport. +func (m *MachinesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "MachinesClient.CreateOrUpdate": + resp, err = m.dispatchCreateOrUpdate(req) + case "MachinesClient.Delete": + resp, err = m.dispatchDelete(req) + case "MachinesClient.Get": + resp, err = m.dispatchGet(req) + case "MachinesClient.NewListByResourceGroupPager": + resp, err = m.dispatchNewListByResourceGroupPager(req) + case "MachinesClient.NewListBySubscriptionPager": + resp, err = m.dispatchNewListBySubscriptionPager(req) + case "MachinesClient.Update": + resp, err = m.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MachinesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if m.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?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[armhybridcompute.Machine](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, machineNameParam, 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).Machine, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *MachinesServerTransport) 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\.HybridCompute/machines/(?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 + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Delete(req.Context(), resourceGroupNameParam, machineNameParam, 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 *MachinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(armhybridcompute.InstanceViewTypes(expandUnescaped)) + var options *armhybridcompute.MachinesClientGetOptions + if expandParam != nil { + options = &armhybridcompute.MachinesClientGetOptions{ + Expand: expandParam, + } + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, machineNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Machine, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *MachinesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := m.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + m.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armhybridcompute.MachinesClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + m.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (m *MachinesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := m.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := m.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + m.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armhybridcompute.MachinesClientListBySubscriptionResponse, 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) { + m.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + m.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (m *MachinesServerTransport) 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\.HybridCompute/machines/(?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[armhybridcompute.MachineUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Update(req.Context(), resourceGroupNameParam, machineNameParam, 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).Machine, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/management_server.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/management_server.go new file mode 100644 index 000000000000..54b55beea979 --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/management_server.go @@ -0,0 +1,119 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridcompute/armhybridcompute" + "net/http" + "net/url" + "regexp" +) + +// ManagementServer is a fake server for instances of the armhybridcompute.ManagementClient type. +type ManagementServer struct { + // BeginUpgradeExtensions is the fake for method ManagementClient.BeginUpgradeExtensions + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpgradeExtensions func(ctx context.Context, resourceGroupName string, machineName string, extensionUpgradeParameters armhybridcompute.MachineExtensionUpgrade, options *armhybridcompute.ManagementClientBeginUpgradeExtensionsOptions) (resp azfake.PollerResponder[armhybridcompute.ManagementClientUpgradeExtensionsResponse], errResp azfake.ErrorResponder) +} + +// NewManagementServerTransport creates a new instance of ManagementServerTransport with the provided implementation. +// The returned ManagementServerTransport instance is connected to an instance of armhybridcompute.ManagementClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewManagementServerTransport(srv *ManagementServer) *ManagementServerTransport { + return &ManagementServerTransport{ + srv: srv, + beginUpgradeExtensions: newTracker[azfake.PollerResponder[armhybridcompute.ManagementClientUpgradeExtensionsResponse]](), + } +} + +// ManagementServerTransport connects instances of armhybridcompute.ManagementClient to instances of ManagementServer. +// Don't use this type directly, use NewManagementServerTransport instead. +type ManagementServerTransport struct { + srv *ManagementServer + beginUpgradeExtensions *tracker[azfake.PollerResponder[armhybridcompute.ManagementClientUpgradeExtensionsResponse]] +} + +// Do implements the policy.Transporter interface for ManagementServerTransport. +func (m *ManagementServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ManagementClient.BeginUpgradeExtensions": + resp, err = m.dispatchBeginUpgradeExtensions(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ManagementServerTransport) dispatchBeginUpgradeExtensions(req *http.Request) (*http.Response, error) { + if m.srv.BeginUpgradeExtensions == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpgradeExtensions not implemented")} + } + beginUpgradeExtensions := m.beginUpgradeExtensions.get(req) + if beginUpgradeExtensions == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/upgradeExtensions` + 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[armhybridcompute.MachineExtensionUpgrade](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginUpgradeExtensions(req.Context(), resourceGroupNameParam, machineNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpgradeExtensions = &respr + m.beginUpgradeExtensions.add(req, beginUpgradeExtensions) + } + + resp, err := server.PollerResponderNext(beginUpgradeExtensions, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + m.beginUpgradeExtensions.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpgradeExtensions) { + m.beginUpgradeExtensions.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/operations_server.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/operations_server.go new file mode 100644 index 000000000000..aaf6721dab08 --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/operations_server.go @@ -0,0 +1,92 @@ +//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 ( + "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/hybridcompute/armhybridcompute" + "net/http" +) + +// OperationsServer is a fake server for instances of the armhybridcompute.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armhybridcompute.OperationsClientListOptions) (resp azfake.PagerResponder[armhybridcompute.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armhybridcompute.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armhybridcompute.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armhybridcompute.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armhybridcompute.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privateendpointconnections_server.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privateendpointconnections_server.go new file mode 100644 index 000000000000..1b9003976475 --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privateendpointconnections_server.go @@ -0,0 +1,272 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridcompute/armhybridcompute" + "net/http" + "net/url" + "regexp" +) + +// PrivateEndpointConnectionsServer is a fake server for instances of the armhybridcompute.PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsServer struct { + // BeginCreateOrUpdate is the fake for method PrivateEndpointConnectionsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters armhybridcompute.PrivateEndpointConnection, options *armhybridcompute.PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armhybridcompute.PrivateEndpointConnectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method PrivateEndpointConnectionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *armhybridcompute.PrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armhybridcompute.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PrivateEndpointConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *armhybridcompute.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armhybridcompute.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByPrivateLinkScopePager is the fake for method PrivateEndpointConnectionsClient.NewListByPrivateLinkScopePager + // HTTP status codes to indicate success: http.StatusOK + NewListByPrivateLinkScopePager func(resourceGroupName string, scopeName string, options *armhybridcompute.PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions) (resp azfake.PagerResponder[armhybridcompute.PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse]) +} + +// NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. +// The returned PrivateEndpointConnectionsServerTransport instance is connected to an instance of armhybridcompute.PrivateEndpointConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { + return &PrivateEndpointConnectionsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armhybridcompute.PrivateEndpointConnectionsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armhybridcompute.PrivateEndpointConnectionsClientDeleteResponse]](), + newListByPrivateLinkScopePager: newTracker[azfake.PagerResponder[armhybridcompute.PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse]](), + } +} + +// PrivateEndpointConnectionsServerTransport connects instances of armhybridcompute.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. +// Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. +type PrivateEndpointConnectionsServerTransport struct { + srv *PrivateEndpointConnectionsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armhybridcompute.PrivateEndpointConnectionsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armhybridcompute.PrivateEndpointConnectionsClientDeleteResponse]] + newListByPrivateLinkScopePager *tracker[azfake.PagerResponder[armhybridcompute.PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse]] +} + +// Do implements the policy.Transporter interface for PrivateEndpointConnectionsServerTransport. +func (p *PrivateEndpointConnectionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "PrivateEndpointConnectionsClient.BeginCreateOrUpdate": + resp, err = p.dispatchBeginCreateOrUpdate(req) + case "PrivateEndpointConnectionsClient.BeginDelete": + resp, err = p.dispatchBeginDelete(req) + case "PrivateEndpointConnectionsClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.NewListByPrivateLinkScopePager": + resp, err = p.dispatchNewListByPrivateLinkScopePager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := p.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?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[armhybridcompute.PrivateEndpointConnection](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, scopeNameParam, privateEndpointConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + p.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + p.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := p.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?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 + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, scopeNameParam, privateEndpointConnectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + p.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) { + p.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) { + p.beginDelete.remove(req) + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.HybridCompute/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?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 + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, scopeNameParam, privateEndpointConnectionNameParam, 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).PrivateEndpointConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListByPrivateLinkScopePager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByPrivateLinkScopePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByPrivateLinkScopePager not implemented")} + } + newListByPrivateLinkScopePager := p.newListByPrivateLinkScopePager.get(req) + if newListByPrivateLinkScopePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` + 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 + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByPrivateLinkScopePager(resourceGroupNameParam, scopeNameParam, nil) + newListByPrivateLinkScopePager = &resp + p.newListByPrivateLinkScopePager.add(req, newListByPrivateLinkScopePager) + server.PagerResponderInjectNextLinks(newListByPrivateLinkScopePager, req, func(page *armhybridcompute.PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByPrivateLinkScopePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByPrivateLinkScopePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByPrivateLinkScopePager) { + p.newListByPrivateLinkScopePager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privatelinkresources_server.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privatelinkresources_server.go new file mode 100644 index 000000000000..dffac77b7bfa --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privatelinkresources_server.go @@ -0,0 +1,156 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridcompute/armhybridcompute" + "net/http" + "net/url" + "regexp" +) + +// PrivateLinkResourcesServer is a fake server for instances of the armhybridcompute.PrivateLinkResourcesClient type. +type PrivateLinkResourcesServer struct { + // Get is the fake for method PrivateLinkResourcesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, scopeName string, groupName string, options *armhybridcompute.PrivateLinkResourcesClientGetOptions) (resp azfake.Responder[armhybridcompute.PrivateLinkResourcesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByPrivateLinkScopePager is the fake for method PrivateLinkResourcesClient.NewListByPrivateLinkScopePager + // HTTP status codes to indicate success: http.StatusOK + NewListByPrivateLinkScopePager func(resourceGroupName string, scopeName string, options *armhybridcompute.PrivateLinkResourcesClientListByPrivateLinkScopeOptions) (resp azfake.PagerResponder[armhybridcompute.PrivateLinkResourcesClientListByPrivateLinkScopeResponse]) +} + +// NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. +// The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armhybridcompute.PrivateLinkResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { + return &PrivateLinkResourcesServerTransport{ + srv: srv, + newListByPrivateLinkScopePager: newTracker[azfake.PagerResponder[armhybridcompute.PrivateLinkResourcesClientListByPrivateLinkScopeResponse]](), + } +} + +// PrivateLinkResourcesServerTransport connects instances of armhybridcompute.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. +// Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. +type PrivateLinkResourcesServerTransport struct { + srv *PrivateLinkResourcesServer + newListByPrivateLinkScopePager *tracker[azfake.PagerResponder[armhybridcompute.PrivateLinkResourcesClientListByPrivateLinkScopeResponse]] +} + +// Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. +func (p *PrivateLinkResourcesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "PrivateLinkResourcesClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateLinkResourcesClient.NewListByPrivateLinkScopePager": + resp, err = p.dispatchNewListByPrivateLinkScopePager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.HybridCompute/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources/(?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 + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + groupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, scopeNameParam, groupNameParam, 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).PrivateLinkResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchNewListByPrivateLinkScopePager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByPrivateLinkScopePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByPrivateLinkScopePager not implemented")} + } + newListByPrivateLinkScopePager := p.newListByPrivateLinkScopePager.get(req) + if newListByPrivateLinkScopePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + 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 + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByPrivateLinkScopePager(resourceGroupNameParam, scopeNameParam, nil) + newListByPrivateLinkScopePager = &resp + p.newListByPrivateLinkScopePager.add(req, newListByPrivateLinkScopePager) + server.PagerResponderInjectNextLinks(newListByPrivateLinkScopePager, req, func(page *armhybridcompute.PrivateLinkResourcesClientListByPrivateLinkScopeResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByPrivateLinkScopePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByPrivateLinkScopePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByPrivateLinkScopePager) { + p.newListByPrivateLinkScopePager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privatelinkscopes_server.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privatelinkscopes_server.go new file mode 100644 index 000000000000..feb4b7f3d6aa --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/privatelinkscopes_server.go @@ -0,0 +1,405 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridcompute/armhybridcompute" + "net/http" + "net/url" + "regexp" +) + +// PrivateLinkScopesServer is a fake server for instances of the armhybridcompute.PrivateLinkScopesClient type. +type PrivateLinkScopesServer struct { + // CreateOrUpdate is the fake for method PrivateLinkScopesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, scopeName string, parameters armhybridcompute.PrivateLinkScope, options *armhybridcompute.PrivateLinkScopesClientCreateOrUpdateOptions) (resp azfake.Responder[armhybridcompute.PrivateLinkScopesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method PrivateLinkScopesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, scopeName string, options *armhybridcompute.PrivateLinkScopesClientBeginDeleteOptions) (resp azfake.PollerResponder[armhybridcompute.PrivateLinkScopesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PrivateLinkScopesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, scopeName string, options *armhybridcompute.PrivateLinkScopesClientGetOptions) (resp azfake.Responder[armhybridcompute.PrivateLinkScopesClientGetResponse], errResp azfake.ErrorResponder) + + // GetValidationDetails is the fake for method PrivateLinkScopesClient.GetValidationDetails + // HTTP status codes to indicate success: http.StatusOK + GetValidationDetails func(ctx context.Context, location string, privateLinkScopeID string, options *armhybridcompute.PrivateLinkScopesClientGetValidationDetailsOptions) (resp azfake.Responder[armhybridcompute.PrivateLinkScopesClientGetValidationDetailsResponse], errResp azfake.ErrorResponder) + + // GetValidationDetailsForMachine is the fake for method PrivateLinkScopesClient.GetValidationDetailsForMachine + // HTTP status codes to indicate success: http.StatusOK + GetValidationDetailsForMachine func(ctx context.Context, resourceGroupName string, machineName string, options *armhybridcompute.PrivateLinkScopesClientGetValidationDetailsForMachineOptions) (resp azfake.Responder[armhybridcompute.PrivateLinkScopesClientGetValidationDetailsForMachineResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method PrivateLinkScopesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armhybridcompute.PrivateLinkScopesClientListOptions) (resp azfake.PagerResponder[armhybridcompute.PrivateLinkScopesClientListResponse]) + + // NewListByResourceGroupPager is the fake for method PrivateLinkScopesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armhybridcompute.PrivateLinkScopesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armhybridcompute.PrivateLinkScopesClientListByResourceGroupResponse]) + + // UpdateTags is the fake for method PrivateLinkScopesClient.UpdateTags + // HTTP status codes to indicate success: http.StatusOK + UpdateTags func(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags armhybridcompute.TagsResource, options *armhybridcompute.PrivateLinkScopesClientUpdateTagsOptions) (resp azfake.Responder[armhybridcompute.PrivateLinkScopesClientUpdateTagsResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateLinkScopesServerTransport creates a new instance of PrivateLinkScopesServerTransport with the provided implementation. +// The returned PrivateLinkScopesServerTransport instance is connected to an instance of armhybridcompute.PrivateLinkScopesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateLinkScopesServerTransport(srv *PrivateLinkScopesServer) *PrivateLinkScopesServerTransport { + return &PrivateLinkScopesServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armhybridcompute.PrivateLinkScopesClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armhybridcompute.PrivateLinkScopesClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armhybridcompute.PrivateLinkScopesClientListByResourceGroupResponse]](), + } +} + +// PrivateLinkScopesServerTransport connects instances of armhybridcompute.PrivateLinkScopesClient to instances of PrivateLinkScopesServer. +// Don't use this type directly, use NewPrivateLinkScopesServerTransport instead. +type PrivateLinkScopesServerTransport struct { + srv *PrivateLinkScopesServer + beginDelete *tracker[azfake.PollerResponder[armhybridcompute.PrivateLinkScopesClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armhybridcompute.PrivateLinkScopesClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armhybridcompute.PrivateLinkScopesClientListByResourceGroupResponse]] +} + +// Do implements the policy.Transporter interface for PrivateLinkScopesServerTransport. +func (p *PrivateLinkScopesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "PrivateLinkScopesClient.CreateOrUpdate": + resp, err = p.dispatchCreateOrUpdate(req) + case "PrivateLinkScopesClient.BeginDelete": + resp, err = p.dispatchBeginDelete(req) + case "PrivateLinkScopesClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateLinkScopesClient.GetValidationDetails": + resp, err = p.dispatchGetValidationDetails(req) + case "PrivateLinkScopesClient.GetValidationDetailsForMachine": + resp, err = p.dispatchGetValidationDetailsForMachine(req) + case "PrivateLinkScopesClient.NewListPager": + resp, err = p.dispatchNewListPager(req) + case "PrivateLinkScopesClient.NewListByResourceGroupPager": + resp, err = p.dispatchNewListByResourceGroupPager(req) + case "PrivateLinkScopesClient.UpdateTags": + resp, err = p.dispatchUpdateTags(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateLinkScopesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes/(?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[armhybridcompute.PrivateLinkScope](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, scopeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrivateLinkScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateLinkScopesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := p.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes/(?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 + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, scopeNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + p.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) { + p.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) { + p.beginDelete.remove(req) + } + + return resp, nil +} + +func (p *PrivateLinkScopesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.HybridCompute/privateLinkScopes/(?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 + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, scopeNameParam, 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).PrivateLinkScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateLinkScopesServerTransport) dispatchGetValidationDetails(req *http.Request) (*http.Response, error) { + if p.srv.GetValidationDetails == nil { + return nil, &nonRetriableError{errors.New("fake for method GetValidationDetails not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkScopes/(?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) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + privateLinkScopeIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateLinkScopeId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetValidationDetails(req.Context(), locationParam, privateLinkScopeIDParam, 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).PrivateLinkScopeValidationDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateLinkScopesServerTransport) dispatchGetValidationDetailsForMachine(req *http.Request) (*http.Response, error) { + if p.srv.GetValidationDetailsForMachine == nil { + return nil, &nonRetriableError{errors.New("fake for method GetValidationDetailsForMachine not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/machines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkScopes/current` + 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 + } + machineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("machineName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetValidationDetailsForMachine(req.Context(), resourceGroupNameParam, machineNameParam, 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).PrivateLinkScopeValidationDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateLinkScopesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := p.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes` + 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 := p.srv.NewListPager(nil) + newListPager = &resp + p.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armhybridcompute.PrivateLinkScopesClientListResponse, 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) { + p.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + p.newListPager.remove(req) + } + return resp, nil +} + +func (p *PrivateLinkScopesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := p.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes` + 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 := p.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + p.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armhybridcompute.PrivateLinkScopesClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + p.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (p *PrivateLinkScopesServerTransport) dispatchUpdateTags(req *http.Request) (*http.Response, error) { + if p.srv.UpdateTags == nil { + return nil, &nonRetriableError{errors.New("fake for method UpdateTags not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.HybridCompute/privateLinkScopes/(?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[armhybridcompute.TagsResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.UpdateTags(req.Context(), resourceGroupNameParam, scopeNameParam, 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).PrivateLinkScope, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/server_factory.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/server_factory.go new file mode 100644 index 000000000000..10b57131d0e6 --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/server_factory.go @@ -0,0 +1,113 @@ +//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 ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armhybridcompute.ClientFactory type. +type ServerFactory struct { + MachineExtensionsServer MachineExtensionsServer + MachinesServer MachinesServer + ManagementServer ManagementServer + OperationsServer OperationsServer + PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer + PrivateLinkResourcesServer PrivateLinkResourcesServer + PrivateLinkScopesServer PrivateLinkScopesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armhybridcompute.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armhybridcompute.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trMachineExtensionsServer *MachineExtensionsServerTransport + trMachinesServer *MachinesServerTransport + trManagementServer *ManagementServerTransport + trOperationsServer *OperationsServerTransport + trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport + trPrivateLinkScopesServer *PrivateLinkScopesServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "MachineExtensionsClient": + initServer(s, &s.trMachineExtensionsServer, func() *MachineExtensionsServerTransport { + return NewMachineExtensionsServerTransport(&s.srv.MachineExtensionsServer) + }) + resp, err = s.trMachineExtensionsServer.Do(req) + case "MachinesClient": + initServer(s, &s.trMachinesServer, func() *MachinesServerTransport { return NewMachinesServerTransport(&s.srv.MachinesServer) }) + resp, err = s.trMachinesServer.Do(req) + case "ManagementClient": + initServer(s, &s.trManagementServer, func() *ManagementServerTransport { return NewManagementServerTransport(&s.srv.ManagementServer) }) + resp, err = s.trManagementServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "PrivateEndpointConnectionsClient": + initServer(s, &s.trPrivateEndpointConnectionsServer, func() *PrivateEndpointConnectionsServerTransport { + return NewPrivateEndpointConnectionsServerTransport(&s.srv.PrivateEndpointConnectionsServer) + }) + resp, err = s.trPrivateEndpointConnectionsServer.Do(req) + case "PrivateLinkResourcesClient": + initServer(s, &s.trPrivateLinkResourcesServer, func() *PrivateLinkResourcesServerTransport { + return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) + }) + resp, err = s.trPrivateLinkResourcesServer.Do(req) + case "PrivateLinkScopesClient": + initServer(s, &s.trPrivateLinkScopesServer, func() *PrivateLinkScopesServerTransport { + return NewPrivateLinkScopesServerTransport(&s.srv.PrivateLinkScopesServer) + }) + resp, err = s.trPrivateLinkScopesServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/time_rfc3339.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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/hybridcompute/armhybridcompute/go.mod b/sdk/resourcemanager/hybridcompute/armhybridcompute/go.mod index 2d0c7d6192b1..130388b013da 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/go.mod +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridcompute/armhy go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/go.sum b/sdk/resourcemanager/hybridcompute/armhybridcompute/go.sum index 8ba445a8c4da..7985f1da436f 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/go.sum +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/go.sum @@ -1,31 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/machineextensions_client.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/machineextensions_client.go index e1b16675f4e4..8c9ed4140f82 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/machineextensions_client.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/machineextensions_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -33,7 +32,7 @@ type MachineExtensionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMachineExtensionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MachineExtensionsClient, error) { - cl, err := arm.NewClient(moduleName+".MachineExtensionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -60,9 +59,14 @@ func (client *MachineExtensionsClient) BeginCreateOrUpdate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[MachineExtensionsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MachineExtensionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MachineExtensionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MachineExtensionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -71,18 +75,24 @@ func (client *MachineExtensionsClient) BeginCreateOrUpdate(ctx context.Context, // // Generated from API version 2022-03-10 func (client *MachineExtensionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, machineName string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "MachineExtensionsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, machineName, extensionName, extensionParameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -112,7 +122,10 @@ func (client *MachineExtensionsClient) createOrUpdateCreateRequest(ctx context.C reqQP.Set("api-version", "2022-03-10") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, extensionParameters) + if err := runtime.MarshalAsJSON(req, extensionParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - The operation to delete the extension. @@ -130,9 +143,14 @@ func (client *MachineExtensionsClient) BeginDelete(ctx context.Context, resource if err != nil { return nil, err } - return runtime.NewPoller[MachineExtensionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MachineExtensionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MachineExtensionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MachineExtensionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -141,18 +159,24 @@ func (client *MachineExtensionsClient) BeginDelete(ctx context.Context, resource // // Generated from API version 2022-03-10 func (client *MachineExtensionsClient) deleteOperation(ctx context.Context, resourceGroupName string, machineName string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "MachineExtensionsClient.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, machineName, extensionName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -194,18 +218,25 @@ func (client *MachineExtensionsClient) deleteCreateRequest(ctx context.Context, // - extensionName - The name of the machine extension. // - options - MachineExtensionsClientGetOptions contains the optional parameters for the MachineExtensionsClient.Get method. func (client *MachineExtensionsClient) Get(ctx context.Context, resourceGroupName string, machineName string, extensionName string, options *MachineExtensionsClientGetOptions) (MachineExtensionsClientGetResponse, error) { + var err error + const operationName = "MachineExtensionsClient.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, machineName, extensionName, options) if err != nil { return MachineExtensionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MachineExtensionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MachineExtensionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MachineExtensionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -260,25 +291,20 @@ func (client *MachineExtensionsClient) NewListPager(resourceGroupName string, ma return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MachineExtensionsClientListResponse) (MachineExtensionsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, machineName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return MachineExtensionsClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MachineExtensionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, machineName, options) + }, nil) if err != nil { return MachineExtensionsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MachineExtensionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -336,9 +362,14 @@ func (client *MachineExtensionsClient) BeginUpdate(ctx context.Context, resource if err != nil { return nil, err } - return runtime.NewPoller[MachineExtensionsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MachineExtensionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MachineExtensionsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MachineExtensionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -347,18 +378,24 @@ func (client *MachineExtensionsClient) BeginUpdate(ctx context.Context, resource // // Generated from API version 2022-03-10 func (client *MachineExtensionsClient) update(ctx context.Context, resourceGroupName string, machineName string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "MachineExtensionsClient.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, machineName, extensionName, extensionParameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -388,5 +425,8 @@ func (client *MachineExtensionsClient) updateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-03-10") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, extensionParameters) + if err := runtime.MarshalAsJSON(req, extensionParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/machines_client.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/machines_client.go index da87fe95a307..a8d6be342902 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/machines_client.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/machines_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -33,7 +32,7 @@ type MachinesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MachinesClient, error) { - cl, err := arm.NewClient(moduleName+".MachinesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -53,18 +52,25 @@ func NewMachinesClient(subscriptionID string, credential azcore.TokenCredential, // - parameters - Parameters supplied to the Create hybrid machine operation. // - options - MachinesClientCreateOrUpdateOptions contains the optional parameters for the MachinesClient.CreateOrUpdate method. func (client *MachinesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, machineName string, parameters Machine, options *MachinesClientCreateOrUpdateOptions) (MachinesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "MachinesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, machineName, parameters, options) if err != nil { return MachinesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MachinesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MachinesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MachinesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -90,7 +96,10 @@ func (client *MachinesClient) createOrUpdateCreateRequest(ctx context.Context, r reqQP.Set("api-version", "2022-03-10") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -110,16 +119,22 @@ func (client *MachinesClient) createOrUpdateHandleResponse(resp *http.Response) // - machineName - The name of the hybrid machine. // - options - MachinesClientDeleteOptions contains the optional parameters for the MachinesClient.Delete method. func (client *MachinesClient) Delete(ctx context.Context, resourceGroupName string, machineName string, options *MachinesClientDeleteOptions) (MachinesClientDeleteResponse, error) { + var err error + const operationName = "MachinesClient.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, machineName, options) if err != nil { return MachinesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MachinesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return MachinesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return MachinesClientDeleteResponse{}, err } return MachinesClientDeleteResponse{}, nil } @@ -158,18 +173,25 @@ func (client *MachinesClient) deleteCreateRequest(ctx context.Context, resourceG // - machineName - The name of the hybrid machine. // - options - MachinesClientGetOptions contains the optional parameters for the MachinesClient.Get method. func (client *MachinesClient) Get(ctx context.Context, resourceGroupName string, machineName string, options *MachinesClientGetOptions) (MachinesClientGetResponse, error) { + var err error + const operationName = "MachinesClient.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, machineName, options) if err != nil { return MachinesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MachinesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MachinesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MachinesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -223,25 +245,20 @@ func (client *MachinesClient) NewListByResourceGroupPager(resourceGroupName stri return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MachinesClientListByResourceGroupResponse) (MachinesClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return MachinesClientListByResourceGroupResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MachinesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) if err != nil { return MachinesClientListByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MachinesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -288,25 +305,20 @@ func (client *MachinesClient) NewListBySubscriptionPager(options *MachinesClient return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MachinesClientListBySubscriptionResponse) (MachinesClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MachinesClient.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 MachinesClientListBySubscriptionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MachinesClientListBySubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MachinesClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -346,18 +358,25 @@ func (client *MachinesClient) listBySubscriptionHandleResponse(resp *http.Respon // - parameters - Parameters supplied to the Update hybrid machine operation. // - options - MachinesClientUpdateOptions contains the optional parameters for the MachinesClient.Update method. func (client *MachinesClient) Update(ctx context.Context, resourceGroupName string, machineName string, parameters MachineUpdate, options *MachinesClientUpdateOptions) (MachinesClientUpdateResponse, error) { + var err error + const operationName = "MachinesClient.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, machineName, parameters, options) if err != nil { return MachinesClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MachinesClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MachinesClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MachinesClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -383,7 +402,10 @@ func (client *MachinesClient) updateCreateRequest(ctx context.Context, resourceG reqQP.Set("api-version", "2022-03-10") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/management_client.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/management_client.go index 304730e40838..c629ed0a598b 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/management_client.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/management_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -33,7 +32,7 @@ type ManagementClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewManagementClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagementClient, error) { - cl, err := arm.NewClient(moduleName+".ManagementClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -59,9 +58,14 @@ func (client *ManagementClient) BeginUpgradeExtensions(ctx context.Context, reso if err != nil { return nil, err } - return runtime.NewPoller[ManagementClientUpgradeExtensionsResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagementClientUpgradeExtensionsResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[ManagementClientUpgradeExtensionsResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagementClientUpgradeExtensionsResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -70,18 +74,24 @@ func (client *ManagementClient) BeginUpgradeExtensions(ctx context.Context, reso // // Generated from API version 2022-03-10 func (client *ManagementClient) upgradeExtensions(ctx context.Context, resourceGroupName string, machineName string, extensionUpgradeParameters MachineExtensionUpgrade, options *ManagementClientBeginUpgradeExtensionsOptions) (*http.Response, error) { + var err error + const operationName = "ManagementClient.BeginUpgradeExtensions" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.upgradeExtensionsCreateRequest(ctx, resourceGroupName, machineName, extensionUpgradeParameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // upgradeExtensionsCreateRequest creates the UpgradeExtensions request. @@ -107,5 +117,8 @@ func (client *ManagementClient) upgradeExtensionsCreateRequest(ctx context.Conte reqQP.Set("api-version", "2022-03-10") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, extensionUpgradeParameters) + if err := runtime.MarshalAsJSON(req, extensionUpgradeParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/models.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/models.go index d5e55cb5dd94..94e88cd52ef5 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/models.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/models.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -295,38 +294,6 @@ type MachineExtensionUpgrade struct { ExtensionTargets map[string]*ExtensionTargetProperties } -// MachineExtensionsClientBeginCreateOrUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginCreateOrUpdate -// method. -type MachineExtensionsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MachineExtensionsClientBeginDeleteOptions contains the optional parameters for the MachineExtensionsClient.BeginDelete -// method. -type MachineExtensionsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MachineExtensionsClientBeginUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginUpdate -// method. -type MachineExtensionsClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MachineExtensionsClientGetOptions contains the optional parameters for the MachineExtensionsClient.Get method. -type MachineExtensionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.NewListPager method. -type MachineExtensionsClientListOptions struct { - // The expand expression to apply on the operation. - Expand *string -} - // MachineExtensionsListResult - Describes the Machine Extensions List Result. type MachineExtensionsListResult struct { // The uri to fetch the next page of machine extensions. Call ListNext() with this to fetch the next page of extensions. @@ -459,46 +426,6 @@ type MachineUpdateProperties struct { PrivateLinkScopeResourceID *string } -// MachinesClientCreateOrUpdateOptions contains the optional parameters for the MachinesClient.CreateOrUpdate method. -type MachinesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// MachinesClientDeleteOptions contains the optional parameters for the MachinesClient.Delete method. -type MachinesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// MachinesClientGetOptions contains the optional parameters for the MachinesClient.Get method. -type MachinesClientGetOptions struct { - // The expand expression to apply on the operation. - Expand *InstanceViewTypes -} - -// MachinesClientListByResourceGroupOptions contains the optional parameters for the MachinesClient.NewListByResourceGroupPager -// method. -type MachinesClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// MachinesClientListBySubscriptionOptions contains the optional parameters for the MachinesClient.NewListBySubscriptionPager -// method. -type MachinesClientListBySubscriptionOptions struct { - // placeholder for future optional parameters -} - -// MachinesClientUpdateOptions contains the optional parameters for the MachinesClient.Update method. -type MachinesClientUpdateOptions struct { - // placeholder for future optional parameters -} - -// ManagementClientBeginUpgradeExtensionsOptions contains the optional parameters for the ManagementClient.BeginUpgradeExtensions -// method. -type ManagementClientBeginUpgradeExtensionsOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - // OSProfile - Specifies the operating system settings for the hybrid machine. type OSProfile struct { // Specifies the linux configuration for update management. @@ -559,11 +486,6 @@ type OperationValueDisplay struct { Resource *string } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - // PatchSettings - Specifies the patch settings. type PatchSettings struct { // Specifies the assessment mode. @@ -630,32 +552,6 @@ type PrivateEndpointConnectionProperties struct { ProvisioningState *string } -// PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate -// method. -type PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO 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. - ResumeToken string -} - -// PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get -// method. -type PrivateEndpointConnectionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByPrivateLinkScopePager -// method. -type PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions struct { - // placeholder for future optional parameters -} - // PrivateEndpointProperty - Private endpoint which the connection belongs to. type PrivateEndpointProperty struct { // Resource id of the private endpoint. @@ -701,17 +597,6 @@ type PrivateLinkResourceProperties struct { RequiredZoneNames []*string } -// PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get method. -type PrivateLinkResourcesClientGetOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkResourcesClientListByPrivateLinkScopeOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListByPrivateLinkScopePager -// method. -type PrivateLinkResourcesClientListByPrivateLinkScopeOptions struct { - // placeholder for future optional parameters -} - // PrivateLinkScope - An Azure Arc PrivateLinkScope definition. type PrivateLinkScope struct { // REQUIRED; Resource location @@ -774,52 +659,6 @@ type PrivateLinkScopeValidationDetails struct { ID *string } -// PrivateLinkScopesClientBeginDeleteOptions contains the optional parameters for the PrivateLinkScopesClient.BeginDelete -// method. -type PrivateLinkScopesClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// PrivateLinkScopesClientCreateOrUpdateOptions contains the optional parameters for the PrivateLinkScopesClient.CreateOrUpdate -// method. -type PrivateLinkScopesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkScopesClientGetOptions contains the optional parameters for the PrivateLinkScopesClient.Get method. -type PrivateLinkScopesClientGetOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkScopesClientGetValidationDetailsForMachineOptions contains the optional parameters for the PrivateLinkScopesClient.GetValidationDetailsForMachine -// method. -type PrivateLinkScopesClientGetValidationDetailsForMachineOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkScopesClientGetValidationDetailsOptions contains the optional parameters for the PrivateLinkScopesClient.GetValidationDetails -// method. -type PrivateLinkScopesClientGetValidationDetailsOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkScopesClientListByResourceGroupOptions contains the optional parameters for the PrivateLinkScopesClient.NewListByResourceGroupPager -// method. -type PrivateLinkScopesClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkScopesClientListOptions contains the optional parameters for the PrivateLinkScopesClient.NewListPager method. -type PrivateLinkScopesClientListOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkScopesClientUpdateTagsOptions contains the optional parameters for the PrivateLinkScopesClient.UpdateTags method. -type PrivateLinkScopesClientUpdateTagsOptions struct { - // placeholder for future optional parameters -} - // PrivateLinkScopesResource - An azure resource object type PrivateLinkScopesResource struct { // REQUIRED; Resource location diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/models_serde.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/models_serde.go index ee1d027bb6a0..ca92a16329dc 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/models_serde.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/models_serde.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -522,7 +521,7 @@ func (m MachineExtensionInstanceViewStatus) MarshalJSON() ([]byte, error) { populate(objectMap, "displayStatus", m.DisplayStatus) populate(objectMap, "level", m.Level) populate(objectMap, "message", m.Message) - populateTimeRFC3339(objectMap, "time", m.Time) + populateDateTimeRFC3339(objectMap, "time", m.Time) return json.Marshal(objectMap) } @@ -548,7 +547,7 @@ func (m *MachineExtensionInstanceViewStatus) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Message", &m.Message) delete(rawMsg, key) case "time": - err = unpopulateTimeRFC3339(val, "Time", &m.Time) + err = unpopulateDateTimeRFC3339(val, "Time", &m.Time) delete(rawMsg, key) } if err != nil { @@ -806,7 +805,7 @@ func (m MachineProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "domainName", m.DomainName) populate(objectMap, "errorDetails", m.ErrorDetails) populate(objectMap, "extensions", m.Extensions) - populateTimeRFC3339(objectMap, "lastStatusChange", m.LastStatusChange) + populateDateTimeRFC3339(objectMap, "lastStatusChange", m.LastStatusChange) populate(objectMap, "locationData", m.LocationData) populate(objectMap, "machineFqdn", m.MachineFqdn) populate(objectMap, "mssqlDiscovered", m.MssqlDiscovered) @@ -868,7 +867,7 @@ func (m *MachineProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Extensions", &m.Extensions) delete(rawMsg, key) case "lastStatusChange": - err = unpopulateTimeRFC3339(val, "LastStatusChange", &m.LastStatusChange) + err = unpopulateDateTimeRFC3339(val, "LastStatusChange", &m.LastStatusChange) delete(rawMsg, key) case "locationData": err = unpopulate(val, "LocationData", &m.LocationData) @@ -1910,10 +1909,10 @@ func (s *ServiceStatuses) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -1929,7 +1928,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -1938,7 +1937,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/operations_client.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/operations_client.go index 7a9f6844822b..595085053bfb 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/operations_client.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/operations_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -28,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,6 +47,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return false }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") req, err := client.listCreateRequest(ctx, options) if err != nil { return OperationsClientListResponse{}, err @@ -61,6 +61,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/options.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/options.go new file mode 100644 index 000000000000..90fbb79be07a --- /dev/null +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/options.go @@ -0,0 +1,169 @@ +//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 armhybridcompute + +// MachineExtensionsClientBeginCreateOrUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginCreateOrUpdate +// method. +type MachineExtensionsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MachineExtensionsClientBeginDeleteOptions contains the optional parameters for the MachineExtensionsClient.BeginDelete +// method. +type MachineExtensionsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MachineExtensionsClientBeginUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginUpdate +// method. +type MachineExtensionsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MachineExtensionsClientGetOptions contains the optional parameters for the MachineExtensionsClient.Get method. +type MachineExtensionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.NewListPager method. +type MachineExtensionsClientListOptions struct { + // The expand expression to apply on the operation. + Expand *string +} + +// MachinesClientCreateOrUpdateOptions contains the optional parameters for the MachinesClient.CreateOrUpdate method. +type MachinesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// MachinesClientDeleteOptions contains the optional parameters for the MachinesClient.Delete method. +type MachinesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// MachinesClientGetOptions contains the optional parameters for the MachinesClient.Get method. +type MachinesClientGetOptions struct { + // The expand expression to apply on the operation. + Expand *InstanceViewTypes +} + +// MachinesClientListByResourceGroupOptions contains the optional parameters for the MachinesClient.NewListByResourceGroupPager +// method. +type MachinesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// MachinesClientListBySubscriptionOptions contains the optional parameters for the MachinesClient.NewListBySubscriptionPager +// method. +type MachinesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// MachinesClientUpdateOptions contains the optional parameters for the MachinesClient.Update method. +type MachinesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// ManagementClientBeginUpgradeExtensionsOptions contains the optional parameters for the ManagementClient.BeginUpgradeExtensions +// method. +type ManagementClientBeginUpgradeExtensionsOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate +// method. +type PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO 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. + ResumeToken string +} + +// PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get +// method. +type PrivateEndpointConnectionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByPrivateLinkScopePager +// method. +type PrivateEndpointConnectionsClientListByPrivateLinkScopeOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get method. +type PrivateLinkResourcesClientGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesClientListByPrivateLinkScopeOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListByPrivateLinkScopePager +// method. +type PrivateLinkResourcesClientListByPrivateLinkScopeOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesClientBeginDeleteOptions contains the optional parameters for the PrivateLinkScopesClient.BeginDelete +// method. +type PrivateLinkScopesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PrivateLinkScopesClientCreateOrUpdateOptions contains the optional parameters for the PrivateLinkScopesClient.CreateOrUpdate +// method. +type PrivateLinkScopesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesClientGetOptions contains the optional parameters for the PrivateLinkScopesClient.Get method. +type PrivateLinkScopesClientGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesClientGetValidationDetailsForMachineOptions contains the optional parameters for the PrivateLinkScopesClient.GetValidationDetailsForMachine +// method. +type PrivateLinkScopesClientGetValidationDetailsForMachineOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesClientGetValidationDetailsOptions contains the optional parameters for the PrivateLinkScopesClient.GetValidationDetails +// method. +type PrivateLinkScopesClientGetValidationDetailsOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesClientListByResourceGroupOptions contains the optional parameters for the PrivateLinkScopesClient.NewListByResourceGroupPager +// method. +type PrivateLinkScopesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesClientListOptions contains the optional parameters for the PrivateLinkScopesClient.NewListPager method. +type PrivateLinkScopesClientListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesClientUpdateTagsOptions contains the optional parameters for the PrivateLinkScopesClient.UpdateTags method. +type PrivateLinkScopesClientUpdateTagsOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/privateendpointconnections_client.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/privateendpointconnections_client.go index 33486947f382..7bcb204ed9be 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/privateendpointconnections_client.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/privateendpointconnections_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -33,7 +32,7 @@ type PrivateEndpointConnectionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -59,9 +58,14 @@ func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context. if err != nil { return nil, err } - return runtime.NewPoller[PrivateEndpointConnectionsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -70,18 +74,24 @@ func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context. // // Generated from API version 2022-03-10 func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -111,7 +121,10 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx reqQP.Set("api-version", "2022-03-10") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a private endpoint connection with a given name. @@ -129,9 +142,14 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -140,18 +158,24 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // // Generated from API version 2022-03-10 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.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, scopeName, privateEndpointConnectionName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -194,18 +218,25 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get // method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.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, scopeName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -260,25 +291,20 @@ func (client *PrivateEndpointConnectionsClient) NewListByPrivateLinkScopePager(r return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse) (PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateEndpointConnectionsClient.NewListByPrivateLinkScopePager") + 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.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) + }, nil) if err != nil { return PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse{}, runtime.NewResponseError(resp) - } return client.listByPrivateLinkScopeHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/privatelinkresources_client.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/privatelinkresources_client.go index 2dada9607828..f5f1659a6020 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/privatelinkresources_client.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/privatelinkresources_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -33,7 +32,7 @@ type PrivateLinkResourcesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateLinkResourcesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,18 +53,25 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // - options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get // method. func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, groupName string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { + var err error + const operationName = "PrivateLinkResourcesClient.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, scopeName, groupName, options) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkResourcesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkResourcesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -120,25 +126,20 @@ func (client *PrivateLinkResourcesClient) NewListByPrivateLinkScopePager(resourc return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PrivateLinkResourcesClientListByPrivateLinkScopeResponse) (PrivateLinkResourcesClientListByPrivateLinkScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkResourcesClient.NewListByPrivateLinkScopePager") + 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.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) + }, nil) if err != nil { return PrivateLinkResourcesClientListByPrivateLinkScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PrivateLinkResourcesClientListByPrivateLinkScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkResourcesClientListByPrivateLinkScopeResponse{}, runtime.NewResponseError(resp) - } return client.listByPrivateLinkScopeHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/privatelinkscopes_client.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/privatelinkscopes_client.go index 7e126d0a9036..fca3b9a94cee 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/privatelinkscopes_client.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/privatelinkscopes_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -33,7 +32,7 @@ type PrivateLinkScopesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkScopesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkScopesClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateLinkScopesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewPrivateLinkScopesClient(subscriptionID string, credential azcore.TokenCr // - options - PrivateLinkScopesClientCreateOrUpdateOptions contains the optional parameters for the PrivateLinkScopesClient.CreateOrUpdate // method. func (client *PrivateLinkScopesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, parameters PrivateLinkScope, options *PrivateLinkScopesClientCreateOrUpdateOptions) (PrivateLinkScopesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "PrivateLinkScopesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, scopeName, parameters, options) if err != nil { return PrivateLinkScopesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkScopesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return PrivateLinkScopesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkScopesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -92,7 +98,10 @@ func (client *PrivateLinkScopesClient) createOrUpdateCreateRequest(ctx context.C reqQP.Set("api-version", "2022-03-10") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -118,9 +127,14 @@ func (client *PrivateLinkScopesClient) BeginDelete(ctx context.Context, resource if err != nil { return nil, err } - return runtime.NewPoller[PrivateLinkScopesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateLinkScopesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[PrivateLinkScopesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateLinkScopesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -129,18 +143,24 @@ func (client *PrivateLinkScopesClient) BeginDelete(ctx context.Context, resource // // Generated from API version 2022-03-10 func (client *PrivateLinkScopesClient) deleteOperation(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkScopesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "PrivateLinkScopesClient.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, scopeName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -177,18 +197,25 @@ func (client *PrivateLinkScopesClient) deleteCreateRequest(ctx context.Context, // - scopeName - The name of the Azure Arc PrivateLinkScope resource. // - options - PrivateLinkScopesClientGetOptions contains the optional parameters for the PrivateLinkScopesClient.Get method. func (client *PrivateLinkScopesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkScopesClientGetOptions) (PrivateLinkScopesClientGetResponse, error) { + var err error + const operationName = "PrivateLinkScopesClient.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, scopeName, options) if err != nil { return PrivateLinkScopesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkScopesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkScopesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkScopesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -235,18 +262,25 @@ func (client *PrivateLinkScopesClient) getHandleResponse(resp *http.Response) (P // - options - PrivateLinkScopesClientGetValidationDetailsOptions contains the optional parameters for the PrivateLinkScopesClient.GetValidationDetails // method. func (client *PrivateLinkScopesClient) GetValidationDetails(ctx context.Context, location string, privateLinkScopeID string, options *PrivateLinkScopesClientGetValidationDetailsOptions) (PrivateLinkScopesClientGetValidationDetailsResponse, error) { + var err error + const operationName = "PrivateLinkScopesClient.GetValidationDetails" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getValidationDetailsCreateRequest(ctx, location, privateLinkScopeID, options) if err != nil { return PrivateLinkScopesClientGetValidationDetailsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkScopesClientGetValidationDetailsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkScopesClientGetValidationDetailsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkScopesClientGetValidationDetailsResponse{}, err } - return client.getValidationDetailsHandleResponse(resp) + resp, err := client.getValidationDetailsHandleResponse(httpResp) + return resp, err } // getValidationDetailsCreateRequest creates the GetValidationDetails request. @@ -293,18 +327,25 @@ func (client *PrivateLinkScopesClient) getValidationDetailsHandleResponse(resp * // - options - PrivateLinkScopesClientGetValidationDetailsForMachineOptions contains the optional parameters for the PrivateLinkScopesClient.GetValidationDetailsForMachine // method. func (client *PrivateLinkScopesClient) GetValidationDetailsForMachine(ctx context.Context, resourceGroupName string, machineName string, options *PrivateLinkScopesClientGetValidationDetailsForMachineOptions) (PrivateLinkScopesClientGetValidationDetailsForMachineResponse, error) { + var err error + const operationName = "PrivateLinkScopesClient.GetValidationDetailsForMachine" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getValidationDetailsForMachineCreateRequest(ctx, resourceGroupName, machineName, options) if err != nil { return PrivateLinkScopesClientGetValidationDetailsForMachineResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkScopesClientGetValidationDetailsForMachineResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkScopesClientGetValidationDetailsForMachineResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkScopesClientGetValidationDetailsForMachineResponse{}, err } - return client.getValidationDetailsForMachineHandleResponse(resp) + resp, err := client.getValidationDetailsForMachineHandleResponse(httpResp) + return resp, err } // getValidationDetailsForMachineCreateRequest creates the GetValidationDetailsForMachine request. @@ -353,25 +394,20 @@ func (client *PrivateLinkScopesClient) NewListPager(options *PrivateLinkScopesCl return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PrivateLinkScopesClientListResponse) (PrivateLinkScopesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return PrivateLinkScopesClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkScopesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return PrivateLinkScopesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkScopesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -414,25 +450,20 @@ func (client *PrivateLinkScopesClient) NewListByResourceGroupPager(resourceGroup return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PrivateLinkScopesClientListByResourceGroupResponse) (PrivateLinkScopesClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return PrivateLinkScopesClientListByResourceGroupResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkScopesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) if err != nil { return PrivateLinkScopesClientListByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkScopesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -477,18 +508,25 @@ func (client *PrivateLinkScopesClient) listByResourceGroupHandleResponse(resp *h // - options - PrivateLinkScopesClientUpdateTagsOptions contains the optional parameters for the PrivateLinkScopesClient.UpdateTags // method. func (client *PrivateLinkScopesClient) UpdateTags(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource, options *PrivateLinkScopesClientUpdateTagsOptions) (PrivateLinkScopesClientUpdateTagsResponse, error) { + var err error + const operationName = "PrivateLinkScopesClient.UpdateTags" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, scopeName, privateLinkScopeTags, options) if err != nil { return PrivateLinkScopesClientUpdateTagsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkScopesClientUpdateTagsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkScopesClientUpdateTagsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkScopesClientUpdateTagsResponse{}, err } - return client.updateTagsHandleResponse(resp) + resp, err := client.updateTagsHandleResponse(httpResp) + return resp, err } // updateTagsCreateRequest creates the UpdateTags request. @@ -514,7 +552,10 @@ func (client *PrivateLinkScopesClient) updateTagsCreateRequest(ctx context.Conte reqQP.Set("api-version", "2022-03-10") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, privateLinkScopeTags) + if err := runtime.MarshalAsJSON(req, privateLinkScopeTags); err != nil { + return nil, err + } + return req, nil } // updateTagsHandleResponse handles the UpdateTags response. diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/response_types.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/response_types.go index 25b4052f5fdf..50960fe1eff0 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/response_types.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/response_types.go @@ -3,14 +3,14 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute // MachineExtensionsClientCreateOrUpdateResponse contains the response from method MachineExtensionsClient.BeginCreateOrUpdate. type MachineExtensionsClientCreateOrUpdateResponse struct { + // Describes a Machine Extension. MachineExtension } @@ -21,21 +21,25 @@ type MachineExtensionsClientDeleteResponse struct { // MachineExtensionsClientGetResponse contains the response from method MachineExtensionsClient.Get. type MachineExtensionsClientGetResponse struct { + // Describes a Machine Extension. MachineExtension } // MachineExtensionsClientListResponse contains the response from method MachineExtensionsClient.NewListPager. type MachineExtensionsClientListResponse struct { + // Describes the Machine Extensions List Result. MachineExtensionsListResult } // MachineExtensionsClientUpdateResponse contains the response from method MachineExtensionsClient.BeginUpdate. type MachineExtensionsClientUpdateResponse struct { + // Describes a Machine Extension. MachineExtension } // MachinesClientCreateOrUpdateResponse contains the response from method MachinesClient.CreateOrUpdate. type MachinesClientCreateOrUpdateResponse struct { + // Describes a hybrid machine. Machine } @@ -46,21 +50,25 @@ type MachinesClientDeleteResponse struct { // MachinesClientGetResponse contains the response from method MachinesClient.Get. type MachinesClientGetResponse struct { + // Describes a hybrid machine. Machine } // MachinesClientListByResourceGroupResponse contains the response from method MachinesClient.NewListByResourceGroupPager. type MachinesClientListByResourceGroupResponse struct { + // The List hybrid machine operation response. MachineListResult } // MachinesClientListBySubscriptionResponse contains the response from method MachinesClient.NewListBySubscriptionPager. type MachinesClientListBySubscriptionResponse struct { + // The List hybrid machine operation response. MachineListResult } // MachinesClientUpdateResponse contains the response from method MachinesClient.Update. type MachinesClientUpdateResponse struct { + // Describes a hybrid machine. Machine } @@ -71,11 +79,13 @@ type ManagementClientUpgradeExtensionsResponse struct { // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // The List Compute Operation operation response. OperationListResult } // PrivateEndpointConnectionsClientCreateOrUpdateResponse contains the response from method PrivateEndpointConnectionsClient.BeginCreateOrUpdate. type PrivateEndpointConnectionsClientCreateOrUpdateResponse struct { + // A private endpoint connection PrivateEndpointConnection } @@ -86,26 +96,31 @@ type PrivateEndpointConnectionsClientDeleteResponse struct { // PrivateEndpointConnectionsClientGetResponse contains the response from method PrivateEndpointConnectionsClient.Get. type PrivateEndpointConnectionsClientGetResponse struct { + // A private endpoint connection PrivateEndpointConnection } // PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse contains the response from method PrivateEndpointConnectionsClient.NewListByPrivateLinkScopePager. type PrivateEndpointConnectionsClientListByPrivateLinkScopeResponse struct { + // A list of private endpoint connections. PrivateEndpointConnectionListResult } // PrivateLinkResourcesClientGetResponse contains the response from method PrivateLinkResourcesClient.Get. type PrivateLinkResourcesClientGetResponse struct { + // A private link resource PrivateLinkResource } // PrivateLinkResourcesClientListByPrivateLinkScopeResponse contains the response from method PrivateLinkResourcesClient.NewListByPrivateLinkScopePager. type PrivateLinkResourcesClientListByPrivateLinkScopeResponse struct { + // A list of private link resources PrivateLinkResourceListResult } // PrivateLinkScopesClientCreateOrUpdateResponse contains the response from method PrivateLinkScopesClient.CreateOrUpdate. type PrivateLinkScopesClientCreateOrUpdateResponse struct { + // An Azure Arc PrivateLinkScope definition. PrivateLinkScope } @@ -116,6 +131,7 @@ type PrivateLinkScopesClientDeleteResponse struct { // PrivateLinkScopesClientGetResponse contains the response from method PrivateLinkScopesClient.Get. type PrivateLinkScopesClientGetResponse struct { + // An Azure Arc PrivateLinkScope definition. PrivateLinkScope } @@ -131,15 +147,18 @@ type PrivateLinkScopesClientGetValidationDetailsResponse struct { // PrivateLinkScopesClientListByResourceGroupResponse contains the response from method PrivateLinkScopesClient.NewListByResourceGroupPager. type PrivateLinkScopesClientListByResourceGroupResponse struct { + // Describes the list of Azure Arc PrivateLinkScope resources. PrivateLinkScopeListResult } // PrivateLinkScopesClientListResponse contains the response from method PrivateLinkScopesClient.NewListPager. type PrivateLinkScopesClientListResponse struct { + // Describes the list of Azure Arc PrivateLinkScope resources. PrivateLinkScopeListResult } // PrivateLinkScopesClientUpdateTagsResponse contains the response from method PrivateLinkScopesClient.UpdateTags. type PrivateLinkScopesClientUpdateTagsResponse struct { + // An Azure Arc PrivateLinkScope definition. PrivateLinkScope } diff --git a/sdk/resourcemanager/hybridcompute/armhybridcompute/time_rfc3339.go b/sdk/resourcemanager/hybridcompute/armhybridcompute/time_rfc3339.go index 11928484add6..8093138a95a7 100644 --- a/sdk/resourcemanager/hybridcompute/armhybridcompute/time_rfc3339.go +++ b/sdk/resourcemanager/hybridcompute/armhybridcompute/time_rfc3339.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armhybridcompute @@ -19,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) }