From 7349271eed9a487faf226bcb279e0c02488c6597 Mon Sep 17 00:00:00 2001 From: lakshmimsft Date: Mon, 11 Nov 2024 10:06:43 -0800 Subject: [PATCH] upd client for messengerrp --- build/generate.mk | 2 +- pkg/messagingrp/api/README.md | 3 +- .../fake/zz_generated_internal.go | 66 ++++ .../fake/zz_generated_operations_server.go | 118 ++++++ .../zz_generated_rabbitmqqueues_server.go | 353 ++++++++++++++++++ .../fake/zz_generated_server_factory.go | 80 ++++ .../fake/zz_generated_time_rfc3339.go | 114 ++++++ .../zz_generated_client_factory.go | 25 +- .../zz_generated_constants.go | 29 +- .../zz_generated_interfaces.go | 3 - .../v20231001preview/zz_generated_models.go | 191 +++++----- .../zz_generated_models_serde.go | 13 +- .../zz_generated_operations_client.go | 30 +- .../v20231001preview/zz_generated_options.go | 9 +- .../zz_generated_polymorphic_helpers.go | 5 +- .../zz_generated_rabbitmqqueues_client.go | 81 ++-- ...nse_types.go => zz_generated_responses.go} | 15 +- .../zz_generated_time_rfc3339.go | 76 ++-- 18 files changed, 981 insertions(+), 232 deletions(-) create mode 100644 pkg/messagingrp/api/v20231001preview/fake/zz_generated_internal.go create mode 100644 pkg/messagingrp/api/v20231001preview/fake/zz_generated_operations_server.go create mode 100644 pkg/messagingrp/api/v20231001preview/fake/zz_generated_rabbitmqqueues_server.go create mode 100644 pkg/messagingrp/api/v20231001preview/fake/zz_generated_server_factory.go create mode 100644 pkg/messagingrp/api/v20231001preview/fake/zz_generated_time_rfc3339.go rename pkg/messagingrp/api/v20231001preview/{zz_generated_response_types.go => zz_generated_responses.go} (80%) diff --git a/build/generate.mk b/build/generate.mk index 56b0655f9f9..e0a969f997f 100644 --- a/build/generate.mk +++ b/build/generate.mk @@ -89,7 +89,7 @@ generate-rad-datastoresrp-client: generate-node-installed generate-autorest-inst .PHONY: generate-rad-messagingrp-client generate-rad-messagingrp-client: generate-node-installed generate-autorest-installed generate-tsp-installed generate-openapi-spec ## Generates the messagingrp client SDK (Autorest). @echo "$(AUTOREST_MODULE_VERSION) is module version" - autorest pkg/messagingrp/api/README.md --tag=messaging-2023-10-01-preview + autorest pkg/messagingrp/api/README.md --tag=messaging-2023-10-01-preview && rm pkg/messagingrp/api/v20231001preview/go.mod .PHONY: generate-rad-daprrp-client generate-rad-daprrp-client: generate-node-installed generate-autorest-installed generate-tsp-installed generate-openapi-spec ## Generates the daprrp client SDK (Autorest). diff --git a/pkg/messagingrp/api/README.md b/pkg/messagingrp/api/README.md index 9ff2049dae0..5aa7b1c4097 100644 --- a/pkg/messagingrp/api/README.md +++ b/pkg/messagingrp/api/README.md @@ -44,7 +44,8 @@ The following configuration generates track2 go models and client. ```yaml $(tag) != '' version: 3.*.* -use: "@autorest/go@4.0.0-preview.55" +use: "@autorest/go@4.0.0-preview.69" +module: "github.com/radius-project/radius/pkg/messagingrp/api/v20231001preview" module-version: 0.0.1 file-prefix: zz_generated_ license-header: "Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information.\nCode generated by Microsoft (R) AutoRest Code Generator.\nChanges may cause incorrect behavior and will be lost if the code is regenerated." diff --git a/pkg/messagingrp/api/v20231001preview/fake/zz_generated_internal.go b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_internal.go new file mode 100644 index 00000000000..0c62457a833 --- /dev/null +++ b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_internal.go @@ -0,0 +1,66 @@ +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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" + "sync" +) + + +type result struct { + resp *http.Response + err error +} + +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 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/pkg/messagingrp/api/v20231001preview/fake/zz_generated_operations_server.go b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_operations_server.go new file mode 100644 index 00000000000..3c9ff3c46be --- /dev/null +++ b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_operations_server.go @@ -0,0 +1,118 @@ +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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/azcore/to" + "github.com/radius-project/radius/pkg/messagingrp/api/v20231001preview" + "net/http" +) + +// OperationsServer is a fake server for instances of the v20231001preview.OperationsClient type. +type OperationsServer struct{ + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *v20231001preview.OperationsClientListOptions) (resp azfake.PagerResponder[v20231001preview.OperationsClientListResponse]) + +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of v20231001preview.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[v20231001preview.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of v20231001preview.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[v20231001preview.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")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + 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) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *v20231001preview.OperationsClientListResponse, 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) { + 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 +} + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/pkg/messagingrp/api/v20231001preview/fake/zz_generated_rabbitmqqueues_server.go b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_rabbitmqqueues_server.go new file mode 100644 index 00000000000..2d837bd0e13 --- /dev/null +++ b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_rabbitmqqueues_server.go @@ -0,0 +1,353 @@ +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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/radius-project/radius/pkg/messagingrp/api/v20231001preview" + "net/http" + "net/url" + "regexp" +) + +// RabbitMqQueuesServer is a fake server for instances of the v20231001preview.RabbitMqQueuesClient type. +type RabbitMqQueuesServer struct{ + // BeginCreateOrUpdate is the fake for method RabbitMqQueuesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, rabbitMQQueueName string, resource v20231001preview.RabbitMQQueueResource, options *v20231001preview.RabbitMqQueuesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method RabbitMqQueuesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, rabbitMQQueueName string, options *v20231001preview.RabbitMqQueuesClientBeginDeleteOptions) (resp azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RabbitMqQueuesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, rabbitMQQueueName string, options *v20231001preview.RabbitMqQueuesClientGetOptions) (resp azfake.Responder[v20231001preview.RabbitMqQueuesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByScopePager is the fake for method RabbitMqQueuesClient.NewListByScopePager + // HTTP status codes to indicate success: http.StatusOK + NewListByScopePager func(options *v20231001preview.RabbitMqQueuesClientListByScopeOptions) (resp azfake.PagerResponder[v20231001preview.RabbitMqQueuesClientListByScopeResponse]) + + // ListSecrets is the fake for method RabbitMqQueuesClient.ListSecrets + // HTTP status codes to indicate success: http.StatusOK + ListSecrets func(ctx context.Context, rabbitMQQueueName string, body map[string]any, options *v20231001preview.RabbitMqQueuesClientListSecretsOptions) (resp azfake.Responder[v20231001preview.RabbitMqQueuesClientListSecretsResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method RabbitMqQueuesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, rabbitMQQueueName string, properties v20231001preview.RabbitMQQueueResourceUpdate, options *v20231001preview.RabbitMqQueuesClientBeginUpdateOptions) (resp azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientUpdateResponse], errResp azfake.ErrorResponder) + +} + +// NewRabbitMqQueuesServerTransport creates a new instance of RabbitMqQueuesServerTransport with the provided implementation. +// The returned RabbitMqQueuesServerTransport instance is connected to an instance of v20231001preview.RabbitMqQueuesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRabbitMqQueuesServerTransport(srv *RabbitMqQueuesServer) *RabbitMqQueuesServerTransport { + return &RabbitMqQueuesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientDeleteResponse]](), + newListByScopePager: newTracker[azfake.PagerResponder[v20231001preview.RabbitMqQueuesClientListByScopeResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientUpdateResponse]](), + } +} + +// RabbitMqQueuesServerTransport connects instances of v20231001preview.RabbitMqQueuesClient to instances of RabbitMqQueuesServer. +// Don't use this type directly, use NewRabbitMqQueuesServerTransport instead. +type RabbitMqQueuesServerTransport struct { + srv *RabbitMqQueuesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientDeleteResponse]] + newListByScopePager *tracker[azfake.PagerResponder[v20231001preview.RabbitMqQueuesClientListByScopeResponse]] + beginUpdate *tracker[azfake.PollerResponder[v20231001preview.RabbitMqQueuesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for RabbitMqQueuesServerTransport. +func (r *RabbitMqQueuesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return r.dispatchToMethodFake(req, method) +} + +func (r *RabbitMqQueuesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if rabbitMqQueuesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = rabbitMqQueuesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "RabbitMqQueuesClient.BeginCreateOrUpdate": + res.resp, res.err = r.dispatchBeginCreateOrUpdate(req) + case "RabbitMqQueuesClient.BeginDelete": + res.resp, res.err = r.dispatchBeginDelete(req) + case "RabbitMqQueuesClient.Get": + res.resp, res.err = r.dispatchGet(req) + case "RabbitMqQueuesClient.NewListByScopePager": + res.resp, res.err = r.dispatchNewListByScopePager(req) + case "RabbitMqQueuesClient.ListSecrets": + res.resp, res.err = r.dispatchListSecrets(req) + case "RabbitMqQueuesClient.BeginUpdate": + res.resp, res.err = r.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (r *RabbitMqQueuesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := r.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Applications\.Messaging/rabbitMQQueues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[v20231001preview.RabbitMQQueueResource](req) + if err != nil { + return nil, err + } + rabbitMQQueueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("rabbitMQQueueName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreateOrUpdate(req.Context(), rabbitMQQueueNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + r.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + r.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + r.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (r *RabbitMqQueuesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := r.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Applications\.Messaging/rabbitMQQueues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + rabbitMQQueueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("rabbitMQQueueName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), rabbitMQQueueNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + r.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) { + r.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) { + r.beginDelete.remove(req) + } + + return resp, nil +} + +func (r *RabbitMqQueuesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Applications\.Messaging/rabbitMQQueues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + rabbitMQQueueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("rabbitMQQueueName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), rabbitMQQueueNameParam, 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).RabbitMQQueueResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RabbitMqQueuesServerTransport) dispatchNewListByScopePager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByScopePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByScopePager not implemented")} + } + newListByScopePager := r.newListByScopePager.get(req) + if newListByScopePager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Applications\.Messaging/rabbitMQQueues` + 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 := r.srv.NewListByScopePager(nil) + newListByScopePager = &resp + r.newListByScopePager.add(req, newListByScopePager) + server.PagerResponderInjectNextLinks(newListByScopePager, req, func(page *v20231001preview.RabbitMqQueuesClientListByScopeResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByScopePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListByScopePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByScopePager) { + r.newListByScopePager.remove(req) + } + return resp, nil +} + +func (r *RabbitMqQueuesServerTransport) dispatchListSecrets(req *http.Request) (*http.Response, error) { + if r.srv.ListSecrets == nil { + return nil, &nonRetriableError{errors.New("fake for method ListSecrets not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Applications\.Messaging/rabbitMQQueues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listSecrets` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[map[string]any](req) + if err != nil { + return nil, err + } + rabbitMQQueueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("rabbitMQQueueName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.ListSecrets(req.Context(), rabbitMQQueueNameParam, 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).RabbitMQListSecretsResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RabbitMqQueuesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := r.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Applications\.Messaging/rabbitMQQueues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[v20231001preview.RabbitMQQueueResourceUpdate](req) + if err != nil { + return nil, err + } + rabbitMQQueueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("rabbitMQQueueName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), rabbitMQQueueNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + r.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) { + r.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) { + r.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to RabbitMqQueuesServerTransport +var rabbitMqQueuesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/pkg/messagingrp/api/v20231001preview/fake/zz_generated_server_factory.go b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_server_factory.go new file mode 100644 index 00000000000..194a926e68f --- /dev/null +++ b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_server_factory.go @@ -0,0 +1,80 @@ +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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 v20231001preview.ClientFactory type. +type ServerFactory struct { + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // RabbitMqQueuesServer contains the fakes for client RabbitMqQueuesClient + RabbitMqQueuesServer RabbitMqQueuesServer + +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of v20231001preview.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 v20231001preview.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trOperationsServer *OperationsServerTransport + trRabbitMqQueuesServer *RabbitMqQueuesServerTransport +} + +// 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 "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "RabbitMqQueuesClient": + initServer(s, &s.trRabbitMqQueuesServer, func() *RabbitMqQueuesServerTransport { return NewRabbitMqQueuesServerTransport(&s.srv.RabbitMqQueuesServer) }) + resp, err = s.trRabbitMqQueuesServer.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/pkg/messagingrp/api/v20231001preview/fake/zz_generated_time_rfc3339.go b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_time_rfc3339.go new file mode 100644 index 00000000000..83c75cddc68 --- /dev/null +++ b/pkg/messagingrp/api/v20231001preview/fake/zz_generated_time_rfc3339.go @@ -0,0 +1,114 @@ +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + + + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + + + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_client_factory.go b/pkg/messagingrp/api/v20231001preview/zz_generated_client_factory.go index 4e82fbb8756..dfd844bfcfe 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_client_factory.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_client_factory.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -16,8 +13,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { rootScope string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -28,23 +24,28 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - rootScope: rootScope, credential: credential, - options: options.Clone(), + rootScope: rootScope, + internal: internal, }, nil } +// NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } +// NewRabbitMqQueuesClient creates a new instance of RabbitMqQueuesClient. func (c *ClientFactory) NewRabbitMqQueuesClient() *RabbitMqQueuesClient { - subClient, _ := NewRabbitMqQueuesClient(c.rootScope, c.credential, c.options) - return subClient + return &RabbitMqQueuesClient{ + rootScope: c.rootScope, + internal: c.internal, + } } diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_constants.go b/pkg/messagingrp/api/v20231001preview/zz_generated_constants.go index dee57fba783..66a8629f037 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_constants.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_constants.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -8,7 +5,7 @@ package v20231001preview const ( - moduleName = "v20231001preview" + moduleName = "github.com/radius-project/radius/pkg/messagingrp/api/v20231001preview" moduleVersion = "v0.0.1" ) @@ -50,9 +47,9 @@ func PossibleCreatedByTypeValues() []CreatedByType { type IdentitySettingKind string const ( - // IdentitySettingKindAzureComWorkload - azure ad workload identity +// IdentitySettingKindAzureComWorkload - azure ad workload identity IdentitySettingKindAzureComWorkload IdentitySettingKind = "azure.com.workload" - // IdentitySettingKindUndefined - undefined identity +// IdentitySettingKindUndefined - undefined identity IdentitySettingKindUndefined IdentitySettingKind = "undefined" ) @@ -87,21 +84,21 @@ func PossibleOriginValues() []Origin { type ProvisioningState string const ( - // ProvisioningStateAccepted - The resource create request has been accepted +// ProvisioningStateAccepted - The resource create request has been accepted ProvisioningStateAccepted ProvisioningState = "Accepted" - // ProvisioningStateCanceled - The resource provisioning has been canceled +// ProvisioningStateCanceled - The resource provisioning has been canceled ProvisioningStateCanceled ProvisioningState = "Canceled" - // ProvisioningStateCreating - The resource is being created +// ProvisioningStateCreating - The resource is being created ProvisioningStateCreating ProvisioningState = "Creating" - // ProvisioningStateDeleting - The resource is being deleted +// ProvisioningStateDeleting - The resource is being deleted ProvisioningStateDeleting ProvisioningState = "Deleting" - // ProvisioningStateFailed - The resource provisioning has failed +// ProvisioningStateFailed - The resource provisioning has failed ProvisioningStateFailed ProvisioningState = "Failed" - // ProvisioningStateProvisioning - The resource is being provisioned +// ProvisioningStateProvisioning - The resource is being provisioned ProvisioningStateProvisioning ProvisioningState = "Provisioning" - // ProvisioningStateSucceeded - The resource has been successfully provisioned +// ProvisioningStateSucceeded - The resource has been successfully provisioned ProvisioningStateSucceeded ProvisioningState = "Succeeded" - // ProvisioningStateUpdating - The resource is being updated +// ProvisioningStateUpdating - The resource is being updated ProvisioningStateUpdating ProvisioningState = "Updating" ) @@ -125,9 +122,9 @@ func PossibleProvisioningStateValues() []ProvisioningState { type ResourceProvisioning string const ( - // ResourceProvisioningManual - The resource lifecycle will be managed by the user +// ResourceProvisioningManual - The resource lifecycle will be managed by the user ResourceProvisioningManual ResourceProvisioning = "manual" - // ResourceProvisioningRecipe - The resource lifecycle will be managed by Radius +// ResourceProvisioningRecipe - The resource lifecycle will be managed by Radius ResourceProvisioningRecipe ResourceProvisioning = "recipe" ) diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_interfaces.go b/pkg/messagingrp/api/v20231001preview/zz_generated_interfaces.go index ff4b623caed..dd034e311af 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_interfaces.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_interfaces.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_models.go b/pkg/messagingrp/api/v20231001preview/zz_generated_models.go index a01b5879a5f..878133dae54 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_models.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_models.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -12,31 +9,31 @@ import "time" // AzureResourceManagerCommonTypesTrackedResourceUpdate - The resource model definition for an Azure Resource Manager tracked // top level resource which has 'tags' and a 'location' type AzureResourceManagerCommonTypesTrackedResourceUpdate struct { - // Resource tags. +// Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} +// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource +// READ-ONLY; The name of the resource Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. +// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" +// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } // EnvironmentCompute - Represents backing compute resource type EnvironmentCompute struct { - // REQUIRED; Discriminator property for EnvironmentCompute. +// REQUIRED; Discriminator property for EnvironmentCompute. Kind *string - // Configuration for supported external identity providers +// Configuration for supported external identity providers Identity *IdentitySettings - // The resource id of the compute resource for application environment. +// The resource id of the compute resource for application environment. ResourceID *string } @@ -45,62 +42,62 @@ func (e *EnvironmentCompute) GetEnvironmentCompute() *EnvironmentCompute { retur // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { - // READ-ONLY; The additional info. +// READ-ONLY; The additional info. Info map[string]any - // READ-ONLY; The additional info type. +// READ-ONLY; The additional info type. Type *string } // ErrorDetail - The error detail. type ErrorDetail struct { - // READ-ONLY; The error additional info. +// READ-ONLY; The error additional info. AdditionalInfo []*ErrorAdditionalInfo - // READ-ONLY; The error code. +// READ-ONLY; The error code. Code *string - // READ-ONLY; The error details. +// READ-ONLY; The error details. Details []*ErrorDetail - // READ-ONLY; The error message. +// READ-ONLY; The error message. Message *string - // READ-ONLY; The error target. +// READ-ONLY; The error target. Target *string } // ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. // (This also follows the OData error response format.). type ErrorResponse struct { - // The error object. +// The error object. Error *ErrorDetail } // IdentitySettings is the external identity setting. type IdentitySettings struct { - // REQUIRED; kind of identity setting +// REQUIRED; kind of identity setting Kind *IdentitySettingKind - // The URI for your compute platform's OIDC issuer +// The URI for your compute platform's OIDC issuer OidcIssuer *string - // The resource ID of the provisioned identity +// The resource ID of the provisioned identity Resource *string } // KubernetesCompute - The Kubernetes compute configuration type KubernetesCompute struct { - // REQUIRED; Discriminator property for EnvironmentCompute. +// REQUIRED; Discriminator property for EnvironmentCompute. Kind *string - // REQUIRED; The namespace to use for the environment. +// REQUIRED; The namespace to use for the environment. Namespace *string - // Configuration for supported external identity providers +// Configuration for supported external identity providers Identity *IdentitySettings - // The resource id of the compute resource for application environment. +// The resource id of the compute resource for application environment. ResourceID *string } @@ -115,39 +112,39 @@ func (k *KubernetesCompute) GetEnvironmentCompute() *EnvironmentCompute { // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { - // Localized display information for this particular operation. +// Localized display information for this particular operation. Display *OperationDisplay - // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +// READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. ActionType *ActionType - // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane +// READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane // operations. IsDataAction *bool - // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", +// READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", // "Microsoft.Compute/virtualMachines/capture/action" Name *string - // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" Origin *Origin } // OperationDisplay - Localized display information for this particular operation. type OperationDisplay struct { - // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. +// READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. Description *string - // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual +// READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual // Machine", "Restart Virtual Machine". Operation *string - // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft +// READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft // Compute". Provider *string - // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job +// READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job // Schedule Collections". Resource *string } @@ -155,237 +152,237 @@ type OperationDisplay struct { // OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to // get the next set of results. type OperationListResult struct { - // READ-ONLY; URL to get the next set of operation list results (if there are any). +// READ-ONLY; URL to get the next set of operation list results (if there are any). NextLink *string - // READ-ONLY; List of operations supported by the resource provider +// READ-ONLY; List of operations supported by the resource provider Value []*Operation } // OutputResource - Properties of an output resource. type OutputResource struct { - // The UCP resource ID of the underlying resource. +// The UCP resource ID of the underlying resource. ID *string - // The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency +// The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency // relationship. LocalIDs do not have any particular format or meaning beyond // being compared to determine dependency relationships. LocalID *string - // Determines whether Radius manages the lifecycle of the underlying resource. +// Determines whether Radius manages the lifecycle of the underlying resource. RadiusManaged *bool } // RabbitMQListSecretsResult - The secret values for the given RabbitMQQueue resource type RabbitMQListSecretsResult struct { - // The password used to connect to the RabbitMQ instance +// The password used to connect to the RabbitMQ instance Password *string - // The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. +// The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. // Can be overridden with a custom value URI *string } // RabbitMQQueueProperties - RabbitMQQueue portable resource properties type RabbitMQQueueProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to +// REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to Environment *string - // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) +// Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) Application *string - // The hostname of the RabbitMQ instance +// The hostname of the RabbitMQ instance Host *string - // The port of the RabbitMQ instance. Defaults to 5672 +// The port of the RabbitMQ instance. Defaults to 5672 Port *int32 - // The name of the queue +// The name of the queue Queue *string - // The recipe used to automatically deploy underlying infrastructure for the resource +// The recipe used to automatically deploy underlying infrastructure for the resource Recipe *Recipe - // Specifies how the underlying service/resource is provisioned and managed. +// Specifies how the underlying service/resource is provisioned and managed. ResourceProvisioning *ResourceProvisioning - // List of the resource IDs that support the rabbitMQ resource +// List of the resource IDs that support the rabbitMQ resource Resources []*ResourceReference - // The secrets to connect to the RabbitMQ instance +// The secrets to connect to the RabbitMQ instance Secrets *RabbitMQSecrets - // Specifies whether to use SSL when connecting to the RabbitMQ instance +// Specifies whether to use SSL when connecting to the RabbitMQ instance TLS *bool - // The username to use when connecting to the RabbitMQ instance +// The username to use when connecting to the RabbitMQ instance Username *string - // The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost. +// The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost. VHost *string - // READ-ONLY; The status of the asynchronous operation. +// READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of a resource. +// READ-ONLY; Status of a resource. Status *ResourceStatus } // RabbitMQQueueResource - RabbitMQQueue portable resource type RabbitMQQueueResource struct { - // REQUIRED; The geo-location where the resource lives +// REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; The resource-specific properties for this resource. +// REQUIRED; The resource-specific properties for this resource. Properties *RabbitMQQueueProperties - // Resource tags. +// Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} +// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource +// READ-ONLY; The name of the resource Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. +// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" +// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } // RabbitMQQueueResourceListResult - The response of a RabbitMQQueueResource list operation. type RabbitMQQueueResourceListResult struct { - // REQUIRED; The RabbitMQQueueResource items on this page +// REQUIRED; The RabbitMQQueueResource items on this page Value []*RabbitMQQueueResource - // The link to the next page of items +// The link to the next page of items NextLink *string } // RabbitMQQueueResourceUpdate - RabbitMQQueue portable resource type RabbitMQQueueResourceUpdate struct { - // Resource tags. +// Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} +// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource +// READ-ONLY; The name of the resource Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. +// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" +// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } // RabbitMQSecrets - The connection secrets properties to the RabbitMQ instance type RabbitMQSecrets struct { - // The password used to connect to the RabbitMQ instance +// The password used to connect to the RabbitMQ instance Password *string - // The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. +// The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. // Can be overridden with a custom value URI *string } // Recipe - The recipe used to automatically deploy underlying infrastructure for a portable resource type Recipe struct { - // REQUIRED; The name of the recipe within the environment to use +// REQUIRED; The name of the recipe within the environment to use Name *string - // Key/value parameters to pass into the recipe at deployment +// Key/value parameters to pass into the recipe at deployment Parameters map[string]any } // RecipeStatus - Recipe status at deployment time for a resource. type RecipeStatus struct { - // REQUIRED; TemplateKind is the kind of the recipe template used by the portable resource upon deployment. +// REQUIRED; TemplateKind is the kind of the recipe template used by the portable resource upon deployment. TemplateKind *string - // REQUIRED; TemplatePath is the path of the recipe consumed by the portable resource upon deployment. +// REQUIRED; TemplatePath is the path of the recipe consumed by the portable resource upon deployment. TemplatePath *string - // TemplateVersion is the version number of the template. +// TemplateVersion is the version number of the template. TemplateVersion *string } // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} +// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource +// READ-ONLY; The name of the resource Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. +// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" +// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } // ResourceReference - Describes a reference to an existing resource type ResourceReference struct { - // REQUIRED; Resource id of an existing resource +// REQUIRED; Resource id of an existing resource ID *string } // ResourceStatus - Status of a resource. type ResourceStatus struct { - // The compute resource associated with the resource. +// The compute resource associated with the resource. Compute EnvironmentComputeClassification - // Properties of an output resource +// Properties of an output resource OutputResources []*OutputResource - // READ-ONLY; The recipe data at the time of deployment +// READ-ONLY; The recipe data at the time of deployment Recipe *RecipeStatus } // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { - // The timestamp of resource creation (UTC). +// The timestamp of resource creation (UTC). CreatedAt *time.Time - // The identity that created the resource. +// The identity that created the resource. CreatedBy *string - // The type of identity that created the resource. +// The type of identity that created the resource. CreatedByType *CreatedByType - // The timestamp of resource last modification (UTC) +// The timestamp of resource last modification (UTC) LastModifiedAt *time.Time - // The identity that last modified the resource. +// The identity that last modified the resource. LastModifiedBy *string - // The type of identity that last modified the resource. +// The type of identity that last modified the resource. LastModifiedByType *CreatedByType } // TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' // and a 'location' type TrackedResource struct { - // REQUIRED; The geo-location where the resource lives +// REQUIRED; The geo-location where the resource lives Location *string - // Resource tags. +// Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} +// READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource +// READ-ONLY; The name of the resource Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. +// READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" +// READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_models_serde.go b/pkg/messagingrp/api/v20231001preview/zz_generated_models_serde.go index d5be2708824..f32de3ebbb7 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_models_serde.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_models_serde.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -851,10 +848,10 @@ func (r *ResourceStatus) 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) @@ -870,7 +867,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) @@ -879,7 +876,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) @@ -953,7 +950,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_operations_client.go b/pkg/messagingrp/api/v20231001preview/zz_generated_operations_client.go index a26b477ef5b..ae77ab45866 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_operations_client.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_operations_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -26,7 +23,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 } @@ -46,30 +43,25 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, 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 OperationsClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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 OperationsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) - }, + }, + Tracer: client.internal.Tracer(), }) } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Applications.Messaging/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_options.go b/pkg/messagingrp/api/v20231001preview/zz_generated_options.go index 1eaffef9767..e5ec6f6b11a 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_options.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_options.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -15,19 +12,19 @@ type OperationsClientListOptions struct { // RabbitMqQueuesClientBeginCreateOrUpdateOptions contains the optional parameters for the RabbitMqQueuesClient.BeginCreateOrUpdate // method. type RabbitMqQueuesClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. +// Resumes the long-running operation from the provided token. ResumeToken string } // RabbitMqQueuesClientBeginDeleteOptions contains the optional parameters for the RabbitMqQueuesClient.BeginDelete method. type RabbitMqQueuesClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. +// Resumes the long-running operation from the provided token. ResumeToken string } // RabbitMqQueuesClientBeginUpdateOptions contains the optional parameters for the RabbitMqQueuesClient.BeginUpdate method. type RabbitMqQueuesClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. +// Resumes the long-running operation from the provided token. ResumeToken string } diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_polymorphic_helpers.go b/pkg/messagingrp/api/v20231001preview/zz_generated_polymorphic_helpers.go index c574dd5eea4..7b008f3d809 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_polymorphic_helpers.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_polymorphic_helpers.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -10,7 +7,7 @@ package v20231001preview import "encoding/json" func unmarshalEnvironmentComputeClassification(rawMsg json.RawMessage) (EnvironmentComputeClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_rabbitmqqueues_client.go b/pkg/messagingrp/api/v20231001preview/zz_generated_rabbitmqqueues_client.go index bb5f1527951..1d48fc4ab1b 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_rabbitmqqueues_client.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_rabbitmqqueues_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -33,7 +30,7 @@ type RabbitMqQueuesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewRabbitMqQueuesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RabbitMqQueuesClient, error) { - cl, err := arm.NewClient(moduleName+".RabbitMqQueuesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -60,10 +57,13 @@ func (client *RabbitMqQueuesClient) BeginCreateOrUpdate(ctx context.Context, rab } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RabbitMqQueuesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[RabbitMqQueuesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RabbitMqQueuesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -73,6 +73,10 @@ func (client *RabbitMqQueuesClient) BeginCreateOrUpdate(ctx context.Context, rab // Generated from API version 2023-10-01-preview func (client *RabbitMqQueuesClient) createOrUpdate(ctx context.Context, rabbitMQQueueName string, resource RabbitMQQueueResource, options *RabbitMqQueuesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "RabbitMqQueuesClient.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, rabbitMQQueueName, resource, options) if err != nil { return nil, err @@ -89,7 +93,7 @@ func (client *RabbitMqQueuesClient) createOrUpdate(ctx context.Context, rabbitMQ } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *RabbitMqQueuesClient) createOrUpdateCreateRequest(ctx context.Context, rabbitMQQueueName string, resource RabbitMQQueueResource, options *RabbitMqQueuesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) createOrUpdateCreateRequest(ctx context.Context, rabbitMQQueueName string, resource RabbitMQQueueResource, _ *RabbitMqQueuesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if rabbitMQQueueName == "" { @@ -107,7 +111,7 @@ func (client *RabbitMqQueuesClient) createOrUpdateCreateRequest(ctx context.Cont if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } - return req, nil +; return req, nil } // BeginDelete - Delete a RabbitMQQueueResource @@ -125,10 +129,13 @@ func (client *RabbitMqQueuesClient) BeginDelete(ctx context.Context, rabbitMQQue } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RabbitMqQueuesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[RabbitMqQueuesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RabbitMqQueuesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -138,6 +145,10 @@ func (client *RabbitMqQueuesClient) BeginDelete(ctx context.Context, rabbitMQQue // Generated from API version 2023-10-01-preview func (client *RabbitMqQueuesClient) deleteOperation(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "RabbitMqQueuesClient.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, rabbitMQQueueName, options) if err != nil { return nil, err @@ -154,7 +165,7 @@ func (client *RabbitMqQueuesClient) deleteOperation(ctx context.Context, rabbitM } // deleteCreateRequest creates the Delete request. -func (client *RabbitMqQueuesClient) deleteCreateRequest(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientBeginDeleteOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) deleteCreateRequest(ctx context.Context, rabbitMQQueueName string, _ *RabbitMqQueuesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if rabbitMQQueueName == "" { @@ -180,6 +191,10 @@ func (client *RabbitMqQueuesClient) deleteCreateRequest(ctx context.Context, rab // - options - RabbitMqQueuesClientGetOptions contains the optional parameters for the RabbitMqQueuesClient.Get method. func (client *RabbitMqQueuesClient) Get(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientGetOptions) (RabbitMqQueuesClientGetResponse, error) { var err error + const operationName = "RabbitMqQueuesClient.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, rabbitMQQueueName, options) if err != nil { return RabbitMqQueuesClientGetResponse{}, err @@ -197,7 +212,7 @@ func (client *RabbitMqQueuesClient) Get(ctx context.Context, rabbitMQQueueName s } // getCreateRequest creates the Get request. -func (client *RabbitMqQueuesClient) getCreateRequest(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientGetOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) getCreateRequest(ctx context.Context, rabbitMQQueueName string, _ *RabbitMqQueuesClientGetOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if rabbitMQQueueName == "" { @@ -235,30 +250,25 @@ func (client *RabbitMqQueuesClient) NewListByScopePager(options *RabbitMqQueuesC return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *RabbitMqQueuesClientListByScopeResponse) (RabbitMqQueuesClientListByScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return RabbitMqQueuesClientListByScopeResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RabbitMqQueuesClient.NewListByScopePager") + 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.listByScopeCreateRequest(ctx, options) + }, nil) if err != nil { return RabbitMqQueuesClientListByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RabbitMqQueuesClientListByScopeResponse{}, runtime.NewResponseError(resp) - } return client.listByScopeHandleResponse(resp) - }, + }, + Tracer: client.internal.Tracer(), }) } // listByScopeCreateRequest creates the ListByScope request. -func (client *RabbitMqQueuesClient) listByScopeCreateRequest(ctx context.Context, options *RabbitMqQueuesClientListByScopeOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) listByScopeCreateRequest(ctx context.Context, _ *RabbitMqQueuesClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -291,6 +301,10 @@ func (client *RabbitMqQueuesClient) listByScopeHandleResponse(resp *http.Respons // method. func (client *RabbitMqQueuesClient) ListSecrets(ctx context.Context, rabbitMQQueueName string, body map[string]any, options *RabbitMqQueuesClientListSecretsOptions) (RabbitMqQueuesClientListSecretsResponse, error) { var err error + const operationName = "RabbitMqQueuesClient.ListSecrets" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listSecretsCreateRequest(ctx, rabbitMQQueueName, body, options) if err != nil { return RabbitMqQueuesClientListSecretsResponse{}, err @@ -308,7 +322,7 @@ func (client *RabbitMqQueuesClient) ListSecrets(ctx context.Context, rabbitMQQue } // listSecretsCreateRequest creates the ListSecrets request. -func (client *RabbitMqQueuesClient) listSecretsCreateRequest(ctx context.Context, rabbitMQQueueName string, body map[string]any, options *RabbitMqQueuesClientListSecretsOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) listSecretsCreateRequest(ctx context.Context, rabbitMQQueueName string, body map[string]any, _ *RabbitMqQueuesClientListSecretsOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}/listSecrets" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if rabbitMQQueueName == "" { @@ -326,7 +340,7 @@ func (client *RabbitMqQueuesClient) listSecretsCreateRequest(ctx context.Context if err := runtime.MarshalAsJSON(req, body); err != nil { return nil, err } - return req, nil +; return req, nil } // listSecretsHandleResponse handles the ListSecrets response. @@ -354,10 +368,13 @@ func (client *RabbitMqQueuesClient) BeginUpdate(ctx context.Context, rabbitMQQue } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RabbitMqQueuesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[RabbitMqQueuesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RabbitMqQueuesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -367,6 +384,10 @@ func (client *RabbitMqQueuesClient) BeginUpdate(ctx context.Context, rabbitMQQue // Generated from API version 2023-10-01-preview func (client *RabbitMqQueuesClient) update(ctx context.Context, rabbitMQQueueName string, properties RabbitMQQueueResourceUpdate, options *RabbitMqQueuesClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "RabbitMqQueuesClient.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, rabbitMQQueueName, properties, options) if err != nil { return nil, err @@ -383,7 +404,7 @@ func (client *RabbitMqQueuesClient) update(ctx context.Context, rabbitMQQueueNam } // updateCreateRequest creates the Update request. -func (client *RabbitMqQueuesClient) updateCreateRequest(ctx context.Context, rabbitMQQueueName string, properties RabbitMQQueueResourceUpdate, options *RabbitMqQueuesClientBeginUpdateOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) updateCreateRequest(ctx context.Context, rabbitMQQueueName string, properties RabbitMQQueueResourceUpdate, _ *RabbitMqQueuesClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if rabbitMQQueueName == "" { @@ -401,6 +422,6 @@ func (client *RabbitMqQueuesClient) updateCreateRequest(ctx context.Context, rab if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } - return req, nil +; return req, nil } diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_response_types.go b/pkg/messagingrp/api/v20231001preview/zz_generated_responses.go similarity index 80% rename from pkg/messagingrp/api/v20231001preview/zz_generated_response_types.go rename to pkg/messagingrp/api/v20231001preview/zz_generated_responses.go index a038e0d8080..d97790328b1 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_response_types.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_responses.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -9,13 +6,13 @@ package v20231001preview // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { - // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. +// A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. OperationListResult } // RabbitMqQueuesClientCreateOrUpdateResponse contains the response from method RabbitMqQueuesClient.BeginCreateOrUpdate. type RabbitMqQueuesClientCreateOrUpdateResponse struct { - // RabbitMQQueue portable resource +// RabbitMQQueue portable resource RabbitMQQueueResource } @@ -26,25 +23,25 @@ type RabbitMqQueuesClientDeleteResponse struct { // RabbitMqQueuesClientGetResponse contains the response from method RabbitMqQueuesClient.Get. type RabbitMqQueuesClientGetResponse struct { - // RabbitMQQueue portable resource +// RabbitMQQueue portable resource RabbitMQQueueResource } // RabbitMqQueuesClientListByScopeResponse contains the response from method RabbitMqQueuesClient.NewListByScopePager. type RabbitMqQueuesClientListByScopeResponse struct { - // The response of a RabbitMQQueueResource list operation. +// The response of a RabbitMQQueueResource list operation. RabbitMQQueueResourceListResult } // RabbitMqQueuesClientListSecretsResponse contains the response from method RabbitMqQueuesClient.ListSecrets. type RabbitMqQueuesClientListSecretsResponse struct { - // The secret values for the given RabbitMQQueue resource +// The secret values for the given RabbitMQQueue resource RabbitMQListSecretsResult } // RabbitMqQueuesClientUpdateResponse contains the response from method RabbitMqQueuesClient.BeginUpdate. type RabbitMqQueuesClientUpdateResponse struct { - // RabbitMQQueue portable resource +// RabbitMQQueue portable resource RabbitMQQueueResource } diff --git a/pkg/messagingrp/api/v20231001preview/zz_generated_time_rfc3339.go b/pkg/messagingrp/api/v20231001preview/zz_generated_time_rfc3339.go index 948a6660cdc..bbe5fcce128 100644 --- a/pkg/messagingrp/api/v20231001preview/zz_generated_time_rfc3339.go +++ b/pkg/messagingrp/api/v20231001preview/zz_generated_time_rfc3339.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository 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. @@ -21,51 +18,78 @@ import ( +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) -// 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 +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 - if tzOffsetRegex.Match(data) { - layout = rfc3339JSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout - if tzOffsetRegex.Match(data) { +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } -func (t *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 (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + -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) { @@ -74,14 +98,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 { - if data == nil || strings.EqualFold(string(data), "null") { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || 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) }