From 5f63485735701c9125a3d6d496e24c7262da47ce Mon Sep 17 00:00:00 2001 From: ReleaseHelper Date: Fri, 10 Nov 2023 01:14:50 +0000 Subject: [PATCH 1/3] [Release] sdk/resourcemanager/confluent/armconfluent/2.0.0 generation from spec commit: db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3 --- .../confluent/armconfluent/CHANGELOG.md | 52 + .../confluent/armconfluent/access_client.go | 521 ++++++++ .../access_client_example_test.go | 390 ++++++ .../confluent/armconfluent/autorest.md | 7 +- .../confluent/armconfluent/client_factory.go | 25 +- .../confluent/armconfluent/constants.go | 7 +- .../armconfluent/fake/access_server.go | 362 ++++++ .../confluent/armconfluent/fake/internal.go | 64 + .../fake/marketplaceagreements_server.go | 146 +++ .../armconfluent/fake/organization_server.go | 353 ++++++ .../fake/organizationoperations_server.go | 96 ++ .../armconfluent/fake/server_factory.go | 99 ++ .../armconfluent/fake/time_rfc3339.go | 86 ++ .../armconfluent/fake/validations_server.go | 147 +++ .../confluent/armconfluent/go.mod | 23 +- .../confluent/armconfluent/go.sum | 48 +- .../marketplaceagreements_client.go | 56 +- ...rketplaceagreements_client_example_test.go | 12 +- .../confluent/armconfluent/models.go | 561 +++++++-- .../confluent/armconfluent/models_serde.go | 1094 ++++++++++++++++- .../confluent/armconfluent/options.go | 112 ++ .../armconfluent/organization_client.go | 171 +-- .../organization_client_example_test.go | 159 ++- .../organizationoperations_client.go | 30 +- ...anizationoperations_client_example_test.go | 4 +- .../confluent/armconfluent/response_types.go | 60 +- .../confluent/armconfluent/time_rfc3339.go | 43 +- .../armconfluent/validations_client.go | 102 +- .../validations_client_example_test.go | 101 +- 29 files changed, 4464 insertions(+), 467 deletions(-) create mode 100644 sdk/resourcemanager/confluent/armconfluent/access_client.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/access_client_example_test.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/fake/access_server.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/fake/internal.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/fake/marketplaceagreements_server.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/fake/organization_server.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/fake/organizationoperations_server.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/fake/server_factory.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/fake/validations_server.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/options.go diff --git a/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md b/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md index ad37ecec75d7..25fec089c729 100644 --- a/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md +++ b/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md @@ -1,5 +1,57 @@ # Release History +## 2.0.0 (2023-11-24) +### Breaking Changes + +- Function `timeRFC3339.MarshalText` has been removed +- Function `*timeRFC3339.Parse` has been removed +- Function `*timeRFC3339.UnmarshalText` has been removed + +### Features Added + +- New function `NewAccessClient(string, azcore.TokenCredential, *arm.ClientOptions) (*AccessClient, error)` +- New function `*AccessClient.InviteUser(context.Context, string, string, AccessInviteUserAccountModel, *AccessClientInviteUserOptions) (AccessClientInviteUserResponse, error)` +- New function `*AccessClient.ListClusters(context.Context, string, string, ListAccessRequestModel, *AccessClientListClustersOptions) (AccessClientListClustersResponse, error)` +- New function `*AccessClient.ListEnvironments(context.Context, string, string, ListAccessRequestModel, *AccessClientListEnvironmentsOptions) (AccessClientListEnvironmentsResponse, error)` +- New function `*AccessClient.ListInvitations(context.Context, string, string, ListAccessRequestModel, *AccessClientListInvitationsOptions) (AccessClientListInvitationsResponse, error)` +- New function `*AccessClient.ListRoleBindings(context.Context, string, string, ListAccessRequestModel, *AccessClientListRoleBindingsOptions) (AccessClientListRoleBindingsResponse, error)` +- New function `*AccessClient.ListServiceAccounts(context.Context, string, string, ListAccessRequestModel, *AccessClientListServiceAccountsOptions) (AccessClientListServiceAccountsResponse, error)` +- New function `*AccessClient.ListUsers(context.Context, string, string, ListAccessRequestModel, *AccessClientListUsersOptions) (AccessClientListUsersResponse, error)` +- New function `*ClientFactory.NewAccessClient() *AccessClient` +- New function `*ValidationsClient.ValidateOrganizationV2(context.Context, string, string, OrganizationResource, *ValidationsClientValidateOrganizationV2Options) (ValidationsClientValidateOrganizationV2Response, error)` +- New function `dateTimeRFC3339.MarshalText() ([]byte, error)` +- New function `*dateTimeRFC3339.Parse(string) error` +- New function `*dateTimeRFC3339.UnmarshalText([]byte) error` +- New struct `AccessInviteUserAccountModel` +- New struct `AccessInvitedUserDetails` +- New struct `AccessListClusterSuccessResponse` +- New struct `AccessListEnvironmentsSuccessResponse` +- New struct `AccessListInvitationsSuccessResponse` +- New struct `AccessListRoleBindingsSuccessResponse` +- New struct `AccessListServiceAccountsSuccessResponse` +- New struct `AccessListUsersSuccessResponse` +- New struct `ClusterByokEntity` +- New struct `ClusterConfigEntity` +- New struct `ClusterEnvironmentEntity` +- New struct `ClusterNetworkEntity` +- New struct `ClusterRecord` +- New struct `ClusterSpecEntity` +- New struct `ClusterStatusEntity` +- New struct `EnvironmentRecord` +- New struct `InvitationRecord` +- New struct `LinkOrganization` +- New struct `ListAccessRequestModel` +- New struct `ListMetadata` +- New struct `MetadataEntity` +- New struct `RoleBindingRecord` +- New struct `ServiceAccountRecord` +- New struct `UserRecord` +- New struct `ValidationResponse` +- New field `PrivateOfferID`, `PrivateOfferIDs`, `TermID` in struct `OfferDetail` +- New field `LinkOrganization` in struct `OrganizationResourceProperties` +- New field `AADEmail`, `UserPrincipalName` in struct `UserDetail` + + ## 1.1.0 (2023-03-28) ### Features Added diff --git a/sdk/resourcemanager/confluent/armconfluent/access_client.go b/sdk/resourcemanager/confluent/armconfluent/access_client.go new file mode 100644 index 000000000000..7dd45a609f39 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/access_client.go @@ -0,0 +1,521 @@ +//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 armconfluent + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AccessClient contains the methods for the Access group. +// Don't use this type directly, use NewAccessClient() instead. +type AccessClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAccessClient creates a new instance of AccessClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAccessClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AccessClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AccessClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// InviteUser - Invite user to the organization +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Organization resource name +// - body - Invite user account model +// - options - AccessClientInviteUserOptions contains the optional parameters for the AccessClient.InviteUser method. +func (client *AccessClient) InviteUser(ctx context.Context, resourceGroupName string, organizationName string, body AccessInviteUserAccountModel, options *AccessClientInviteUserOptions) (AccessClientInviteUserResponse, error) { + var err error + const operationName = "AccessClient.InviteUser" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.inviteUserCreateRequest(ctx, resourceGroupName, organizationName, body, options) + if err != nil { + return AccessClientInviteUserResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccessClientInviteUserResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccessClientInviteUserResponse{}, err + } + resp, err := client.inviteUserHandleResponse(httpResp) + return resp, err +} + +// inviteUserCreateRequest creates the InviteUser request. +func (client *AccessClient) inviteUserCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, body AccessInviteUserAccountModel, options *AccessClientInviteUserOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}/access/default/createInvitation" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-22") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// inviteUserHandleResponse handles the InviteUser response. +func (client *AccessClient) inviteUserHandleResponse(resp *http.Response) (AccessClientInviteUserResponse, error) { + result := AccessClientInviteUserResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InvitationRecord); err != nil { + return AccessClientInviteUserResponse{}, err + } + return result, nil +} + +// ListClusters - Cluster details +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Organization resource name +// - body - List Access Request Model +// - options - AccessClientListClustersOptions contains the optional parameters for the AccessClient.ListClusters method. +func (client *AccessClient) ListClusters(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListClustersOptions) (AccessClientListClustersResponse, error) { + var err error + const operationName = "AccessClient.ListClusters" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listClustersCreateRequest(ctx, resourceGroupName, organizationName, body, options) + if err != nil { + return AccessClientListClustersResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccessClientListClustersResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccessClientListClustersResponse{}, err + } + resp, err := client.listClustersHandleResponse(httpResp) + return resp, err +} + +// listClustersCreateRequest creates the ListClusters request. +func (client *AccessClient) listClustersCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListClustersOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}/access/default/listClusters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-22") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listClustersHandleResponse handles the ListClusters response. +func (client *AccessClient) listClustersHandleResponse(resp *http.Response) (AccessClientListClustersResponse, error) { + result := AccessClientListClustersResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessListClusterSuccessResponse); err != nil { + return AccessClientListClustersResponse{}, err + } + return result, nil +} + +// ListEnvironments - Environment list of an organization +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Organization resource name +// - body - List Access Request Model +// - options - AccessClientListEnvironmentsOptions contains the optional parameters for the AccessClient.ListEnvironments method. +func (client *AccessClient) ListEnvironments(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListEnvironmentsOptions) (AccessClientListEnvironmentsResponse, error) { + var err error + const operationName = "AccessClient.ListEnvironments" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listEnvironmentsCreateRequest(ctx, resourceGroupName, organizationName, body, options) + if err != nil { + return AccessClientListEnvironmentsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccessClientListEnvironmentsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccessClientListEnvironmentsResponse{}, err + } + resp, err := client.listEnvironmentsHandleResponse(httpResp) + return resp, err +} + +// listEnvironmentsCreateRequest creates the ListEnvironments request. +func (client *AccessClient) listEnvironmentsCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListEnvironmentsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}/access/default/listEnvironments" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-22") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listEnvironmentsHandleResponse handles the ListEnvironments response. +func (client *AccessClient) listEnvironmentsHandleResponse(resp *http.Response) (AccessClientListEnvironmentsResponse, error) { + result := AccessClientListEnvironmentsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessListEnvironmentsSuccessResponse); err != nil { + return AccessClientListEnvironmentsResponse{}, err + } + return result, nil +} + +// ListInvitations - Organization accounts invitation details +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Organization resource name +// - body - List Access Request Model +// - options - AccessClientListInvitationsOptions contains the optional parameters for the AccessClient.ListInvitations method. +func (client *AccessClient) ListInvitations(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListInvitationsOptions) (AccessClientListInvitationsResponse, error) { + var err error + const operationName = "AccessClient.ListInvitations" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listInvitationsCreateRequest(ctx, resourceGroupName, organizationName, body, options) + if err != nil { + return AccessClientListInvitationsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccessClientListInvitationsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccessClientListInvitationsResponse{}, err + } + resp, err := client.listInvitationsHandleResponse(httpResp) + return resp, err +} + +// listInvitationsCreateRequest creates the ListInvitations request. +func (client *AccessClient) listInvitationsCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListInvitationsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}/access/default/listInvitations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-22") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listInvitationsHandleResponse handles the ListInvitations response. +func (client *AccessClient) listInvitationsHandleResponse(resp *http.Response) (AccessClientListInvitationsResponse, error) { + result := AccessClientListInvitationsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessListInvitationsSuccessResponse); err != nil { + return AccessClientListInvitationsResponse{}, err + } + return result, nil +} + +// ListRoleBindings - Organization role bindings +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Organization resource name +// - body - List Access Request Model +// - options - AccessClientListRoleBindingsOptions contains the optional parameters for the AccessClient.ListRoleBindings method. +func (client *AccessClient) ListRoleBindings(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListRoleBindingsOptions) (AccessClientListRoleBindingsResponse, error) { + var err error + const operationName = "AccessClient.ListRoleBindings" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listRoleBindingsCreateRequest(ctx, resourceGroupName, organizationName, body, options) + if err != nil { + return AccessClientListRoleBindingsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccessClientListRoleBindingsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccessClientListRoleBindingsResponse{}, err + } + resp, err := client.listRoleBindingsHandleResponse(httpResp) + return resp, err +} + +// listRoleBindingsCreateRequest creates the ListRoleBindings request. +func (client *AccessClient) listRoleBindingsCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListRoleBindingsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}/access/default/listRoleBindings" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-22") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listRoleBindingsHandleResponse handles the ListRoleBindings response. +func (client *AccessClient) listRoleBindingsHandleResponse(resp *http.Response) (AccessClientListRoleBindingsResponse, error) { + result := AccessClientListRoleBindingsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessListRoleBindingsSuccessResponse); err != nil { + return AccessClientListRoleBindingsResponse{}, err + } + return result, nil +} + +// ListServiceAccounts - Organization service accounts details +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Organization resource name +// - body - List Access Request Model +// - options - AccessClientListServiceAccountsOptions contains the optional parameters for the AccessClient.ListServiceAccounts +// method. +func (client *AccessClient) ListServiceAccounts(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListServiceAccountsOptions) (AccessClientListServiceAccountsResponse, error) { + var err error + const operationName = "AccessClient.ListServiceAccounts" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listServiceAccountsCreateRequest(ctx, resourceGroupName, organizationName, body, options) + if err != nil { + return AccessClientListServiceAccountsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccessClientListServiceAccountsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccessClientListServiceAccountsResponse{}, err + } + resp, err := client.listServiceAccountsHandleResponse(httpResp) + return resp, err +} + +// listServiceAccountsCreateRequest creates the ListServiceAccounts request. +func (client *AccessClient) listServiceAccountsCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListServiceAccountsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}/access/default/listServiceAccounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-22") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listServiceAccountsHandleResponse handles the ListServiceAccounts response. +func (client *AccessClient) listServiceAccountsHandleResponse(resp *http.Response) (AccessClientListServiceAccountsResponse, error) { + result := AccessClientListServiceAccountsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessListServiceAccountsSuccessResponse); err != nil { + return AccessClientListServiceAccountsResponse{}, err + } + return result, nil +} + +// ListUsers - Organization users details +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Organization resource name +// - body - List Access Request Model +// - options - AccessClientListUsersOptions contains the optional parameters for the AccessClient.ListUsers method. +func (client *AccessClient) ListUsers(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListUsersOptions) (AccessClientListUsersResponse, error) { + var err error + const operationName = "AccessClient.ListUsers" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listUsersCreateRequest(ctx, resourceGroupName, organizationName, body, options) + if err != nil { + return AccessClientListUsersResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AccessClientListUsersResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccessClientListUsersResponse{}, err + } + resp, err := client.listUsersHandleResponse(httpResp) + return resp, err +} + +// listUsersCreateRequest creates the ListUsers request. +func (client *AccessClient) listUsersCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, body ListAccessRequestModel, options *AccessClientListUsersOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}/access/default/listUsers" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-22") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listUsersHandleResponse handles the ListUsers response. +func (client *AccessClient) listUsersHandleResponse(resp *http.Response) (AccessClientListUsersResponse, error) { + result := AccessClientListUsersResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessListUsersSuccessResponse); err != nil { + return AccessClientListUsersResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/confluent/armconfluent/access_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/access_client_example_test.go new file mode 100644 index 000000000000..5b0f928256b5 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/access_client_example_test.go @@ -0,0 +1,390 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfluent_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Access_UsersList.json +func ExampleAccessClient_ListUsers() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessClient().ListUsers(ctx, "myResourceGroup", "myOrganization", armconfluent.ListAccessRequestModel{ + SearchFilters: map[string]*string{ + "pageSize": to.Ptr("10"), + "pageToken": to.Ptr("asc4fts4ft"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccessListUsersSuccessResponse = armconfluent.AccessListUsersSuccessResponse{ + // Data: []*armconfluent.UserRecord{ + // { + // AuthType: to.Ptr("AUTH_TYPE_SSO"), + // Email: to.Ptr("marty.mcfly@example.com"), + // FullName: to.Ptr("Marty McFly"), + // ID: to.Ptr("dlz-f3a90de"), + // Kind: to.Ptr("User"), + // Metadata: &armconfluent.MetadataEntity{ + // CreatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // DeletedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // ResourceName: to.Ptr("crn://confluent.cloud/user=u-12345"), + // Self: to.Ptr("https://api.confluent.cloud/iam/v2/users/u-12345"), + // UpdatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // }, + // }}, + // Kind: to.Ptr("UserList"), + // Metadata: &armconfluent.ListMetadata{ + // First: to.Ptr("https://api.confluent.cloud/iam/v2/users"), + // Last: to.Ptr("https://api.confluent.cloud/iam/v2/users?page_token=bcAOehAY8F16YD84Z1wT"), + // Next: to.Ptr("https://api.confluent.cloud/iam/v2/users?page_token=UvmDWOB1iwfAIBPj6EYb"), + // Prev: to.Ptr("https://api.confluent.cloud/iam/v2/users?page_token=YIXRY97wWYmwzrax4dld"), + // TotalSize: to.Ptr[int32](123), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Access_ServiceAccountsList.json +func ExampleAccessClient_ListServiceAccounts() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessClient().ListServiceAccounts(ctx, "myResourceGroup", "myOrganization", armconfluent.ListAccessRequestModel{ + SearchFilters: map[string]*string{ + "pageSize": to.Ptr("10"), + "pageToken": to.Ptr("asc4fts4ft"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccessListServiceAccountsSuccessResponse = armconfluent.AccessListServiceAccountsSuccessResponse{ + // Data: []*armconfluent.ServiceAccountRecord{ + // { + // Description: to.Ptr("Doc's repair bot for the DeLorean"), + // DisplayName: to.Ptr("DeLorean_auto_repair"), + // ID: to.Ptr("dlz-f3a90de"), + // Kind: to.Ptr("ServiceAccount"), + // Metadata: &armconfluent.MetadataEntity{ + // CreatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // DeletedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // ResourceName: to.Ptr("crn://confluent.cloud/service-account=sa-12345"), + // Self: to.Ptr("https://api.confluent.cloud/iam/v2/service-accounts/sa-12345"), + // UpdatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // }, + // }}, + // Kind: to.Ptr("ServiceAccountList"), + // Metadata: &armconfluent.ListMetadata{ + // First: to.Ptr("https://api.confluent.cloud/iam/v2/service-accounts"), + // Last: to.Ptr("https://api.confluent.cloud/iam/v2/service-accounts?page_token=bcAOehAY8F16YD84Z1wT"), + // Next: to.Ptr("https://api.confluent.cloud/iam/v2/service-accounts?page_token=UvmDWOB1iwfAIBPj6EYb"), + // Prev: to.Ptr("https://api.confluent.cloud/iam/v2/service-accounts?page_token=YIXRY97wWYmwzrax4dld"), + // TotalSize: to.Ptr[int32](123), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Access_InvitationsList.json +func ExampleAccessClient_ListInvitations() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessClient().ListInvitations(ctx, "myResourceGroup", "myOrganization", armconfluent.ListAccessRequestModel{ + SearchFilters: map[string]*string{ + "pageSize": to.Ptr("10"), + "pageToken": to.Ptr("asc4fts4ft"), + "status": to.Ptr("INVITE_STATUS_SENT"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccessListInvitationsSuccessResponse = armconfluent.AccessListInvitationsSuccessResponse{ + // Data: []*armconfluent.InvitationRecord{ + // { + // AcceptedAt: to.Ptr("2022-07-06T17:21:33Z"), + // AuthType: to.Ptr("AUTH_TYPE_SSO"), + // Email: to.Ptr("johndoe@confluent.io"), + // ExpiresAt: to.Ptr("2022-07-07T17:22:39Z"), + // ID: to.Ptr("dlz-f3a90de"), + // Kind: to.Ptr("Invitation"), + // Metadata: &armconfluent.MetadataEntity{ + // CreatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // DeletedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // ResourceName: to.Ptr("crn://confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/invitation=i-12345"), + // Self: to.Ptr("https://api.confluent.cloud/iam/v2/invitations/i-12345"), + // UpdatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // }, + // Status: to.Ptr("INVITE_STATUS_SENT"), + // }}, + // Kind: to.Ptr("InvitationList"), + // Metadata: &armconfluent.ListMetadata{ + // First: to.Ptr("https://api.confluent.cloud/iam/v2/invitations"), + // Last: to.Ptr("https://api.confluent.cloud/iam/v2/invitations?page_token=bcAOehAY8F16YD84Z1wT"), + // Next: to.Ptr("https://api.confluent.cloud/iam/v2/invitations?page_token=UvmDWOB1iwfAIBPj6EYb"), + // Prev: to.Ptr("https://api.confluent.cloud/iam/v2/invitations?page_token=YIXRY97wWYmwzrax4dld"), + // TotalSize: to.Ptr[int32](123), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Access_InviteUser.json +func ExampleAccessClient_InviteUser() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessClient().InviteUser(ctx, "myResourceGroup", "myOrganization", armconfluent.AccessInviteUserAccountModel{ + InvitedUserDetails: &armconfluent.AccessInvitedUserDetails{ + AuthType: to.Ptr("AUTH_TYPE_SSO"), + InvitedEmail: to.Ptr("user2@onmicrosoft.com"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.InvitationRecord = armconfluent.InvitationRecord{ + // AcceptedAt: to.Ptr("2022-07-06T17:21:33Z"), + // AuthType: to.Ptr("AUTH_TYPE_SSO"), + // Email: to.Ptr("johndoe@confluent.io"), + // ExpiresAt: to.Ptr("2022-07-07T17:22:39Z"), + // ID: to.Ptr("dlz-f3a90de"), + // Kind: to.Ptr("Invitation"), + // Metadata: &armconfluent.MetadataEntity{ + // CreatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // DeletedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // ResourceName: to.Ptr("crn://confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/invitation=i-12345"), + // Self: to.Ptr("https://api.confluent.cloud/iam/v2/invitations/i-12345"), + // UpdatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // }, + // Status: to.Ptr("INVITE_STATUS_SENT"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Access_EnvironmentList.json +func ExampleAccessClient_ListEnvironments() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessClient().ListEnvironments(ctx, "myResourceGroup", "myOrganization", armconfluent.ListAccessRequestModel{ + SearchFilters: map[string]*string{ + "pageSize": to.Ptr("10"), + "pageToken": to.Ptr("asc4fts4ft"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccessListEnvironmentsSuccessResponse = armconfluent.AccessListEnvironmentsSuccessResponse{ + // Data: []*armconfluent.EnvironmentRecord{ + // { + // DisplayName: to.Ptr("prod-finance01"), + // ID: to.Ptr("dlz-f3a90de"), + // Kind: to.Ptr("Environment"), + // Metadata: &armconfluent.MetadataEntity{ + // CreatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // DeletedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // ResourceName: to.Ptr("crn://confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/environment=e-12345"), + // Self: to.Ptr("https://api.confluent.cloud/org/v2/environments/e-12345"), + // UpdatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // }, + // }}, + // Kind: to.Ptr("EnvironmentList"), + // Metadata: &armconfluent.ListMetadata{ + // First: to.Ptr("https://api.confluent.cloud/org/v2/environments"), + // Last: to.Ptr("https://api.confluent.cloud/org/v2/environments?page_token=bcAOehAY8F16YD84Z1wT"), + // Next: to.Ptr("https://api.confluent.cloud/org/v2/environments?page_token=UvmDWOB1iwfAIBPj6EYb"), + // Prev: to.Ptr("https://api.confluent.cloud/org/v2/environments?page_token=YIXRY97wWYmwzrax4dld"), + // TotalSize: to.Ptr[int32](123), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Access_ClusterList.json +func ExampleAccessClient_ListClusters() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessClient().ListClusters(ctx, "myResourceGroup", "myOrganization", armconfluent.ListAccessRequestModel{ + SearchFilters: map[string]*string{ + "pageSize": to.Ptr("10"), + "pageToken": to.Ptr("asc4fts4ft"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccessListClusterSuccessResponse = armconfluent.AccessListClusterSuccessResponse{ + // Data: []*armconfluent.ClusterRecord{ + // { + // ID: to.Ptr("dlz-f3a90de"), + // Kind: to.Ptr("Cluster"), + // Metadata: &armconfluent.MetadataEntity{ + // CreatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // DeletedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // ResourceName: to.Ptr("crn://confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/environment=env-abc123/cloud-cluster=lkc-12345"), + // Self: to.Ptr("https://api.confluent.cloud/cmk/v2/clusters/lkc-12345"), + // UpdatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // }, + // Spec: &armconfluent.ClusterSpecEntity{ + // APIEndpoint: to.Ptr("https://pkac-00000.us-west-2.aws.confluent.cloud"), + // Availability: to.Ptr("SINGLE_ZONE"), + // Byok: &armconfluent.ClusterByokEntity{ + // ID: to.Ptr("cck-00000"), + // Related: to.Ptr("https://api.confluent.cloud/byok/v1/keys/cck-00000"), + // ResourceName: to.Ptr("https://api.confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/key=cck-00000"), + // }, + // Cloud: to.Ptr("GCP"), + // Config: &armconfluent.ClusterConfigEntity{ + // Kind: to.Ptr("Basic"), + // }, + // DisplayName: to.Ptr("ProdKafkaCluster"), + // Environment: &armconfluent.ClusterEnvironmentEntity{ + // Environment: to.Ptr("string"), + // ID: to.Ptr("env-00000"), + // Related: to.Ptr("https://api.confluent.cloud/v2/environments/env-00000"), + // ResourceName: to.Ptr("https://api.confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/environment=env-00000"), + // }, + // HTTPEndpoint: to.Ptr("https://lkc-00000-00000.us-central1.gcp.glb.confluent.cloud"), + // KafkaBootstrapEndpoint: to.Ptr("lkc-00000-00000.us-central1.gcp.glb.confluent.cloud:9092"), + // Network: &armconfluent.ClusterNetworkEntity{ + // Environment: to.Ptr("string"), + // ID: to.Ptr("n-00000"), + // Related: to.Ptr("https://api.confluent.cloud/networking/v1/networks/n-00000"), + // ResourceName: to.Ptr("https://api.confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/environment=env-abc123/network=n-00000"), + // }, + // Region: to.Ptr("us-east4"), + // }, + // Status: &armconfluent.ClusterStatusEntity{ + // Cku: to.Ptr[int32](2), + // Phase: to.Ptr("PROVISIONED"), + // }, + // }}, + // Kind: to.Ptr("ClusterList"), + // Metadata: &armconfluent.ListMetadata{ + // First: to.Ptr("https://api.confluent.cloud/cmk/v2/clusters"), + // Last: to.Ptr("https://api.confluent.cloud/cmk/v2/clusters?page_token=bcAOehAY8F16YD84Z1wT"), + // Next: to.Ptr("https://api.confluent.cloud/cmk/v2/clusters?page_token=UvmDWOB1iwfAIBPj6EYb"), + // Prev: to.Ptr("https://api.confluent.cloud/cmk/v2/clusters?page_token=YIXRY97wWYmwzrax4dld"), + // TotalSize: to.Ptr[int32](123), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Access_RoleBindingList.json +func ExampleAccessClient_ListRoleBindings() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessClient().ListRoleBindings(ctx, "myResourceGroup", "myOrganization", armconfluent.ListAccessRequestModel{ + SearchFilters: map[string]*string{ + "pageSize": to.Ptr("10"), + "pageToken": to.Ptr("asc4fts4ft"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccessListRoleBindingsSuccessResponse = armconfluent.AccessListRoleBindingsSuccessResponse{ + // Data: []*armconfluent.RoleBindingRecord{ + // { + // CrnPattern: to.Ptr("crn://confluent.cloud/organization=1111aaaa-11aa-11aa-11aa-111111aaaaaa/environment=env-aaa1111/cloud-cluster=lkc-1111aaa"), + // ID: to.Ptr("dlz-f3a90de"), + // Kind: to.Ptr("RoleBinding"), + // Metadata: &armconfluent.MetadataEntity{ + // CreatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // DeletedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // ResourceName: to.Ptr("crn://confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/role-binding=rb-12345"), + // Self: to.Ptr("https://api.confluent.cloud/iam/v2/role-bindings/rb-12345"), + // UpdatedAt: to.Ptr("2006-01-02T15:04:05-07:00"), + // }, + // Principal: to.Ptr("User:u-111aaa"), + // RoleName: to.Ptr("CloudClusterAdmin"), + // }}, + // Kind: to.Ptr("RoleBindingList"), + // Metadata: &armconfluent.ListMetadata{ + // First: to.Ptr("https://api.confluent.cloud/iam/v2/role-bindings"), + // Last: to.Ptr("https://api.confluent.cloud/iam/v2/role-bindings?page_token=bcAOehAY8F16YD84Z1wT"), + // Next: to.Ptr("https://api.confluent.cloud/iam/v2/role-bindings?page_token=UvmDWOB1iwfAIBPj6EYb"), + // Prev: to.Ptr("https://api.confluent.cloud/iam/v2/role-bindings?page_token=YIXRY97wWYmwzrax4dld"), + // TotalSize: to.Ptr[int32](123), + // }, + // } +} diff --git a/sdk/resourcemanager/confluent/armconfluent/autorest.md b/sdk/resourcemanager/confluent/armconfluent/autorest.md index d9a2d1f6e554..05374c4b4882 100644 --- a/sdk/resourcemanager/confluent/armconfluent/autorest.md +++ b/sdk/resourcemanager/confluent/armconfluent/autorest.md @@ -5,8 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.0 +module-version: 2.0.0 +tag: package-2023-08-22 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/confluent/armconfluent/client_factory.go b/sdk/resourcemanager/confluent/armconfluent/client_factory.go index 46213fb3ce38..9801edc8ec8a 100644 --- a/sdk/resourcemanager/confluent/armconfluent/client_factory.go +++ b/sdk/resourcemanager/confluent/armconfluent/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 armconfluent @@ -24,11 +23,11 @@ type ClientFactory struct { // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - Microsoft Azure subscription id +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - 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,21 +37,31 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } -func (c *ClientFactory) NewMarketplaceAgreementsClient() *MarketplaceAgreementsClient { - subClient, _ := NewMarketplaceAgreementsClient(c.subscriptionID, c.credential, c.options) +// NewAccessClient creates a new instance of AccessClient. +func (c *ClientFactory) NewAccessClient() *AccessClient { + subClient, _ := NewAccessClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOrganizationOperationsClient() *OrganizationOperationsClient { - subClient, _ := NewOrganizationOperationsClient(c.credential, c.options) +// NewMarketplaceAgreementsClient creates a new instance of MarketplaceAgreementsClient. +func (c *ClientFactory) NewMarketplaceAgreementsClient() *MarketplaceAgreementsClient { + subClient, _ := NewMarketplaceAgreementsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewOrganizationClient creates a new instance of OrganizationClient. func (c *ClientFactory) NewOrganizationClient() *OrganizationClient { subClient, _ := NewOrganizationClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewOrganizationOperationsClient creates a new instance of OrganizationOperationsClient. +func (c *ClientFactory) NewOrganizationOperationsClient() *OrganizationOperationsClient { + subClient, _ := NewOrganizationOperationsClient(c.credential, c.options) + return subClient +} + +// NewValidationsClient creates a new instance of ValidationsClient. func (c *ClientFactory) NewValidationsClient() *ValidationsClient { subClient, _ := NewValidationsClient(c.subscriptionID, c.credential, c.options) return subClient diff --git a/sdk/resourcemanager/confluent/armconfluent/constants.go b/sdk/resourcemanager/confluent/armconfluent/constants.go index 7eafaba100a8..f68c7db2343f 100644 --- a/sdk/resourcemanager/confluent/armconfluent/constants.go +++ b/sdk/resourcemanager/confluent/armconfluent/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 armconfluent const ( - moduleName = "armconfluent" - moduleVersion = "v1.1.0" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" + moduleVersion = "v2.0.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/confluent/armconfluent/fake/access_server.go b/sdk/resourcemanager/confluent/armconfluent/fake/access_server.go new file mode 100644 index 000000000000..b7565c79009b --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/fake/access_server.go @@ -0,0 +1,362 @@ +//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/confluent/armconfluent" + "net/http" + "net/url" + "regexp" +) + +// AccessServer is a fake server for instances of the armconfluent.AccessClient type. +type AccessServer struct { + // InviteUser is the fake for method AccessClient.InviteUser + // HTTP status codes to indicate success: http.StatusOK + InviteUser func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.AccessInviteUserAccountModel, options *armconfluent.AccessClientInviteUserOptions) (resp azfake.Responder[armconfluent.AccessClientInviteUserResponse], errResp azfake.ErrorResponder) + + // ListClusters is the fake for method AccessClient.ListClusters + // HTTP status codes to indicate success: http.StatusOK + ListClusters func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.ListAccessRequestModel, options *armconfluent.AccessClientListClustersOptions) (resp azfake.Responder[armconfluent.AccessClientListClustersResponse], errResp azfake.ErrorResponder) + + // ListEnvironments is the fake for method AccessClient.ListEnvironments + // HTTP status codes to indicate success: http.StatusOK + ListEnvironments func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.ListAccessRequestModel, options *armconfluent.AccessClientListEnvironmentsOptions) (resp azfake.Responder[armconfluent.AccessClientListEnvironmentsResponse], errResp azfake.ErrorResponder) + + // ListInvitations is the fake for method AccessClient.ListInvitations + // HTTP status codes to indicate success: http.StatusOK + ListInvitations func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.ListAccessRequestModel, options *armconfluent.AccessClientListInvitationsOptions) (resp azfake.Responder[armconfluent.AccessClientListInvitationsResponse], errResp azfake.ErrorResponder) + + // ListRoleBindings is the fake for method AccessClient.ListRoleBindings + // HTTP status codes to indicate success: http.StatusOK + ListRoleBindings func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.ListAccessRequestModel, options *armconfluent.AccessClientListRoleBindingsOptions) (resp azfake.Responder[armconfluent.AccessClientListRoleBindingsResponse], errResp azfake.ErrorResponder) + + // ListServiceAccounts is the fake for method AccessClient.ListServiceAccounts + // HTTP status codes to indicate success: http.StatusOK + ListServiceAccounts func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.ListAccessRequestModel, options *armconfluent.AccessClientListServiceAccountsOptions) (resp azfake.Responder[armconfluent.AccessClientListServiceAccountsResponse], errResp azfake.ErrorResponder) + + // ListUsers is the fake for method AccessClient.ListUsers + // HTTP status codes to indicate success: http.StatusOK + ListUsers func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.ListAccessRequestModel, options *armconfluent.AccessClientListUsersOptions) (resp azfake.Responder[armconfluent.AccessClientListUsersResponse], errResp azfake.ErrorResponder) +} + +// NewAccessServerTransport creates a new instance of AccessServerTransport with the provided implementation. +// The returned AccessServerTransport instance is connected to an instance of armconfluent.AccessClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAccessServerTransport(srv *AccessServer) *AccessServerTransport { + return &AccessServerTransport{srv: srv} +} + +// AccessServerTransport connects instances of armconfluent.AccessClient to instances of AccessServer. +// Don't use this type directly, use NewAccessServerTransport instead. +type AccessServerTransport struct { + srv *AccessServer +} + +// Do implements the policy.Transporter interface for AccessServerTransport. +func (a *AccessServerTransport) 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 "AccessClient.InviteUser": + resp, err = a.dispatchInviteUser(req) + case "AccessClient.ListClusters": + resp, err = a.dispatchListClusters(req) + case "AccessClient.ListEnvironments": + resp, err = a.dispatchListEnvironments(req) + case "AccessClient.ListInvitations": + resp, err = a.dispatchListInvitations(req) + case "AccessClient.ListRoleBindings": + resp, err = a.dispatchListRoleBindings(req) + case "AccessClient.ListServiceAccounts": + resp, err = a.dispatchListServiceAccounts(req) + case "AccessClient.ListUsers": + resp, err = a.dispatchListUsers(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AccessServerTransport) dispatchInviteUser(req *http.Request) (*http.Response, error) { + if a.srv.InviteUser == nil { + return nil, &nonRetriableError{errors.New("fake for method InviteUser not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/access/default/createInvitation` + 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[armconfluent.AccessInviteUserAccountModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.InviteUser(req.Context(), resourceGroupNameParam, organizationNameParam, 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).InvitationRecord, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccessServerTransport) dispatchListClusters(req *http.Request) (*http.Response, error) { + if a.srv.ListClusters == nil { + return nil, &nonRetriableError{errors.New("fake for method ListClusters not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/access/default/listClusters` + 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[armconfluent.ListAccessRequestModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListClusters(req.Context(), resourceGroupNameParam, organizationNameParam, 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).AccessListClusterSuccessResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccessServerTransport) dispatchListEnvironments(req *http.Request) (*http.Response, error) { + if a.srv.ListEnvironments == nil { + return nil, &nonRetriableError{errors.New("fake for method ListEnvironments not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/access/default/listEnvironments` + 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[armconfluent.ListAccessRequestModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListEnvironments(req.Context(), resourceGroupNameParam, organizationNameParam, 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).AccessListEnvironmentsSuccessResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccessServerTransport) dispatchListInvitations(req *http.Request) (*http.Response, error) { + if a.srv.ListInvitations == nil { + return nil, &nonRetriableError{errors.New("fake for method ListInvitations not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/access/default/listInvitations` + 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[armconfluent.ListAccessRequestModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListInvitations(req.Context(), resourceGroupNameParam, organizationNameParam, 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).AccessListInvitationsSuccessResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccessServerTransport) dispatchListRoleBindings(req *http.Request) (*http.Response, error) { + if a.srv.ListRoleBindings == nil { + return nil, &nonRetriableError{errors.New("fake for method ListRoleBindings not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/access/default/listRoleBindings` + 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[armconfluent.ListAccessRequestModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListRoleBindings(req.Context(), resourceGroupNameParam, organizationNameParam, 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).AccessListRoleBindingsSuccessResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccessServerTransport) dispatchListServiceAccounts(req *http.Request) (*http.Response, error) { + if a.srv.ListServiceAccounts == nil { + return nil, &nonRetriableError{errors.New("fake for method ListServiceAccounts not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/access/default/listServiceAccounts` + 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[armconfluent.ListAccessRequestModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListServiceAccounts(req.Context(), resourceGroupNameParam, organizationNameParam, 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).AccessListServiceAccountsSuccessResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccessServerTransport) dispatchListUsers(req *http.Request) (*http.Response, error) { + if a.srv.ListUsers == nil { + return nil, &nonRetriableError{errors.New("fake for method ListUsers not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/access/default/listUsers` + 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[armconfluent.ListAccessRequestModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListUsers(req.Context(), resourceGroupNameParam, organizationNameParam, 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).AccessListUsersSuccessResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/confluent/armconfluent/fake/internal.go b/sdk/resourcemanager/confluent/armconfluent/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/fake/internal.go @@ -0,0 +1,64 @@ +//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" + "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 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/confluent/armconfluent/fake/marketplaceagreements_server.go b/sdk/resourcemanager/confluent/armconfluent/fake/marketplaceagreements_server.go new file mode 100644 index 000000000000..f99fc7002c21 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/fake/marketplaceagreements_server.go @@ -0,0 +1,146 @@ +//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/confluent/armconfluent" + "net/http" + "reflect" + "regexp" +) + +// MarketplaceAgreementsServer is a fake server for instances of the armconfluent.MarketplaceAgreementsClient type. +type MarketplaceAgreementsServer struct { + // Create is the fake for method MarketplaceAgreementsClient.Create + // HTTP status codes to indicate success: http.StatusOK + Create func(ctx context.Context, options *armconfluent.MarketplaceAgreementsClientCreateOptions) (resp azfake.Responder[armconfluent.MarketplaceAgreementsClientCreateResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method MarketplaceAgreementsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armconfluent.MarketplaceAgreementsClientListOptions) (resp azfake.PagerResponder[armconfluent.MarketplaceAgreementsClientListResponse]) +} + +// NewMarketplaceAgreementsServerTransport creates a new instance of MarketplaceAgreementsServerTransport with the provided implementation. +// The returned MarketplaceAgreementsServerTransport instance is connected to an instance of armconfluent.MarketplaceAgreementsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMarketplaceAgreementsServerTransport(srv *MarketplaceAgreementsServer) *MarketplaceAgreementsServerTransport { + return &MarketplaceAgreementsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armconfluent.MarketplaceAgreementsClientListResponse]](), + } +} + +// MarketplaceAgreementsServerTransport connects instances of armconfluent.MarketplaceAgreementsClient to instances of MarketplaceAgreementsServer. +// Don't use this type directly, use NewMarketplaceAgreementsServerTransport instead. +type MarketplaceAgreementsServerTransport struct { + srv *MarketplaceAgreementsServer + newListPager *tracker[azfake.PagerResponder[armconfluent.MarketplaceAgreementsClientListResponse]] +} + +// Do implements the policy.Transporter interface for MarketplaceAgreementsServerTransport. +func (m *MarketplaceAgreementsServerTransport) 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 "MarketplaceAgreementsClient.Create": + resp, err = m.dispatchCreate(req) + case "MarketplaceAgreementsClient.NewListPager": + resp, err = m.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MarketplaceAgreementsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if m.srv.Create == nil { + return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/agreements/default` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armconfluent.AgreementResource](req) + if err != nil { + return nil, err + } + var options *armconfluent.MarketplaceAgreementsClientCreateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armconfluent.MarketplaceAgreementsClientCreateOptions{ + Body: &body, + } + } + respr, errRespr := m.srv.Create(req.Context(), 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).AgreementResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *MarketplaceAgreementsServerTransport) 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~%@]+)/providers/Microsoft\.Confluent/agreements` + 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.NewListPager(nil) + newListPager = &resp + m.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armconfluent.MarketplaceAgreementsClientListResponse, 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 +} diff --git a/sdk/resourcemanager/confluent/armconfluent/fake/organization_server.go b/sdk/resourcemanager/confluent/armconfluent/fake/organization_server.go new file mode 100644 index 000000000000..779dbcaeb3ee --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/fake/organization_server.go @@ -0,0 +1,353 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// OrganizationServer is a fake server for instances of the armconfluent.OrganizationClient type. +type OrganizationServer struct { + // BeginCreate is the fake for method OrganizationClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, organizationName string, options *armconfluent.OrganizationClientBeginCreateOptions) (resp azfake.PollerResponder[armconfluent.OrganizationClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method OrganizationClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, organizationName string, options *armconfluent.OrganizationClientBeginDeleteOptions) (resp azfake.PollerResponder[armconfluent.OrganizationClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method OrganizationClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, organizationName string, options *armconfluent.OrganizationClientGetOptions) (resp azfake.Responder[armconfluent.OrganizationClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method OrganizationClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armconfluent.OrganizationClientListByResourceGroupOptions) (resp azfake.PagerResponder[armconfluent.OrganizationClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method OrganizationClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armconfluent.OrganizationClientListBySubscriptionOptions) (resp azfake.PagerResponder[armconfluent.OrganizationClientListBySubscriptionResponse]) + + // Update is the fake for method OrganizationClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, organizationName string, options *armconfluent.OrganizationClientUpdateOptions) (resp azfake.Responder[armconfluent.OrganizationClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewOrganizationServerTransport creates a new instance of OrganizationServerTransport with the provided implementation. +// The returned OrganizationServerTransport instance is connected to an instance of armconfluent.OrganizationClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOrganizationServerTransport(srv *OrganizationServer) *OrganizationServerTransport { + return &OrganizationServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armconfluent.OrganizationClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armconfluent.OrganizationClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armconfluent.OrganizationClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armconfluent.OrganizationClientListBySubscriptionResponse]](), + } +} + +// OrganizationServerTransport connects instances of armconfluent.OrganizationClient to instances of OrganizationServer. +// Don't use this type directly, use NewOrganizationServerTransport instead. +type OrganizationServerTransport struct { + srv *OrganizationServer + beginCreate *tracker[azfake.PollerResponder[armconfluent.OrganizationClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armconfluent.OrganizationClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armconfluent.OrganizationClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armconfluent.OrganizationClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for OrganizationServerTransport. +func (o *OrganizationServerTransport) 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 "OrganizationClient.BeginCreate": + resp, err = o.dispatchBeginCreate(req) + case "OrganizationClient.BeginDelete": + resp, err = o.dispatchBeginDelete(req) + case "OrganizationClient.Get": + resp, err = o.dispatchGet(req) + case "OrganizationClient.NewListByResourceGroupPager": + resp, err = o.dispatchNewListByResourceGroupPager(req) + case "OrganizationClient.NewListBySubscriptionPager": + resp, err = o.dispatchNewListBySubscriptionPager(req) + case "OrganizationClient.Update": + resp, err = o.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OrganizationServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if o.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := o.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?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[armconfluent.OrganizationResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + var options *armconfluent.OrganizationClientBeginCreateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armconfluent.OrganizationClientBeginCreateOptions{ + Body: &body, + } + } + respr, errRespr := o.srv.BeginCreate(req.Context(), resourceGroupNameParam, organizationNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + o.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + o.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + o.beginCreate.remove(req) + } + + return resp, nil +} + +func (o *OrganizationServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if o.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := o.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations/(?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 + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.BeginDelete(req.Context(), resourceGroupNameParam, organizationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + o.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) { + o.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) { + o.beginDelete.remove(req) + } + + return resp, nil +} + +func (o *OrganizationServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.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\.Confluent/organizations/(?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 + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), resourceGroupNameParam, organizationNameParam, 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).OrganizationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OrganizationServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := o.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations` + 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 := o.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + o.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armconfluent.OrganizationClientListByResourceGroupResponse, 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) { + o.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + o.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (o *OrganizationServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := o.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/organizations` + 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 := o.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + o.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armconfluent.OrganizationClientListBySubscriptionResponse, 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) { + o.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + o.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (o *OrganizationServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if o.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\.Confluent/organizations/(?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[armconfluent.OrganizationResourceUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + var options *armconfluent.OrganizationClientUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armconfluent.OrganizationClientUpdateOptions{ + Body: &body, + } + } + respr, errRespr := o.srv.Update(req.Context(), resourceGroupNameParam, organizationNameParam, 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).OrganizationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/confluent/armconfluent/fake/organizationoperations_server.go b/sdk/resourcemanager/confluent/armconfluent/fake/organizationoperations_server.go new file mode 100644 index 000000000000..038a8328c8a6 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/fake/organizationoperations_server.go @@ -0,0 +1,96 @@ +//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/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" + "net/http" +) + +// OrganizationOperationsServer is a fake server for instances of the armconfluent.OrganizationOperationsClient type. +type OrganizationOperationsServer struct { + // NewListPager is the fake for method OrganizationOperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armconfluent.OrganizationOperationsClientListOptions) (resp azfake.PagerResponder[armconfluent.OrganizationOperationsClientListResponse]) +} + +// NewOrganizationOperationsServerTransport creates a new instance of OrganizationOperationsServerTransport with the provided implementation. +// The returned OrganizationOperationsServerTransport instance is connected to an instance of armconfluent.OrganizationOperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOrganizationOperationsServerTransport(srv *OrganizationOperationsServer) *OrganizationOperationsServerTransport { + return &OrganizationOperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armconfluent.OrganizationOperationsClientListResponse]](), + } +} + +// OrganizationOperationsServerTransport connects instances of armconfluent.OrganizationOperationsClient to instances of OrganizationOperationsServer. +// Don't use this type directly, use NewOrganizationOperationsServerTransport instead. +type OrganizationOperationsServerTransport struct { + srv *OrganizationOperationsServer + newListPager *tracker[azfake.PagerResponder[armconfluent.OrganizationOperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OrganizationOperationsServerTransport. +func (o *OrganizationOperationsServerTransport) 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 "OrganizationOperationsClient.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 *OrganizationOperationsServerTransport) 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 *armconfluent.OrganizationOperationsClientListResponse, 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 +} diff --git a/sdk/resourcemanager/confluent/armconfluent/fake/server_factory.go b/sdk/resourcemanager/confluent/armconfluent/fake/server_factory.go new file mode 100644 index 000000000000..56d8acce5a91 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/fake/server_factory.go @@ -0,0 +1,99 @@ +//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 armconfluent.ClientFactory type. +type ServerFactory struct { + AccessServer AccessServer + MarketplaceAgreementsServer MarketplaceAgreementsServer + OrganizationServer OrganizationServer + OrganizationOperationsServer OrganizationOperationsServer + ValidationsServer ValidationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armconfluent.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 armconfluent.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trAccessServer *AccessServerTransport + trMarketplaceAgreementsServer *MarketplaceAgreementsServerTransport + trOrganizationServer *OrganizationServerTransport + trOrganizationOperationsServer *OrganizationOperationsServerTransport + trValidationsServer *ValidationsServerTransport +} + +// 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 "AccessClient": + initServer(s, &s.trAccessServer, func() *AccessServerTransport { return NewAccessServerTransport(&s.srv.AccessServer) }) + resp, err = s.trAccessServer.Do(req) + case "MarketplaceAgreementsClient": + initServer(s, &s.trMarketplaceAgreementsServer, func() *MarketplaceAgreementsServerTransport { + return NewMarketplaceAgreementsServerTransport(&s.srv.MarketplaceAgreementsServer) + }) + resp, err = s.trMarketplaceAgreementsServer.Do(req) + case "OrganizationClient": + initServer(s, &s.trOrganizationServer, func() *OrganizationServerTransport { return NewOrganizationServerTransport(&s.srv.OrganizationServer) }) + resp, err = s.trOrganizationServer.Do(req) + case "OrganizationOperationsClient": + initServer(s, &s.trOrganizationOperationsServer, func() *OrganizationOperationsServerTransport { + return NewOrganizationOperationsServerTransport(&s.srv.OrganizationOperationsServer) + }) + resp, err = s.trOrganizationOperationsServer.Do(req) + case "ValidationsClient": + initServer(s, &s.trValidationsServer, func() *ValidationsServerTransport { return NewValidationsServerTransport(&s.srv.ValidationsServer) }) + resp, err = s.trValidationsServer.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/confluent/armconfluent/fake/time_rfc3339.go b/sdk/resourcemanager/confluent/armconfluent/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/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/confluent/armconfluent/fake/validations_server.go b/sdk/resourcemanager/confluent/armconfluent/fake/validations_server.go new file mode 100644 index 000000000000..a9b6adfb7749 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/fake/validations_server.go @@ -0,0 +1,147 @@ +//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/confluent/armconfluent" + "net/http" + "net/url" + "regexp" +) + +// ValidationsServer is a fake server for instances of the armconfluent.ValidationsClient type. +type ValidationsServer struct { + // ValidateOrganization is the fake for method ValidationsClient.ValidateOrganization + // HTTP status codes to indicate success: http.StatusOK + ValidateOrganization func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.OrganizationResource, options *armconfluent.ValidationsClientValidateOrganizationOptions) (resp azfake.Responder[armconfluent.ValidationsClientValidateOrganizationResponse], errResp azfake.ErrorResponder) + + // ValidateOrganizationV2 is the fake for method ValidationsClient.ValidateOrganizationV2 + // HTTP status codes to indicate success: http.StatusOK + ValidateOrganizationV2 func(ctx context.Context, resourceGroupName string, organizationName string, body armconfluent.OrganizationResource, options *armconfluent.ValidationsClientValidateOrganizationV2Options) (resp azfake.Responder[armconfluent.ValidationsClientValidateOrganizationV2Response], errResp azfake.ErrorResponder) +} + +// NewValidationsServerTransport creates a new instance of ValidationsServerTransport with the provided implementation. +// The returned ValidationsServerTransport instance is connected to an instance of armconfluent.ValidationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewValidationsServerTransport(srv *ValidationsServer) *ValidationsServerTransport { + return &ValidationsServerTransport{srv: srv} +} + +// ValidationsServerTransport connects instances of armconfluent.ValidationsClient to instances of ValidationsServer. +// Don't use this type directly, use NewValidationsServerTransport instead. +type ValidationsServerTransport struct { + srv *ValidationsServer +} + +// Do implements the policy.Transporter interface for ValidationsServerTransport. +func (v *ValidationsServerTransport) 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 "ValidationsClient.ValidateOrganization": + resp, err = v.dispatchValidateOrganization(req) + case "ValidationsClient.ValidateOrganizationV2": + resp, err = v.dispatchValidateOrganizationV2(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *ValidationsServerTransport) dispatchValidateOrganization(req *http.Request) (*http.Response, error) { + if v.srv.ValidateOrganization == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateOrganization not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/validations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/orgvalidate` + 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[armconfluent.OrganizationResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.ValidateOrganization(req.Context(), resourceGroupNameParam, organizationNameParam, 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).OrganizationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *ValidationsServerTransport) dispatchValidateOrganizationV2(req *http.Request) (*http.Response, error) { + if v.srv.ValidateOrganizationV2 == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateOrganizationV2 not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Confluent/validations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/orgvalidateV2` + 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[armconfluent.OrganizationResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.ValidateOrganizationV2(req.Context(), resourceGroupNameParam, organizationNameParam, 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).ValidationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/confluent/armconfluent/go.mod b/sdk/resourcemanager/confluent/armconfluent/go.mod index bed0f8d841ed..24190a237ff8 100644 --- a/sdk/resourcemanager/confluent/armconfluent/go.mod +++ b/sdk/resourcemanager/confluent/armconfluent/go.mod @@ -1,21 +1,22 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2 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 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent v1.1.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/confluent/armconfluent/go.sum b/sdk/resourcemanager/confluent/armconfluent/go.sum index 8ba445a8c4da..c02253b17e0c 100644 --- a/sdk/resourcemanager/confluent/armconfluent/go.sum +++ b/sdk/resourcemanager/confluent/armconfluent/go.sum @@ -1,31 +1,33 @@ -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/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent v1.1.0 h1:dFEPMqZ4Dn+y//QuFAeGnHTeQPZj3B8ezD3DdoRt9Po= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent v1.1.0/go.mod h1:Pu4wYu9Y3o/2IGMNpb9uw/Dx2bwz69WtDbZB+QfgozU= +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/confluent/armconfluent/marketplaceagreements_client.go b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client.go index aef906962960..1cbd292b5fa4 100644 --- a/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client.go +++ b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_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 armconfluent @@ -29,11 +28,11 @@ type MarketplaceAgreementsClient struct { } // NewMarketplaceAgreementsClient creates a new instance of MarketplaceAgreementsClient with the specified values. -// - subscriptionID - Microsoft Azure subscription id +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMarketplaceAgreementsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MarketplaceAgreementsClient, error) { - cl, err := arm.NewClient(moduleName+".MarketplaceAgreementsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,22 +46,29 @@ func NewMarketplaceAgreementsClient(subscriptionID string, credential azcore.Tok // Create - Create Confluent Marketplace agreement in the subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-12-01 +// Generated from API version 2023-08-22 // - options - MarketplaceAgreementsClientCreateOptions contains the optional parameters for the MarketplaceAgreementsClient.Create // method. func (client *MarketplaceAgreementsClient) Create(ctx context.Context, options *MarketplaceAgreementsClientCreateOptions) (MarketplaceAgreementsClientCreateResponse, error) { + var err error + const operationName = "MarketplaceAgreementsClient.Create" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, options) if err != nil { return MarketplaceAgreementsClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MarketplaceAgreementsClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MarketplaceAgreementsClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -77,11 +83,14 @@ func (client *MarketplaceAgreementsClient) createCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -97,7 +106,7 @@ func (client *MarketplaceAgreementsClient) createHandleResponse(resp *http.Respo // NewListPager - List Confluent marketplace agreements in the subscription. // -// Generated from API version 2021-12-01 +// Generated from API version 2023-08-22 // - options - MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.NewListPager // method. func (client *MarketplaceAgreementsClient) NewListPager(options *MarketplaceAgreementsClientListOptions) *runtime.Pager[MarketplaceAgreementsClientListResponse] { @@ -106,25 +115,20 @@ func (client *MarketplaceAgreementsClient) NewListPager(options *MarketplaceAgre return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MarketplaceAgreementsClientListResponse) (MarketplaceAgreementsClientListResponse, 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) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MarketplaceAgreementsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return MarketplaceAgreementsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MarketplaceAgreementsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MarketplaceAgreementsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -140,7 +144,7 @@ func (client *MarketplaceAgreementsClient) listCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go index 849f897ccbf7..a400cc0c9bdd 100644 --- a/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/MarketplaceAgreements_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/MarketplaceAgreements_List.json func ExampleMarketplaceAgreementsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -52,7 +52,7 @@ func ExampleMarketplaceAgreementsClient_NewListPager() { // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink1"), // Product: to.Ptr("offid1"), // Publisher: to.Ptr("pubid1"), - // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t}()), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.121Z"); return t}()), // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), // }, // }, @@ -67,7 +67,7 @@ func ExampleMarketplaceAgreementsClient_NewListPager() { // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink2"), // Product: to.Ptr("offid2"), // Publisher: to.Ptr("pubid2"), - // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-14T11:33:07.12132Z"); return t}()), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-14T11:33:07.121Z"); return t}()), // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), // }, // }}, @@ -75,7 +75,7 @@ func ExampleMarketplaceAgreementsClient_NewListPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/MarketplaceAgreements_Create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/MarketplaceAgreements_Create.json func ExampleMarketplaceAgreementsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -104,7 +104,7 @@ func ExampleMarketplaceAgreementsClient_Create() { // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink1"), // Product: to.Ptr("offid1"), // Publisher: to.Ptr("pubid1"), - // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-05T17:33:07.12132Z"); return t}()), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-05T17:33:07.121Z"); return t}()), // Signature: to.Ptr("YKWOQOKH2BCKZ46O7SCKHANWEENRFRU5WB4LXDFUYWCBWTS4AG4SGQXCOZYIR5ZJCZTXRMZKYZMO2BJSL5YKPLAR4LBFRUNS6CRYE7A"), // }, // SystemData: &armconfluent.SystemData{ diff --git a/sdk/resourcemanager/confluent/armconfluent/models.go b/sdk/resourcemanager/confluent/armconfluent/models.go index 5b114c0d907e..f45675c66785 100644 --- a/sdk/resourcemanager/confluent/armconfluent/models.go +++ b/sdk/resourcemanager/confluent/armconfluent/models.go @@ -3,296 +3,621 @@ // 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 armconfluent import "time" +// AccessInviteUserAccountModel - Invite User Account model +type AccessInviteUserAccountModel struct { + // Email of the logged in user + Email *string + + // Details of the user who is being invited + InvitedUserDetails *AccessInvitedUserDetails + + // Id of the organization + OrganizationID *string + + // Upn of the logged in user + Upn *string +} + +// AccessInvitedUserDetails - Details of the user being invited +type AccessInvitedUserDetails struct { + // Auth type of the user + AuthType *string + + // UPN/Email of the user who is being invited + InvitedEmail *string +} + +// AccessListClusterSuccessResponse - List cluster success response +type AccessListClusterSuccessResponse struct { + // Data of the environments list + Data []*ClusterRecord + + // Type of response + Kind *string + + // Metadata of the list + Metadata *ListMetadata +} + +// AccessListEnvironmentsSuccessResponse - List environments success response +type AccessListEnvironmentsSuccessResponse struct { + // Data of the environments list + Data []*EnvironmentRecord + + // Type of response + Kind *string + + // Metadata of the list + Metadata *ListMetadata +} + +// AccessListInvitationsSuccessResponse - List invitations success response +type AccessListInvitationsSuccessResponse struct { + // Data of the invitations list + Data []*InvitationRecord + + // Type of response + Kind *string + + // Metadata of the list + Metadata *ListMetadata +} + +// AccessListRoleBindingsSuccessResponse - List cluster success response +type AccessListRoleBindingsSuccessResponse struct { + // Data of the environments list + Data []*RoleBindingRecord + + // Type of response + Kind *string + + // Metadata of the list + Metadata *ListMetadata +} + +// AccessListServiceAccountsSuccessResponse - List service accounts success response +type AccessListServiceAccountsSuccessResponse struct { + // Data of the service accounts list + Data []*ServiceAccountRecord + + // Type of response + Kind *string + + // Metadata of the list + Metadata *ListMetadata +} + +// AccessListUsersSuccessResponse - List users success response +type AccessListUsersSuccessResponse struct { + // Data of the users list + Data []*UserRecord + + // Type of response + Kind *string + + // Metadata of the list + Metadata *ListMetadata +} + // AgreementProperties - Terms properties for Marketplace and Confluent. type AgreementProperties struct { // If any version of the terms have been accepted, otherwise false. - Accepted *bool `json:"accepted,omitempty"` + Accepted *bool // Link to HTML with Microsoft and Publisher terms. - LicenseTextLink *string `json:"licenseTextLink,omitempty"` + LicenseTextLink *string // Plan identifier string. - Plan *string `json:"plan,omitempty"` + Plan *string // Link to the privacy policy of the publisher. - PrivacyPolicyLink *string `json:"privacyPolicyLink,omitempty"` + PrivacyPolicyLink *string // Product identifier string. - Product *string `json:"product,omitempty"` + Product *string // Publisher identifier string. - Publisher *string `json:"publisher,omitempty"` + Publisher *string // Date and time in UTC of when the terms were accepted. This is empty if Accepted is false. - RetrieveDatetime *time.Time `json:"retrieveDatetime,omitempty"` + RetrieveDatetime *time.Time // Terms signature. - Signature *string `json:"signature,omitempty"` + Signature *string } // AgreementResource - Agreement Terms definition type AgreementResource struct { // Represents the properties of the resource. - Properties *AgreementProperties `json:"properties,omitempty"` + Properties *AgreementProperties // READ-ONLY; The ARM id of the resource. - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the agreement. - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Metadata pertaining to creation and last modification of the resource - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the agreement. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // AgreementResourceListResponse - Response of a list operation. type AgreementResourceListResponse struct { // Link to the next set of results, if any. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // Results of a list operation. - Value []*AgreementResource `json:"value,omitempty"` + Value []*AgreementResource +} + +// ClusterByokEntity - The network associated with this object +type ClusterByokEntity struct { + // ID of the referred resource + ID *string + + // API URL for accessing or modifying the referred object + Related *string + + // CRN reference to the referred resource + ResourceName *string +} + +// ClusterConfigEntity - The configuration of the Kafka cluster +type ClusterConfigEntity struct { + // The lifecycle phase of the cluster + Kind *string +} + +// ClusterEnvironmentEntity - The environment to which cluster belongs +type ClusterEnvironmentEntity struct { + // Environment of the referred resource + Environment *string + + // ID of the referred resource + ID *string + + // API URL for accessing or modifying the referred object + Related *string + + // CRN reference to the referred resource + ResourceName *string +} + +// ClusterNetworkEntity - The network associated with this object +type ClusterNetworkEntity struct { + // Environment of the referred resource + Environment *string + + // ID of the referred resource + ID *string + + // API URL for accessing or modifying the referred object + Related *string + + // CRN reference to the referred resource + ResourceName *string +} + +// ClusterRecord - Record of the environment +type ClusterRecord struct { + // Display name of the user + DisplayName *string + + // Id of the environment + ID *string + + // Type of environment + Kind *string + + // Metadata of the record + Metadata *MetadataEntity + + // Specification of the cluster + Spec *ClusterSpecEntity + + // Specification of the cluster + Status *ClusterStatusEntity +} + +// ClusterSpecEntity - Spec of the cluster record +type ClusterSpecEntity struct { + // The Kafka API cluster endpoint + APIEndpoint *string + + // The availability zone configuration of the cluster + Availability *string + + // Specification of the cluster + Byok *ClusterByokEntity + + // The cloud service provider + Cloud *string + + // Specification of the cluster + Config *ClusterConfigEntity + + // The name of the cluster + DisplayName *string + + // Specification of the cluster + Environment *ClusterEnvironmentEntity + + // The cluster HTTP request URL. + HTTPEndpoint *string + + // The bootstrap endpoint used by Kafka clients to connect to the cluster + KafkaBootstrapEndpoint *string + + // Specification of the cluster + Network *ClusterNetworkEntity + + // The cloud service provider region + Region *string + + // type of zone availability + Zone *string +} + +// ClusterStatusEntity - Status of the cluster record +type ClusterStatusEntity struct { + // The number of Confluent Kafka Units + Cku *int32 + + // The lifecycle phase of the cluster + Phase *string +} + +// EnvironmentRecord - Record of the environment +type EnvironmentRecord struct { + // Display name of the user + DisplayName *string + + // Id of the environment + ID *string + + // Type of environment + Kind *string + + // Metadata of the record + Metadata *MetadataEntity } // ErrorResponseBody - Response body of Error type ErrorResponseBody struct { // READ-ONLY; Error code - Code *string `json:"code,omitempty" azure:"ro"` + Code *string // READ-ONLY; Error detail - Details []*ErrorResponseBody `json:"details,omitempty" azure:"ro"` + Details []*ErrorResponseBody // READ-ONLY; Error message - Message *string `json:"message,omitempty" azure:"ro"` + Message *string // READ-ONLY; Error target - Target *string `json:"target,omitempty" azure:"ro"` + Target *string +} + +// InvitationRecord - Record of the invitation +type InvitationRecord struct { + // Accepted date time of the invitation + AcceptedAt *string + + // Auth type of the user + AuthType *string + + // Email of the user + Email *string + + // Expiration date time of the invitation + ExpiresAt *string + + // Id of the invitation + ID *string + + // Type of account + Kind *string + + // Metadata of the record + Metadata *MetadataEntity + + // Status of the invitation + Status *string +} + +// LinkOrganization - Link an existing Confluent organization +type LinkOrganization struct { + // REQUIRED; User auth token + Token *string } -// MarketplaceAgreementsClientCreateOptions contains the optional parameters for the MarketplaceAgreementsClient.Create method. -type MarketplaceAgreementsClientCreateOptions struct { - // Confluent Marketplace Agreement resource - Body *AgreementResource +// ListAccessRequestModel - List Access Request Model +type ListAccessRequestModel struct { + // Search filters for the request + SearchFilters map[string]*string } -// MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.NewListPager -// method. -type MarketplaceAgreementsClientListOptions struct { - // placeholder for future optional parameters +// ListMetadata - Metadata of the list +type ListMetadata struct { + // First page of the list + First *string + + // Last page of the list + Last *string + + // Next page of the list + Next *string + + // Previous page of the list + Prev *string + + // Total size of the list + TotalSize *int32 +} + +// MetadataEntity - Metadata of the data record +type MetadataEntity struct { + // Created Date Time + CreatedAt *string + + // Deleted Date time + DeletedAt *string + + // Resource name of the record + ResourceName *string + + // Self lookup url + Self *string + + // Updated Date time + UpdatedAt *string } // OfferDetail - Confluent Offer detail type OfferDetail struct { // REQUIRED; Offer Id - ID *string `json:"id,omitempty"` + ID *string // REQUIRED; Offer Plan Id - PlanID *string `json:"planId,omitempty"` + PlanID *string // REQUIRED; Offer Plan Name - PlanName *string `json:"planName,omitempty"` + PlanName *string // REQUIRED; Publisher Id - PublisherID *string `json:"publisherId,omitempty"` + PublisherID *string // REQUIRED; Offer Plan Term unit - TermUnit *string `json:"termUnit,omitempty"` + TermUnit *string + + // Private Offer Id + PrivateOfferID *string + + // Array of Private Offer Ids + PrivateOfferIDs []*string - // READ-ONLY; SaaS Offer Status - Status *SaaSOfferStatus `json:"status,omitempty" azure:"ro"` + // SaaS Offer Status + Status *SaaSOfferStatus + + // Offer Plan Term Id + TermID *string } // OperationDisplay - The object that represents the operation. type OperationDisplay struct { // Description of the operation, e.g., 'Write confluent'. - Description *string `json:"description,omitempty"` + Description *string // Operation type, e.g., read, write, delete, etc. - Operation *string `json:"operation,omitempty"` + Operation *string // Service provider: Microsoft.Confluent - Provider *string `json:"provider,omitempty"` + Provider *string // Type on which the operation is performed, e.g., 'clusters'. - Resource *string `json:"resource,omitempty"` + Resource *string } // OperationListResult - Result of GET request to list Confluent operations. type OperationListResult struct { // URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // List of Confluent operations supported by the Microsoft.Confluent provider. - Value []*OperationResult `json:"value,omitempty"` + Value []*OperationResult } // OperationResult - An Confluent REST API operation. type OperationResult struct { // The object that represents the operation. - Display *OperationDisplay `json:"display,omitempty"` + Display *OperationDisplay // Indicates whether the operation is a data action - IsDataAction *bool `json:"isDataAction,omitempty"` + IsDataAction *bool // Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` -} - -// OrganizationClientBeginCreateOptions contains the optional parameters for the OrganizationClient.BeginCreate method. -type OrganizationClientBeginCreateOptions struct { - // Organization resource model - Body *OrganizationResource - // Resumes the LRO from the provided token. - ResumeToken string -} - -// OrganizationClientBeginDeleteOptions contains the optional parameters for the OrganizationClient.BeginDelete method. -type OrganizationClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// OrganizationClientGetOptions contains the optional parameters for the OrganizationClient.Get method. -type OrganizationClientGetOptions struct { - // placeholder for future optional parameters -} - -// OrganizationClientListByResourceGroupOptions contains the optional parameters for the OrganizationClient.NewListByResourceGroupPager -// method. -type OrganizationClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// OrganizationClientListBySubscriptionOptions contains the optional parameters for the OrganizationClient.NewListBySubscriptionPager -// method. -type OrganizationClientListBySubscriptionOptions struct { - // placeholder for future optional parameters -} - -// OrganizationClientUpdateOptions contains the optional parameters for the OrganizationClient.Update method. -type OrganizationClientUpdateOptions struct { - // Updated Organization resource - Body *OrganizationResourceUpdate -} - -// OrganizationOperationsClientListOptions contains the optional parameters for the OrganizationOperationsClient.NewListPager -// method. -type OrganizationOperationsClientListOptions struct { - // placeholder for future optional parameters + Name *string } // OrganizationResource - Organization resource. type OrganizationResource struct { // REQUIRED; Organization resource properties - Properties *OrganizationResourceProperties `json:"properties,omitempty"` + Properties *OrganizationResourceProperties // Location of Organization resource - Location *string `json:"location,omitempty"` + Location *string // Organization resource tags - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; The ARM id of the resource. - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource. - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Metadata pertaining to creation and last modification of the resource - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // OrganizationResourceListResult - The response of a list operation. type OrganizationResourceListResult struct { // Link to the next set of results, if any. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // Result of a list operation. - Value []*OrganizationResource `json:"value,omitempty"` + Value []*OrganizationResource } // OrganizationResourceProperties - Organization resource property type OrganizationResourceProperties struct { // REQUIRED; Confluent offer detail - OfferDetail *OfferDetail `json:"offerDetail,omitempty"` + OfferDetail *OfferDetail // REQUIRED; Subscriber detail - UserDetail *UserDetail `json:"userDetail,omitempty"` + UserDetail *UserDetail + + // Link an existing Confluent organization + LinkOrganization *LinkOrganization // READ-ONLY; The creation time of the resource. - CreatedTime *time.Time `json:"createdTime,omitempty" azure:"ro"` + CreatedTime *time.Time // READ-ONLY; Id of the Confluent organization. - OrganizationID *string `json:"organizationId,omitempty" azure:"ro"` + OrganizationID *string // READ-ONLY; Provision states for confluent RP - ProvisioningState *ProvisionState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisionState // READ-ONLY; SSO url for the Confluent organization. - SsoURL *string `json:"ssoUrl,omitempty" azure:"ro"` + SsoURL *string } // OrganizationResourceUpdate - Organization Resource update type OrganizationResourceUpdate struct { // ARM resource tags - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // ResourceProviderDefaultErrorResponse - Default error response for resource provider type ResourceProviderDefaultErrorResponse struct { // READ-ONLY; Response body of Error - Error *ErrorResponseBody `json:"error,omitempty" azure:"ro"` + Error *ErrorResponseBody +} + +// RoleBindingRecord - Record of the environment +type RoleBindingRecord struct { + // A CRN that specifies the scope and resource patterns necessary for the role to bind + CrnPattern *string + + // Id of the role + ID *string + + // The type of the resource. + Kind *string + + // Metadata of the record + Metadata *MetadataEntity + + // The principal User or Group to bind the role to + Principal *string + + // The name of the role to bind to the principal + RoleName *string +} + +// ServiceAccountRecord - Record of the service account +type ServiceAccountRecord struct { + // Description of the service account + Description *string + + // Name of the service account + DisplayName *string + + // Id of the service account + ID *string + + // Type of account + Kind *string + + // Metadata of the record + Metadata *MetadataEntity } // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). - CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAt *time.Time // The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` + CreatedBy *string // The type of identity that created the resource. - CreatedByType *CreatedByType `json:"createdByType,omitempty"` + CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAt *time.Time // The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedBy *string // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` + LastModifiedByType *CreatedByType } // UserDetail - Subscriber detail type UserDetail struct { // REQUIRED; Email address - EmailAddress *string `json:"emailAddress,omitempty"` + EmailAddress *string + + // AAD email address + AADEmail *string // First name - FirstName *string `json:"firstName,omitempty"` + FirstName *string // Last name - LastName *string `json:"lastName,omitempty"` + LastName *string + + // User principal name + UserPrincipalName *string +} + +// UserRecord - Record of the user +type UserRecord struct { + // Auth type of the user + AuthType *string + + // Email of the user + Email *string + + // Name of the user + FullName *string + + // Id of the user + ID *string + + // Type of account + Kind *string + + // Metadata of the record + Metadata *MetadataEntity } -// ValidationsClientValidateOrganizationOptions contains the optional parameters for the ValidationsClient.ValidateOrganization -// method. -type ValidationsClientValidateOrganizationOptions struct { - // placeholder for future optional parameters +// ValidationResponse - Validation response from the provider +type ValidationResponse struct { + // Info from the response + Info map[string]*string } diff --git a/sdk/resourcemanager/confluent/armconfluent/models_serde.go b/sdk/resourcemanager/confluent/armconfluent/models_serde.go index 029e5478ea2b..25ab46826115 100644 --- a/sdk/resourcemanager/confluent/armconfluent/models_serde.go +++ b/sdk/resourcemanager/confluent/armconfluent/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 armconfluent @@ -16,6 +15,286 @@ import ( "reflect" ) +// MarshalJSON implements the json.Marshaller interface for type AccessInviteUserAccountModel. +func (a AccessInviteUserAccountModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "email", a.Email) + populate(objectMap, "invitedUserDetails", a.InvitedUserDetails) + populate(objectMap, "organizationId", a.OrganizationID) + populate(objectMap, "upn", a.Upn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessInviteUserAccountModel. +func (a *AccessInviteUserAccountModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "email": + err = unpopulate(val, "Email", &a.Email) + delete(rawMsg, key) + case "invitedUserDetails": + err = unpopulate(val, "InvitedUserDetails", &a.InvitedUserDetails) + delete(rawMsg, key) + case "organizationId": + err = unpopulate(val, "OrganizationID", &a.OrganizationID) + delete(rawMsg, key) + case "upn": + err = unpopulate(val, "Upn", &a.Upn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessInvitedUserDetails. +func (a AccessInvitedUserDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "auth_type", a.AuthType) + populate(objectMap, "invitedEmail", a.InvitedEmail) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessInvitedUserDetails. +func (a *AccessInvitedUserDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "auth_type": + err = unpopulate(val, "AuthType", &a.AuthType) + delete(rawMsg, key) + case "invitedEmail": + err = unpopulate(val, "InvitedEmail", &a.InvitedEmail) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessListClusterSuccessResponse. +func (a AccessListClusterSuccessResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "data", a.Data) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "metadata", a.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessListClusterSuccessResponse. +func (a *AccessListClusterSuccessResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "data": + err = unpopulate(val, "Data", &a.Data) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessListEnvironmentsSuccessResponse. +func (a AccessListEnvironmentsSuccessResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "data", a.Data) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "metadata", a.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessListEnvironmentsSuccessResponse. +func (a *AccessListEnvironmentsSuccessResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "data": + err = unpopulate(val, "Data", &a.Data) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessListInvitationsSuccessResponse. +func (a AccessListInvitationsSuccessResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "data", a.Data) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "metadata", a.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessListInvitationsSuccessResponse. +func (a *AccessListInvitationsSuccessResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "data": + err = unpopulate(val, "Data", &a.Data) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessListRoleBindingsSuccessResponse. +func (a AccessListRoleBindingsSuccessResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "data", a.Data) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "metadata", a.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessListRoleBindingsSuccessResponse. +func (a *AccessListRoleBindingsSuccessResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "data": + err = unpopulate(val, "Data", &a.Data) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessListServiceAccountsSuccessResponse. +func (a AccessListServiceAccountsSuccessResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "data", a.Data) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "metadata", a.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessListServiceAccountsSuccessResponse. +func (a *AccessListServiceAccountsSuccessResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "data": + err = unpopulate(val, "Data", &a.Data) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessListUsersSuccessResponse. +func (a AccessListUsersSuccessResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "data", a.Data) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "metadata", a.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessListUsersSuccessResponse. +func (a *AccessListUsersSuccessResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "data": + err = unpopulate(val, "Data", &a.Data) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type AgreementProperties. func (a AgreementProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -25,7 +304,7 @@ func (a AgreementProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "privacyPolicyLink", a.PrivacyPolicyLink) populate(objectMap, "product", a.Product) populate(objectMap, "publisher", a.Publisher) - populateTimeRFC3339(objectMap, "retrieveDatetime", a.RetrieveDatetime) + populateDateTimeRFC3339(objectMap, "retrieveDatetime", a.RetrieveDatetime) populate(objectMap, "signature", a.Signature) return json.Marshal(objectMap) } @@ -54,92 +333,420 @@ func (a *AgreementProperties) UnmarshalJSON(data []byte) error { case "product": err = unpopulate(val, "Product", &a.Product) delete(rawMsg, key) - case "publisher": - err = unpopulate(val, "Publisher", &a.Publisher) + case "publisher": + err = unpopulate(val, "Publisher", &a.Publisher) + delete(rawMsg, key) + case "retrieveDatetime": + err = unpopulateDateTimeRFC3339(val, "RetrieveDatetime", &a.RetrieveDatetime) + delete(rawMsg, key) + case "signature": + err = unpopulate(val, "Signature", &a.Signature) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgreementResource. +func (a AgreementResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementResource. +func (a *AgreementResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgreementResourceListResponse. +func (a AgreementResourceListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementResourceListResponse. +func (a *AgreementResourceListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterByokEntity. +func (c ClusterByokEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "related", c.Related) + populate(objectMap, "resource_name", c.ResourceName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterByokEntity. +func (c *ClusterByokEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "related": + err = unpopulate(val, "Related", &c.Related) + delete(rawMsg, key) + case "resource_name": + err = unpopulate(val, "ResourceName", &c.ResourceName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterConfigEntity. +func (c ClusterConfigEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", c.Kind) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterConfigEntity. +func (c *ClusterConfigEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &c.Kind) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterEnvironmentEntity. +func (c ClusterEnvironmentEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "environment", c.Environment) + populate(objectMap, "id", c.ID) + populate(objectMap, "related", c.Related) + populate(objectMap, "resource_name", c.ResourceName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterEnvironmentEntity. +func (c *ClusterEnvironmentEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "environment": + err = unpopulate(val, "Environment", &c.Environment) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "related": + err = unpopulate(val, "Related", &c.Related) + delete(rawMsg, key) + case "resource_name": + err = unpopulate(val, "ResourceName", &c.ResourceName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterNetworkEntity. +func (c ClusterNetworkEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "environment", c.Environment) + populate(objectMap, "id", c.ID) + populate(objectMap, "related", c.Related) + populate(objectMap, "resource_name", c.ResourceName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterNetworkEntity. +func (c *ClusterNetworkEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "environment": + err = unpopulate(val, "Environment", &c.Environment) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "related": + err = unpopulate(val, "Related", &c.Related) + delete(rawMsg, key) + case "resource_name": + err = unpopulate(val, "ResourceName", &c.ResourceName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterRecord. +func (c ClusterRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display_name", c.DisplayName) + populate(objectMap, "id", c.ID) + populate(objectMap, "kind", c.Kind) + populate(objectMap, "metadata", c.Metadata) + populate(objectMap, "spec", c.Spec) + populate(objectMap, "status", c.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterRecord. +func (c *ClusterRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display_name": + err = unpopulate(val, "DisplayName", &c.DisplayName) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &c.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &c.Metadata) + delete(rawMsg, key) + case "spec": + err = unpopulate(val, "Spec", &c.Spec) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterSpecEntity. +func (c ClusterSpecEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "api_endpoint", c.APIEndpoint) + populate(objectMap, "availability", c.Availability) + populate(objectMap, "byok", c.Byok) + populate(objectMap, "cloud", c.Cloud) + populate(objectMap, "config", c.Config) + populate(objectMap, "display_name", c.DisplayName) + populate(objectMap, "environment", c.Environment) + populate(objectMap, "http_endpoint", c.HTTPEndpoint) + populate(objectMap, "kafka_bootstrap_endpoint", c.KafkaBootstrapEndpoint) + populate(objectMap, "network", c.Network) + populate(objectMap, "region", c.Region) + populate(objectMap, "zone", c.Zone) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterSpecEntity. +func (c *ClusterSpecEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "api_endpoint": + err = unpopulate(val, "APIEndpoint", &c.APIEndpoint) + delete(rawMsg, key) + case "availability": + err = unpopulate(val, "Availability", &c.Availability) + delete(rawMsg, key) + case "byok": + err = unpopulate(val, "Byok", &c.Byok) + delete(rawMsg, key) + case "cloud": + err = unpopulate(val, "Cloud", &c.Cloud) + delete(rawMsg, key) + case "config": + err = unpopulate(val, "Config", &c.Config) + delete(rawMsg, key) + case "display_name": + err = unpopulate(val, "DisplayName", &c.DisplayName) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &c.Environment) + delete(rawMsg, key) + case "http_endpoint": + err = unpopulate(val, "HTTPEndpoint", &c.HTTPEndpoint) + delete(rawMsg, key) + case "kafka_bootstrap_endpoint": + err = unpopulate(val, "KafkaBootstrapEndpoint", &c.KafkaBootstrapEndpoint) + delete(rawMsg, key) + case "network": + err = unpopulate(val, "Network", &c.Network) delete(rawMsg, key) - case "retrieveDatetime": - err = unpopulateTimeRFC3339(val, "RetrieveDatetime", &a.RetrieveDatetime) + case "region": + err = unpopulate(val, "Region", &c.Region) delete(rawMsg, key) - case "signature": - err = unpopulate(val, "Signature", &a.Signature) + case "zone": + err = unpopulate(val, "Zone", &c.Zone) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type AgreementResource. -func (a AgreementResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ClusterStatusEntity. +func (c ClusterStatusEntity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", a.ID) - populate(objectMap, "name", a.Name) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "systemData", a.SystemData) - populate(objectMap, "type", a.Type) + populate(objectMap, "cku", c.Cku) + populate(objectMap, "phase", c.Phase) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementResource. -func (a *AgreementResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterStatusEntity. +func (c *ClusterStatusEntity) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &a.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &a.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &a.Properties) + case "cku": + err = unpopulate(val, "Cku", &c.Cku) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &a.SystemData) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) + case "phase": + err = unpopulate(val, "Phase", &c.Phase) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type AgreementResourceListResponse. -func (a AgreementResourceListResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnvironmentRecord. +func (e EnvironmentRecord) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", a.NextLink) - populate(objectMap, "value", a.Value) + populate(objectMap, "display_name", e.DisplayName) + populate(objectMap, "id", e.ID) + populate(objectMap, "kind", e.Kind) + populate(objectMap, "metadata", e.Metadata) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementResourceListResponse. -func (a *AgreementResourceListResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentRecord. +func (e *EnvironmentRecord) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &a.NextLink) + case "display_name": + err = unpopulate(val, "DisplayName", &e.DisplayName) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &a.Value) + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &e.Metadata) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil @@ -184,14 +791,212 @@ func (e *ErrorResponseBody) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type InvitationRecord. +func (i InvitationRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accepted_at", i.AcceptedAt) + populate(objectMap, "auth_type", i.AuthType) + populate(objectMap, "email", i.Email) + populate(objectMap, "expires_at", i.ExpiresAt) + populate(objectMap, "id", i.ID) + populate(objectMap, "kind", i.Kind) + populate(objectMap, "metadata", i.Metadata) + populate(objectMap, "status", i.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InvitationRecord. +func (i *InvitationRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accepted_at": + err = unpopulate(val, "AcceptedAt", &i.AcceptedAt) + delete(rawMsg, key) + case "auth_type": + err = unpopulate(val, "AuthType", &i.AuthType) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &i.Email) + delete(rawMsg, key) + case "expires_at": + err = unpopulate(val, "ExpiresAt", &i.ExpiresAt) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &i.Metadata) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &i.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinkOrganization. +func (l LinkOrganization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "token", l.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkOrganization. +func (l *LinkOrganization) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "token": + err = unpopulate(val, "Token", &l.Token) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListAccessRequestModel. +func (l ListAccessRequestModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "searchFilters", l.SearchFilters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListAccessRequestModel. +func (l *ListAccessRequestModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "searchFilters": + err = unpopulate(val, "SearchFilters", &l.SearchFilters) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListMetadata. +func (l ListMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "first", l.First) + populate(objectMap, "last", l.Last) + populate(objectMap, "next", l.Next) + populate(objectMap, "prev", l.Prev) + populate(objectMap, "total_size", l.TotalSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListMetadata. +func (l *ListMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "first": + err = unpopulate(val, "First", &l.First) + delete(rawMsg, key) + case "last": + err = unpopulate(val, "Last", &l.Last) + delete(rawMsg, key) + case "next": + err = unpopulate(val, "Next", &l.Next) + delete(rawMsg, key) + case "prev": + err = unpopulate(val, "Prev", &l.Prev) + delete(rawMsg, key) + case "total_size": + err = unpopulate(val, "TotalSize", &l.TotalSize) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MetadataEntity. +func (m MetadataEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "created_at", m.CreatedAt) + populate(objectMap, "deleted_at", m.DeletedAt) + populate(objectMap, "resource_name", m.ResourceName) + populate(objectMap, "self", m.Self) + populate(objectMap, "updated_at", m.UpdatedAt) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetadataEntity. +func (m *MetadataEntity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "created_at": + err = unpopulate(val, "CreatedAt", &m.CreatedAt) + delete(rawMsg, key) + case "deleted_at": + err = unpopulate(val, "DeletedAt", &m.DeletedAt) + delete(rawMsg, key) + case "resource_name": + err = unpopulate(val, "ResourceName", &m.ResourceName) + delete(rawMsg, key) + case "self": + err = unpopulate(val, "Self", &m.Self) + delete(rawMsg, key) + case "updated_at": + err = unpopulate(val, "UpdatedAt", &m.UpdatedAt) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OfferDetail. func (o OfferDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", o.ID) populate(objectMap, "planId", o.PlanID) populate(objectMap, "planName", o.PlanName) + populate(objectMap, "privateOfferId", o.PrivateOfferID) + populate(objectMap, "privateOfferIds", o.PrivateOfferIDs) populate(objectMap, "publisherId", o.PublisherID) populate(objectMap, "status", o.Status) + populate(objectMap, "termId", o.TermID) populate(objectMap, "termUnit", o.TermUnit) return json.Marshal(objectMap) } @@ -214,12 +1019,21 @@ func (o *OfferDetail) UnmarshalJSON(data []byte) error { case "planName": err = unpopulate(val, "PlanName", &o.PlanName) delete(rawMsg, key) + case "privateOfferId": + err = unpopulate(val, "PrivateOfferID", &o.PrivateOfferID) + delete(rawMsg, key) + case "privateOfferIds": + err = unpopulate(val, "PrivateOfferIDs", &o.PrivateOfferIDs) + delete(rawMsg, key) case "publisherId": err = unpopulate(val, "PublisherID", &o.PublisherID) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &o.Status) delete(rawMsg, key) + case "termId": + err = unpopulate(val, "TermID", &o.TermID) + delete(rawMsg, key) case "termUnit": err = unpopulate(val, "TermUnit", &o.TermUnit) delete(rawMsg, key) @@ -421,7 +1235,8 @@ func (o *OrganizationResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OrganizationResourceProperties. func (o OrganizationResourceProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdTime", o.CreatedTime) + populateDateTimeRFC3339(objectMap, "createdTime", o.CreatedTime) + populate(objectMap, "linkOrganization", o.LinkOrganization) populate(objectMap, "offerDetail", o.OfferDetail) populate(objectMap, "organizationId", o.OrganizationID) populate(objectMap, "provisioningState", o.ProvisioningState) @@ -440,7 +1255,10 @@ func (o *OrganizationResourceProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &o.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &o.CreatedTime) + delete(rawMsg, key) + case "linkOrganization": + err = unpopulate(val, "LinkOrganization", &o.LinkOrganization) delete(rawMsg, key) case "offerDetail": err = unpopulate(val, "OfferDetail", &o.OfferDetail) @@ -519,13 +1337,103 @@ func (r *ResourceProviderDefaultErrorResponse) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type RoleBindingRecord. +func (r RoleBindingRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "crn_pattern", r.CrnPattern) + populate(objectMap, "id", r.ID) + populate(objectMap, "kind", r.Kind) + populate(objectMap, "metadata", r.Metadata) + populate(objectMap, "principal", r.Principal) + populate(objectMap, "role_name", r.RoleName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleBindingRecord. +func (r *RoleBindingRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "crn_pattern": + err = unpopulate(val, "CrnPattern", &r.CrnPattern) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &r.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &r.Metadata) + delete(rawMsg, key) + case "principal": + err = unpopulate(val, "Principal", &r.Principal) + delete(rawMsg, key) + case "role_name": + err = unpopulate(val, "RoleName", &r.RoleName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceAccountRecord. +func (s ServiceAccountRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", s.Description) + populate(objectMap, "display_name", s.DisplayName) + populate(objectMap, "id", s.ID) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "metadata", s.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceAccountRecord. +func (s *ServiceAccountRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "display_name": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &s.Metadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type 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) @@ -541,7 +1449,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) @@ -550,7 +1458,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) @@ -569,9 +1477,11 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserDetail. func (u UserDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "aadEmail", u.AADEmail) populate(objectMap, "emailAddress", u.EmailAddress) populate(objectMap, "firstName", u.FirstName) populate(objectMap, "lastName", u.LastName) + populate(objectMap, "userPrincipalName", u.UserPrincipalName) return json.Marshal(objectMap) } @@ -584,6 +1494,9 @@ func (u *UserDetail) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "aadEmail": + err = unpopulate(val, "AADEmail", &u.AADEmail) + delete(rawMsg, key) case "emailAddress": err = unpopulate(val, "EmailAddress", &u.EmailAddress) delete(rawMsg, key) @@ -593,6 +1506,56 @@ func (u *UserDetail) UnmarshalJSON(data []byte) error { case "lastName": err = unpopulate(val, "LastName", &u.LastName) delete(rawMsg, key) + case "userPrincipalName": + err = unpopulate(val, "UserPrincipalName", &u.UserPrincipalName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserRecord. +func (u UserRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "auth_type", u.AuthType) + populate(objectMap, "email", u.Email) + populate(objectMap, "full_name", u.FullName) + populate(objectMap, "id", u.ID) + populate(objectMap, "kind", u.Kind) + populate(objectMap, "metadata", u.Metadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserRecord. +func (u *UserRecord) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "auth_type": + err = unpopulate(val, "AuthType", &u.AuthType) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &u.Email) + delete(rawMsg, key) + case "full_name": + err = unpopulate(val, "FullName", &u.FullName) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &u.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &u.Kind) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &u.Metadata) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) @@ -601,6 +1564,33 @@ func (u *UserDetail) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ValidationResponse. +func (v ValidationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", v.Info) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidationResponse. +func (v *ValidationResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &v.Info) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + func populate(m map[string]any, k string, v any) { if v == nil { return diff --git a/sdk/resourcemanager/confluent/armconfluent/options.go b/sdk/resourcemanager/confluent/armconfluent/options.go new file mode 100644 index 000000000000..63b4c0d51d31 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/options.go @@ -0,0 +1,112 @@ +//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 armconfluent + +// AccessClientInviteUserOptions contains the optional parameters for the AccessClient.InviteUser method. +type AccessClientInviteUserOptions struct { + // placeholder for future optional parameters +} + +// AccessClientListClustersOptions contains the optional parameters for the AccessClient.ListClusters method. +type AccessClientListClustersOptions struct { + // placeholder for future optional parameters +} + +// AccessClientListEnvironmentsOptions contains the optional parameters for the AccessClient.ListEnvironments method. +type AccessClientListEnvironmentsOptions struct { + // placeholder for future optional parameters +} + +// AccessClientListInvitationsOptions contains the optional parameters for the AccessClient.ListInvitations method. +type AccessClientListInvitationsOptions struct { + // placeholder for future optional parameters +} + +// AccessClientListRoleBindingsOptions contains the optional parameters for the AccessClient.ListRoleBindings method. +type AccessClientListRoleBindingsOptions struct { + // placeholder for future optional parameters +} + +// AccessClientListServiceAccountsOptions contains the optional parameters for the AccessClient.ListServiceAccounts method. +type AccessClientListServiceAccountsOptions struct { + // placeholder for future optional parameters +} + +// AccessClientListUsersOptions contains the optional parameters for the AccessClient.ListUsers method. +type AccessClientListUsersOptions struct { + // placeholder for future optional parameters +} + +// MarketplaceAgreementsClientCreateOptions contains the optional parameters for the MarketplaceAgreementsClient.Create method. +type MarketplaceAgreementsClientCreateOptions struct { + // Confluent Marketplace Agreement resource + Body *AgreementResource +} + +// MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.NewListPager +// method. +type MarketplaceAgreementsClientListOptions struct { + // placeholder for future optional parameters +} + +// OrganizationClientBeginCreateOptions contains the optional parameters for the OrganizationClient.BeginCreate method. +type OrganizationClientBeginCreateOptions struct { + // Organization resource model + Body *OrganizationResource + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// OrganizationClientBeginDeleteOptions contains the optional parameters for the OrganizationClient.BeginDelete method. +type OrganizationClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// OrganizationClientGetOptions contains the optional parameters for the OrganizationClient.Get method. +type OrganizationClientGetOptions struct { + // placeholder for future optional parameters +} + +// OrganizationClientListByResourceGroupOptions contains the optional parameters for the OrganizationClient.NewListByResourceGroupPager +// method. +type OrganizationClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// OrganizationClientListBySubscriptionOptions contains the optional parameters for the OrganizationClient.NewListBySubscriptionPager +// method. +type OrganizationClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// OrganizationClientUpdateOptions contains the optional parameters for the OrganizationClient.Update method. +type OrganizationClientUpdateOptions struct { + // Updated Organization resource + Body *OrganizationResourceUpdate +} + +// OrganizationOperationsClientListOptions contains the optional parameters for the OrganizationOperationsClient.NewListPager +// method. +type OrganizationOperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// ValidationsClientValidateOrganizationOptions contains the optional parameters for the ValidationsClient.ValidateOrganization +// method. +type ValidationsClientValidateOrganizationOptions struct { + // placeholder for future optional parameters +} + +// ValidationsClientValidateOrganizationV2Options contains the optional parameters for the ValidationsClient.ValidateOrganizationV2 +// method. +type ValidationsClientValidateOrganizationV2Options struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/confluent/armconfluent/organization_client.go b/sdk/resourcemanager/confluent/armconfluent/organization_client.go index 8e913db1bf7d..ec5e2514f8b8 100644 --- a/sdk/resourcemanager/confluent/armconfluent/organization_client.go +++ b/sdk/resourcemanager/confluent/armconfluent/organization_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 armconfluent @@ -29,11 +28,11 @@ type OrganizationClient struct { } // NewOrganizationClient creates a new instance of OrganizationClient with the specified values. -// - subscriptionID - Microsoft Azure subscription id +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOrganizationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OrganizationClient, error) { - cl, err := arm.NewClient(moduleName+".OrganizationClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,8 +46,8 @@ func NewOrganizationClient(subscriptionID string, credential azcore.TokenCredent // BeginCreate - Create Organization resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-12-01 -// - resourceGroupName - Resource group name +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - organizationName - Organization resource name // - options - OrganizationClientBeginCreateOptions contains the optional parameters for the OrganizationClient.BeginCreate // method. @@ -58,31 +57,41 @@ func (client *OrganizationClient) BeginCreate(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[OrganizationClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[OrganizationClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Create - Create Organization resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-12-01 +// Generated from API version 2023-08-22 func (client *OrganizationClient) create(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "OrganizationClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, organizationName, 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.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -105,11 +114,14 @@ func (client *OrganizationClient) createCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -117,8 +129,8 @@ func (client *OrganizationClient) createCreateRequest(ctx context.Context, resou // BeginDelete - Delete Organization resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-12-01 -// - resourceGroupName - Resource group name +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - organizationName - Organization resource name // - options - OrganizationClientBeginDeleteOptions contains the optional parameters for the OrganizationClient.BeginDelete // method. @@ -128,31 +140,41 @@ func (client *OrganizationClient) BeginDelete(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[OrganizationClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[OrganizationClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Delete - Delete Organization resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-12-01 +// Generated from API version 2023-08-22 func (client *OrganizationClient) deleteOperation(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "OrganizationClient.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, organizationName, 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. @@ -175,7 +197,7 @@ func (client *OrganizationClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -184,23 +206,30 @@ func (client *OrganizationClient) deleteCreateRequest(ctx context.Context, resou // Get - Get the properties of a specific Organization resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-12-01 -// - resourceGroupName - Resource group name +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - organizationName - Organization resource name // - options - OrganizationClientGetOptions contains the optional parameters for the OrganizationClient.Get method. func (client *OrganizationClient) Get(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientGetOptions) (OrganizationClientGetResponse, error) { + var err error + const operationName = "OrganizationClient.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, organizationName, options) if err != nil { return OrganizationClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OrganizationClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OrganizationClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OrganizationClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -223,7 +252,7 @@ func (client *OrganizationClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -240,8 +269,8 @@ func (client *OrganizationClient) getHandleResponse(resp *http.Response) (Organi // NewListByResourceGroupPager - List all Organizations under the specified resource group. // -// Generated from API version 2021-12-01 -// - resourceGroupName - Resource group name +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - OrganizationClientListByResourceGroupOptions contains the optional parameters for the OrganizationClient.NewListByResourceGroupPager // method. func (client *OrganizationClient) NewListByResourceGroupPager(resourceGroupName string, options *OrganizationClientListByResourceGroupOptions) *runtime.Pager[OrganizationClientListByResourceGroupResponse] { @@ -250,25 +279,20 @@ func (client *OrganizationClient) NewListByResourceGroupPager(resourceGroupName return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OrganizationClientListByResourceGroupResponse) (OrganizationClientListByResourceGroupResponse, 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 OrganizationClientListByResourceGroupResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OrganizationClient.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 OrganizationClientListByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OrganizationClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -288,7 +312,7 @@ func (client *OrganizationClient) listByResourceGroupCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -305,7 +329,7 @@ func (client *OrganizationClient) listByResourceGroupHandleResponse(resp *http.R // NewListBySubscriptionPager - List all organizations under the specified subscription. // -// Generated from API version 2021-12-01 +// Generated from API version 2023-08-22 // - options - OrganizationClientListBySubscriptionOptions contains the optional parameters for the OrganizationClient.NewListBySubscriptionPager // method. func (client *OrganizationClient) NewListBySubscriptionPager(options *OrganizationClientListBySubscriptionOptions) *runtime.Pager[OrganizationClientListBySubscriptionResponse] { @@ -314,25 +338,20 @@ func (client *OrganizationClient) NewListBySubscriptionPager(options *Organizati return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OrganizationClientListBySubscriptionResponse) (OrganizationClientListBySubscriptionResponse, 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) - } - if err != nil { - return OrganizationClientListBySubscriptionResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OrganizationClient.NewListBySubscriptionPager") + 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.listBySubscriptionCreateRequest(ctx, options) + }, nil) if err != nil { return OrganizationClientListBySubscriptionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OrganizationClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -348,7 +367,7 @@ func (client *OrganizationClient) listBySubscriptionCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -366,23 +385,30 @@ func (client *OrganizationClient) listBySubscriptionHandleResponse(resp *http.Re // Update - Update Organization resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-12-01 -// - resourceGroupName - Resource group name +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - organizationName - Organization resource name // - options - OrganizationClientUpdateOptions contains the optional parameters for the OrganizationClient.Update method. func (client *OrganizationClient) Update(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientUpdateOptions) (OrganizationClientUpdateResponse, error) { + var err error + const operationName = "OrganizationClient.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, organizationName, options) if err != nil { return OrganizationClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OrganizationClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OrganizationClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OrganizationClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -405,11 +431,14 @@ func (client *OrganizationClient) updateCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } diff --git a/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go index 7b4f0a66320a..94007a905e5b 100644 --- a/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go @@ -15,10 +15,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_ListBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Organization_ListBySubscription.json func ExampleOrganizationClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -53,28 +53,33 @@ func ExampleOrganizationClient_NewListBySubscriptionPager() { // ID: to.Ptr("string"), // PlanID: to.Ptr("string"), // PlanName: to.Ptr("string"), - // PublisherID: to.Ptr("string"), - // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), - // TermUnit: to.Ptr("string"), + // PrivateOfferID: to.Ptr("string"), + // PrivateOfferIDs: []*string{ + // to.Ptr("string")}, + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // AADEmail: to.Ptr("contoso@microsoft.com"), + // EmailAddress: to.Ptr("contoso@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // UserPrincipalName: to.Ptr("contoso@microsoft.com"), + // }, // }, - // OrganizationID: to.Ptr("string"), - // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), - // SsoURL: to.Ptr("string"), - // UserDetail: &armconfluent.UserDetail{ - // EmailAddress: to.Ptr("contoso@microsoft.com"), - // FirstName: to.Ptr("string"), - // LastName: to.Ptr("string"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), // }, - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // }}, - // } + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_ListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Organization_ListByResourceGroup.json func ExampleOrganizationClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -109,28 +114,33 @@ func ExampleOrganizationClient_NewListByResourceGroupPager() { // ID: to.Ptr("string"), // PlanID: to.Ptr("string"), // PlanName: to.Ptr("string"), - // PublisherID: to.Ptr("string"), - // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), - // TermUnit: to.Ptr("string"), + // PrivateOfferID: to.Ptr("string"), + // PrivateOfferIDs: []*string{ + // to.Ptr("string")}, + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // AADEmail: to.Ptr("contoso@microsoft.com"), + // EmailAddress: to.Ptr("contoso@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // UserPrincipalName: to.Ptr("contoso@microsoft.com"), + // }, // }, - // OrganizationID: to.Ptr("string"), - // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), - // SsoURL: to.Ptr("string"), - // UserDetail: &armconfluent.UserDetail{ - // EmailAddress: to.Ptr("contoso@microsoft.com"), - // FirstName: to.Ptr("string"), - // LastName: to.Ptr("string"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), // }, - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // }}, - // } + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Organization_Get.json func ExampleOrganizationClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -186,7 +196,7 @@ func ExampleOrganizationClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Organization_Create.json func ExampleOrganizationClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -200,17 +210,25 @@ func ExampleOrganizationClient_BeginCreate() { poller, err := clientFactory.NewOrganizationClient().BeginCreate(ctx, "myResourceGroup", "myOrganization", &armconfluent.OrganizationClientBeginCreateOptions{Body: &armconfluent.OrganizationResource{ Location: to.Ptr("West US"), Properties: &armconfluent.OrganizationResourceProperties{ + LinkOrganization: &armconfluent.LinkOrganization{ + Token: to.Ptr("string"), + }, OfferDetail: &armconfluent.OfferDetail{ - ID: to.Ptr("string"), - PlanID: to.Ptr("string"), - PlanName: to.Ptr("string"), + ID: to.Ptr("string"), + PlanID: to.Ptr("string"), + PlanName: to.Ptr("string"), + PrivateOfferID: to.Ptr("string"), + PrivateOfferIDs: []*string{ + to.Ptr("string")}, PublisherID: to.Ptr("string"), TermUnit: to.Ptr("string"), }, UserDetail: &armconfluent.UserDetail{ - EmailAddress: to.Ptr("contoso@microsoft.com"), - FirstName: to.Ptr("string"), - LastName: to.Ptr("string"), + AADEmail: to.Ptr("contoso@microsoft.com"), + EmailAddress: to.Ptr("contoso@microsoft.com"), + FirstName: to.Ptr("string"), + LastName: to.Ptr("string"), + UserPrincipalName: to.Ptr("contoso@microsoft.com"), }, }, Tags: map[string]*string{ @@ -239,34 +257,39 @@ func ExampleOrganizationClient_BeginCreate() { // ID: to.Ptr("string"), // PlanID: to.Ptr("string"), // PlanName: to.Ptr("string"), - // PublisherID: to.Ptr("string"), - // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), - // TermUnit: to.Ptr("string"), + // PrivateOfferID: to.Ptr("string"), + // PrivateOfferIDs: []*string{ + // to.Ptr("string")}, + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // AADEmail: to.Ptr("contoso@microsoft.com"), + // EmailAddress: to.Ptr("contoso@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // UserPrincipalName: to.Ptr("contoso@microsoft.com"), + // }, // }, - // OrganizationID: to.Ptr("string"), - // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), - // SsoURL: to.Ptr("string"), - // UserDetail: &armconfluent.UserDetail{ - // EmailAddress: to.Ptr("contoso@microsoft.com"), - // FirstName: to.Ptr("string"), - // LastName: to.Ptr("string"), + // SystemData: &armconfluent.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armconfluent.CreatedByTypeUser), // }, - // }, - // SystemData: &armconfluent.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armconfluent.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armconfluent.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // } + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Organization_Update.json func ExampleOrganizationClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -328,7 +351,7 @@ func ExampleOrganizationClient_Update() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Organization_Delete.json func ExampleOrganizationClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client.go b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client.go index 9d86a7a613ec..1532e86e1a43 100644 --- a/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client.go +++ b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_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 armconfluent @@ -28,7 +27,7 @@ type OrganizationOperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOrganizationOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OrganizationOperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OrganizationOperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -40,7 +39,7 @@ func NewOrganizationOperationsClient(credential azcore.TokenCredential, options // NewListPager - List all operations provided by Microsoft.Confluent. // -// Generated from API version 2021-12-01 +// Generated from API version 2023-08-22 // - options - OrganizationOperationsClientListOptions contains the optional parameters for the OrganizationOperationsClient.NewListPager // method. func (client *OrganizationOperationsClient) NewListPager(options *OrganizationOperationsClientListOptions) *runtime.Pager[OrganizationOperationsClientListResponse] { @@ -49,25 +48,20 @@ func (client *OrganizationOperationsClient) NewListPager(options *OrganizationOp return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OrganizationOperationsClientListResponse) (OrganizationOperationsClientListResponse, 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) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OrganizationOperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return OrganizationOperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OrganizationOperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OrganizationOperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -79,7 +73,7 @@ func (client *OrganizationOperationsClient) listCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go index 9391b9916423..a8114b4c9ea6 100644 --- a/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/OrganizationOperations_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/OrganizationOperations_List.json func ExampleOrganizationOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/confluent/armconfluent/response_types.go b/sdk/resourcemanager/confluent/armconfluent/response_types.go index 2df73e4e379e..6aa0f396f460 100644 --- a/sdk/resourcemanager/confluent/armconfluent/response_types.go +++ b/sdk/resourcemanager/confluent/armconfluent/response_types.go @@ -3,24 +3,68 @@ // 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 armconfluent +// AccessClientInviteUserResponse contains the response from method AccessClient.InviteUser. +type AccessClientInviteUserResponse struct { + // Record of the invitation + InvitationRecord +} + +// AccessClientListClustersResponse contains the response from method AccessClient.ListClusters. +type AccessClientListClustersResponse struct { + // List cluster success response + AccessListClusterSuccessResponse +} + +// AccessClientListEnvironmentsResponse contains the response from method AccessClient.ListEnvironments. +type AccessClientListEnvironmentsResponse struct { + // List environments success response + AccessListEnvironmentsSuccessResponse +} + +// AccessClientListInvitationsResponse contains the response from method AccessClient.ListInvitations. +type AccessClientListInvitationsResponse struct { + // List invitations success response + AccessListInvitationsSuccessResponse +} + +// AccessClientListRoleBindingsResponse contains the response from method AccessClient.ListRoleBindings. +type AccessClientListRoleBindingsResponse struct { + // List cluster success response + AccessListRoleBindingsSuccessResponse +} + +// AccessClientListServiceAccountsResponse contains the response from method AccessClient.ListServiceAccounts. +type AccessClientListServiceAccountsResponse struct { + // List service accounts success response + AccessListServiceAccountsSuccessResponse +} + +// AccessClientListUsersResponse contains the response from method AccessClient.ListUsers. +type AccessClientListUsersResponse struct { + // List users success response + AccessListUsersSuccessResponse +} + // MarketplaceAgreementsClientCreateResponse contains the response from method MarketplaceAgreementsClient.Create. type MarketplaceAgreementsClientCreateResponse struct { + // Agreement Terms definition AgreementResource } // MarketplaceAgreementsClientListResponse contains the response from method MarketplaceAgreementsClient.NewListPager. type MarketplaceAgreementsClientListResponse struct { + // Response of a list operation. AgreementResourceListResponse } // OrganizationClientCreateResponse contains the response from method OrganizationClient.BeginCreate. type OrganizationClientCreateResponse struct { + // Organization resource. OrganizationResource } @@ -31,30 +75,42 @@ type OrganizationClientDeleteResponse struct { // OrganizationClientGetResponse contains the response from method OrganizationClient.Get. type OrganizationClientGetResponse struct { + // Organization resource. OrganizationResource } // OrganizationClientListByResourceGroupResponse contains the response from method OrganizationClient.NewListByResourceGroupPager. type OrganizationClientListByResourceGroupResponse struct { + // The response of a list operation. OrganizationResourceListResult } // OrganizationClientListBySubscriptionResponse contains the response from method OrganizationClient.NewListBySubscriptionPager. type OrganizationClientListBySubscriptionResponse struct { + // The response of a list operation. OrganizationResourceListResult } // OrganizationClientUpdateResponse contains the response from method OrganizationClient.Update. type OrganizationClientUpdateResponse struct { + // Organization resource. OrganizationResource } // OrganizationOperationsClientListResponse contains the response from method OrganizationOperationsClient.NewListPager. type OrganizationOperationsClientListResponse struct { + // Result of GET request to list Confluent operations. OperationListResult } // ValidationsClientValidateOrganizationResponse contains the response from method ValidationsClient.ValidateOrganization. type ValidationsClientValidateOrganizationResponse struct { + // Organization resource. OrganizationResource } + +// ValidationsClientValidateOrganizationV2Response contains the response from method ValidationsClient.ValidateOrganizationV2. +type ValidationsClientValidateOrganizationV2Response struct { + // Validation response from the provider + ValidationResponse +} diff --git a/sdk/resourcemanager/confluent/armconfluent/time_rfc3339.go b/sdk/resourcemanager/confluent/armconfluent/time_rfc3339.go index 281c092bc487..c838498eb8fe 100644 --- a/sdk/resourcemanager/confluent/armconfluent/time_rfc3339.go +++ b/sdk/resourcemanager/confluent/armconfluent/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 armconfluent @@ -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) } diff --git a/sdk/resourcemanager/confluent/armconfluent/validations_client.go b/sdk/resourcemanager/confluent/armconfluent/validations_client.go index f34ddb8003d0..44cb27113ceb 100644 --- a/sdk/resourcemanager/confluent/armconfluent/validations_client.go +++ b/sdk/resourcemanager/confluent/armconfluent/validations_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 armconfluent @@ -29,11 +28,11 @@ type ValidationsClient struct { } // NewValidationsClient creates a new instance of ValidationsClient with the specified values. -// - subscriptionID - Microsoft Azure subscription id +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewValidationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ValidationsClient, error) { - cl, err := arm.NewClient(moduleName+".ValidationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,25 +46,32 @@ func NewValidationsClient(subscriptionID string, credential azcore.TokenCredenti // ValidateOrganization - Organization Validate proxy resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-12-01 -// - resourceGroupName - Resource group name +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - organizationName - Organization resource name // - body - Organization resource model // - options - ValidationsClientValidateOrganizationOptions contains the optional parameters for the ValidationsClient.ValidateOrganization // method. func (client *ValidationsClient) ValidateOrganization(ctx context.Context, resourceGroupName string, organizationName string, body OrganizationResource, options *ValidationsClientValidateOrganizationOptions) (ValidationsClientValidateOrganizationResponse, error) { + var err error + const operationName = "ValidationsClient.ValidateOrganization" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.validateOrganizationCreateRequest(ctx, resourceGroupName, organizationName, body, options) if err != nil { return ValidationsClientValidateOrganizationResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ValidationsClientValidateOrganizationResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ValidationsClientValidateOrganizationResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ValidationsClientValidateOrganizationResponse{}, err } - return client.validateOrganizationHandleResponse(resp) + resp, err := client.validateOrganizationHandleResponse(httpResp) + return resp, err } // validateOrganizationCreateRequest creates the ValidateOrganization request. @@ -88,10 +94,13 @@ func (client *ValidationsClient) validateOrganizationCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01") + reqQP.Set("api-version", "2023-08-22") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // validateOrganizationHandleResponse handles the ValidateOrganization response. @@ -102,3 +111,72 @@ func (client *ValidationsClient) validateOrganizationHandleResponse(resp *http.R } return result, nil } + +// ValidateOrganizationV2 - Organization Validate proxy resource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-22 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Organization resource name +// - body - Organization resource model +// - options - ValidationsClientValidateOrganizationV2Options contains the optional parameters for the ValidationsClient.ValidateOrganizationV2 +// method. +func (client *ValidationsClient) ValidateOrganizationV2(ctx context.Context, resourceGroupName string, organizationName string, body OrganizationResource, options *ValidationsClientValidateOrganizationV2Options) (ValidationsClientValidateOrganizationV2Response, error) { + var err error + const operationName = "ValidationsClient.ValidateOrganizationV2" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateOrganizationV2CreateRequest(ctx, resourceGroupName, organizationName, body, options) + if err != nil { + return ValidationsClientValidateOrganizationV2Response{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ValidationsClientValidateOrganizationV2Response{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ValidationsClientValidateOrganizationV2Response{}, err + } + resp, err := client.validateOrganizationV2HandleResponse(httpResp) + return resp, err +} + +// validateOrganizationV2CreateRequest creates the ValidateOrganizationV2 request. +func (client *ValidationsClient) validateOrganizationV2CreateRequest(ctx context.Context, resourceGroupName string, organizationName string, body OrganizationResource, options *ValidationsClientValidateOrganizationV2Options) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/validations/{organizationName}/orgvalidateV2" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-22") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// validateOrganizationV2HandleResponse handles the ValidateOrganizationV2 response. +func (client *ValidationsClient) validateOrganizationV2HandleResponse(resp *http.Response) (ValidationsClientValidateOrganizationV2Response, error) { + result := ValidationsClientValidateOrganizationV2Response{} + if err := runtime.UnmarshalAsJSON(resp, &result.ValidationResponse); err != nil { + return ValidationsClientValidateOrganizationV2Response{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go index 9c707566b136..096ca7d4a024 100644 --- a/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go @@ -15,10 +15,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Validations_ValidateOrganizations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Validations_ValidateOrganizations.json func ExampleValidationsClient_ValidateOrganization() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -33,16 +33,21 @@ func ExampleValidationsClient_ValidateOrganization() { Location: to.Ptr("West US"), Properties: &armconfluent.OrganizationResourceProperties{ OfferDetail: &armconfluent.OfferDetail{ - ID: to.Ptr("string"), - PlanID: to.Ptr("string"), - PlanName: to.Ptr("string"), + ID: to.Ptr("string"), + PlanID: to.Ptr("string"), + PlanName: to.Ptr("string"), + PrivateOfferID: to.Ptr("string"), + PrivateOfferIDs: []*string{ + to.Ptr("string")}, PublisherID: to.Ptr("string"), TermUnit: to.Ptr("string"), }, UserDetail: &armconfluent.UserDetail{ - EmailAddress: to.Ptr("abc@microsoft.com"), - FirstName: to.Ptr("string"), - LastName: to.Ptr("string"), + AADEmail: to.Ptr("abc@microsoft.com"), + EmailAddress: to.Ptr("abc@microsoft.com"), + FirstName: to.Ptr("string"), + LastName: to.Ptr("string"), + UserPrincipalName: to.Ptr("abc@microsoft.com"), }, }, Tags: map[string]*string{ @@ -66,21 +71,75 @@ func ExampleValidationsClient_ValidateOrganization() { // ID: to.Ptr("string"), // PlanID: to.Ptr("string"), // PlanName: to.Ptr("string"), - // PublisherID: to.Ptr("string"), - // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), - // TermUnit: to.Ptr("string"), + // PrivateOfferID: to.Ptr("string"), + // PrivateOfferIDs: []*string{ + // to.Ptr("string")}, + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // AADEmail: to.Ptr("abc@microsoft.com"), + // EmailAddress: to.Ptr("abc@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // UserPrincipalName: to.Ptr("abc@microsoft.com"), + // }, // }, - // OrganizationID: to.Ptr("string"), - // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), - // SsoURL: to.Ptr("string"), - // UserDetail: &armconfluent.UserDetail{ - // EmailAddress: to.Ptr("abc@microsoft.com"), - // FirstName: to.Ptr("string"), - // LastName: to.Ptr("string"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), // }, - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Validations_ValidateOrganizationsV2.json +func ExampleValidationsClient_ValidateOrganizationV2() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewValidationsClient().ValidateOrganizationV2(ctx, "myResourceGroup", "myOrganization", armconfluent.OrganizationResource{ + Location: to.Ptr("West US"), + Properties: &armconfluent.OrganizationResourceProperties{ + OfferDetail: &armconfluent.OfferDetail{ + ID: to.Ptr("string"), + PlanID: to.Ptr("string"), + PlanName: to.Ptr("string"), + PrivateOfferID: to.Ptr("string"), + PrivateOfferIDs: []*string{ + to.Ptr("string")}, + PublisherID: to.Ptr("string"), + TermUnit: to.Ptr("string"), + }, + UserDetail: &armconfluent.UserDetail{ + AADEmail: to.Ptr("abc@microsoft.com"), + EmailAddress: to.Ptr("abc@microsoft.com"), + FirstName: to.Ptr("string"), + LastName: to.Ptr("string"), + UserPrincipalName: to.Ptr("abc@microsoft.com"), + }, + }, + Tags: map[string]*string{ + "Environment": to.Ptr("Dev"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ValidationResponse = armconfluent.ValidationResponse{ + // Info: map[string]*string{ + // "displayMessage": to.Ptr("This is display message"), // }, // } } From 8cfb202ab5f35ca893782d0f7e70351d77f05fc3 Mon Sep 17 00:00:00 2001 From: Alancere <804873052@qq.com> Date: Wed, 15 Nov 2023 17:59:20 +0800 Subject: [PATCH 2/3] readme --- .../confluent/armconfluent/CHANGELOG.md | 11 +---------- sdk/resourcemanager/confluent/armconfluent/README.md | 7 +++++++ .../armconfluent/access_client_example_test.go | 2 +- .../confluent/armconfluent/autorest.md | 2 +- .../confluent/armconfluent/constants.go | 2 +- sdk/resourcemanager/confluent/armconfluent/go.mod | 3 +-- sdk/resourcemanager/confluent/armconfluent/go.sum | 2 -- .../marketplaceagreements_client_example_test.go | 2 +- .../armconfluent/organization_client_example_test.go | 2 +- .../organizationoperations_client_example_test.go | 2 +- .../armconfluent/validations_client_example_test.go | 2 +- 11 files changed, 16 insertions(+), 21 deletions(-) diff --git a/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md b/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md index 25fec089c729..698885962c4e 100644 --- a/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md +++ b/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md @@ -1,12 +1,6 @@ # Release History -## 2.0.0 (2023-11-24) -### Breaking Changes - -- Function `timeRFC3339.MarshalText` has been removed -- Function `*timeRFC3339.Parse` has been removed -- Function `*timeRFC3339.UnmarshalText` has been removed - +## 1.2.0 (2023-11-24) ### Features Added - New function `NewAccessClient(string, azcore.TokenCredential, *arm.ClientOptions) (*AccessClient, error)` @@ -19,9 +13,6 @@ - New function `*AccessClient.ListUsers(context.Context, string, string, ListAccessRequestModel, *AccessClientListUsersOptions) (AccessClientListUsersResponse, error)` - New function `*ClientFactory.NewAccessClient() *AccessClient` - New function `*ValidationsClient.ValidateOrganizationV2(context.Context, string, string, OrganizationResource, *ValidationsClientValidateOrganizationV2Options) (ValidationsClientValidateOrganizationV2Response, error)` -- New function `dateTimeRFC3339.MarshalText() ([]byte, error)` -- New function `*dateTimeRFC3339.Parse(string) error` -- New function `*dateTimeRFC3339.UnmarshalText([]byte) error` - New struct `AccessInviteUserAccountModel` - New struct `AccessInvitedUserDetails` - New struct `AccessListClusterSuccessResponse` diff --git a/sdk/resourcemanager/confluent/armconfluent/README.md b/sdk/resourcemanager/confluent/armconfluent/README.md index 9477dd05cb68..84869ddd4158 100644 --- a/sdk/resourcemanager/confluent/armconfluent/README.md +++ b/sdk/resourcemanager/confluent/armconfluent/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewOrganizationClient() ``` +## 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/confluent/armconfluent/access_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/access_client_example_test.go index 5b0f928256b5..c467262798dd 100644 --- a/sdk/resourcemanager/confluent/armconfluent/access_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/access_client_example_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" ) // Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Access_UsersList.json diff --git a/sdk/resourcemanager/confluent/armconfluent/autorest.md b/sdk/resourcemanager/confluent/armconfluent/autorest.md index 05374c4b4882..ebadecac6ec3 100644 --- a/sdk/resourcemanager/confluent/armconfluent/autorest.md +++ b/sdk/resourcemanager/confluent/armconfluent/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.0.0 +module-version: 1.2.0 tag: package-2023-08-22 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/confluent/armconfluent/constants.go b/sdk/resourcemanager/confluent/armconfluent/constants.go index f68c7db2343f..df723e5fc182 100644 --- a/sdk/resourcemanager/confluent/armconfluent/constants.go +++ b/sdk/resourcemanager/confluent/armconfluent/constants.go @@ -10,7 +10,7 @@ package armconfluent const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" - moduleVersion = "v2.0.0" + moduleVersion = "v1.2.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/confluent/armconfluent/go.mod b/sdk/resourcemanager/confluent/armconfluent/go.mod index 24190a237ff8..4162342af3f8 100644 --- a/sdk/resourcemanager/confluent/armconfluent/go.mod +++ b/sdk/resourcemanager/confluent/armconfluent/go.mod @@ -1,11 +1,10 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2 +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent v1.1.0 ) require ( diff --git a/sdk/resourcemanager/confluent/armconfluent/go.sum b/sdk/resourcemanager/confluent/armconfluent/go.sum index c02253b17e0c..7985f1da436f 100644 --- a/sdk/resourcemanager/confluent/armconfluent/go.sum +++ b/sdk/resourcemanager/confluent/armconfluent/go.sum @@ -4,8 +4,6 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZM 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/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent v1.1.0 h1:dFEPMqZ4Dn+y//QuFAeGnHTeQPZj3B8ezD3DdoRt9Po= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent v1.1.0/go.mod h1:Pu4wYu9Y3o/2IGMNpb9uw/Dx2bwz69WtDbZB+QfgozU= 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= diff --git a/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go index a400cc0c9bdd..3135729a48c9 100644 --- a/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go @@ -14,7 +14,7 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" ) // Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/MarketplaceAgreements_List.json diff --git a/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go index 94007a905e5b..18999b4b5123 100644 --- a/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" ) // Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Organization_ListBySubscription.json diff --git a/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go index a8114b4c9ea6..0e083960996b 100644 --- a/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go @@ -14,7 +14,7 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" ) // Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/OrganizationOperations_List.json diff --git a/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go index 096ca7d4a024..0a65797fe683 100644 --- a/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go +++ b/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" ) // Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/confluent/resource-manager/Microsoft.Confluent/stable/2023-08-22/examples/Validations_ValidateOrganizations.json From 042a421d690b4e2db4a47b8bc045566c91d44877 Mon Sep 17 00:00:00 2001 From: Peng Jiahui <46921893+Alancere@users.noreply.github.com> Date: Fri, 17 Nov 2023 17:13:15 +0800 Subject: [PATCH 3/3] Update CHANGELOG.md --- sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md b/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md index 698885962c4e..5e6dff6bdfad 100644 --- a/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md +++ b/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.2.0 (2023-11-24) ### Features Added +- Support for test fakes and OpenTelemetry trace spans. - New function `NewAccessClient(string, azcore.TokenCredential, *arm.ClientOptions) (*AccessClient, error)` - New function `*AccessClient.InviteUser(context.Context, string, string, AccessInviteUserAccountModel, *AccessClientInviteUserOptions) (AccessClientInviteUserResponse, error)` - New function `*AccessClient.ListClusters(context.Context, string, string, ListAccessRequestModel, *AccessClientListClustersOptions) (AccessClientListClustersResponse, error)` @@ -55,4 +56,4 @@ The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/ To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/azsdk/go/mgmt/migration). -To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt).