diff --git a/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md b/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md index 1dea7ee44d9b..5509317f92d6 100644 --- a/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md +++ b/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md @@ -1,5 +1,55 @@ # Release History +## 0.6.0 (2024-08-02) +### Breaking Changes + +- Type of `GitHubWorkflowProfile.DeploymentProperties` has been changed from `*DeploymentProperties` to `*Deployment` +- Struct `DeploymentProperties` has been removed + +### Features Added + +- New enum type `QuickStartTemplateType` with values `QuickStartTemplateTypeHCI`, `QuickStartTemplateTypeHCIAKS`, `QuickStartTemplateTypeHCIARCVM`, `QuickStartTemplateTypeNone` +- New function `NewADOOAuthClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ADOOAuthClient, error)` +- New function `*ADOOAuthClient.Get(context.Context, string, *ADOOAuthClientGetOptions) (ADOOAuthClientGetResponse, error)` +- New function `*ADOOAuthClient.NewListPager(string, *ADOOAuthClientListOptions) *runtime.Pager[ADOOAuthClientListResponse]` +- New function `*ClientFactory.NewADOOAuthClient() *ADOOAuthClient` +- New function `*ClientFactory.NewIacProfilesClient() *IacProfilesClient` +- New function `*DeveloperHubServiceClient.GetADOOAuthInfo(context.Context, string, *DeveloperHubServiceClientGetADOOAuthInfoOptions) (DeveloperHubServiceClientGetADOOAuthInfoResponse, error)` +- New function `NewIacProfilesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*IacProfilesClient, error)` +- New function `*IacProfilesClient.CreateOrUpdate(context.Context, string, string, IacProfile, *IacProfilesClientCreateOrUpdateOptions) (IacProfilesClientCreateOrUpdateResponse, error)` +- New function `*IacProfilesClient.Delete(context.Context, string, string, *IacProfilesClientDeleteOptions) (IacProfilesClientDeleteResponse, error)` +- New function `*IacProfilesClient.Export(context.Context, string, string, ExportTemplateRequest, *IacProfilesClientExportOptions) (IacProfilesClientExportResponse, error)` +- New function `*IacProfilesClient.Get(context.Context, string, string, *IacProfilesClientGetOptions) (IacProfilesClientGetResponse, error)` +- New function `*IacProfilesClient.NewListByResourceGroupPager(string, *IacProfilesClientListByResourceGroupOptions) *runtime.Pager[IacProfilesClientListByResourceGroupResponse]` +- New function `*IacProfilesClient.NewListPager(*IacProfilesClientListOptions) *runtime.Pager[IacProfilesClientListResponse]` +- New function `*IacProfilesClient.Scale(context.Context, string, string, ScaleTemplateRequest, *IacProfilesClientScaleOptions) (IacProfilesClientScaleResponse, error)` +- New function `*IacProfilesClient.Sync(context.Context, string, string, *IacProfilesClientSyncOptions) (IacProfilesClientSyncResponse, error)` +- New function `*IacProfilesClient.UpdateTags(context.Context, string, string, TagsObject, *IacProfilesClientUpdateTagsOptions) (IacProfilesClientUpdateTagsResponse, error)` +- New struct `ADOOAuth` +- New struct `ADOOAuthCallRequest` +- New struct `ADOOAuthInfoResponse` +- New struct `ADOOAuthListResponse` +- New struct `ADOOAuthResponse` +- New struct `ADORepository` +- New struct `AzurePipelineProfile` +- New struct `Build` +- New struct `Deployment` +- New struct `ExportTemplateRequest` +- New struct `IacGitHubProfile` +- New struct `IacProfile` +- New struct `IacProfileListResult` +- New struct `IacProfileProperties` +- New struct `IacTemplateDetails` +- New struct `IacTemplateProperties` +- New struct `PrLinkResponse` +- New struct `PullRequest` +- New struct `ScaleProperty` +- New struct `ScaleTemplateRequest` +- New struct `StageProperties` +- New struct `TerraformProfile` +- New field `AzurePipelineProfile` in struct `WorkflowProperties` + + ## 0.5.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/devhub/armdevhub/README.md b/sdk/resourcemanager/devhub/armdevhub/README.md index a53ac8e8b445..58c33b8a6fb5 100644 --- a/sdk/resourcemanager/devhub/armdevhub/README.md +++ b/sdk/resourcemanager/devhub/armdevhub/README.md @@ -57,7 +57,7 @@ clientFactory, err := armdevhub.NewClientFactory(, cred, &optio A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewWorkflowClient() +client := clientFactory.NewADOOAuthClient() ``` ## Fakes diff --git a/sdk/resourcemanager/devhub/armdevhub/adooauth_client.go b/sdk/resourcemanager/devhub/armdevhub/adooauth_client.go new file mode 100644 index 000000000000..5e19904517c0 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/adooauth_client.go @@ -0,0 +1,162 @@ +//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 armdevhub + +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" +) + +// ADOOAuthClient contains the methods for the ADOOAuth group. +// Don't use this type directly, use NewADOOAuthClient() instead. +type ADOOAuthClient struct { + internal *arm.Client + subscriptionID string +} + +// NewADOOAuthClient creates a new instance of ADOOAuthClient 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 NewADOOAuthClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ADOOAuthClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ADOOAuthClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Callback URL to hit once authenticated with Entra ID to have the service store the OAuth token. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - location - The name of the Azure region. +// - options - ADOOAuthClientGetOptions contains the optional parameters for the ADOOAuthClient.Get method. +func (client *ADOOAuthClient) Get(ctx context.Context, location string, options *ADOOAuthClientGetOptions) (ADOOAuthClientGetResponse, error) { + var err error + const operationName = "ADOOAuthClient.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, location, options) + if err != nil { + return ADOOAuthClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ADOOAuthClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ADOOAuthClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ADOOAuthClient) getCreateRequest(ctx context.Context, location string, options *ADOOAuthClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/adooauth/default" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ADOOAuthClient) getHandleResponse(resp *http.Response) (ADOOAuthClientGetResponse, error) { + result := ADOOAuthClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ADOOAuthResponse); err != nil { + return ADOOAuthClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Callback URL to hit once authenticated with ADO to have the service store the OAuth token. +// +// Generated from API version 2024-08-01-preview +// - location - The name of the Azure region. +// - options - ADOOAuthClientListOptions contains the optional parameters for the ADOOAuthClient.NewListPager method. +func (client *ADOOAuthClient) NewListPager(location string, options *ADOOAuthClientListOptions) *runtime.Pager[ADOOAuthClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ADOOAuthClientListResponse]{ + More: func(page ADOOAuthClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ADOOAuthClientListResponse) (ADOOAuthClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ADOOAuthClient.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, location, options) + }, nil) + if err != nil { + return ADOOAuthClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ADOOAuthClient) listCreateRequest(ctx context.Context, location string, options *ADOOAuthClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/adooauth" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ADOOAuthClient) listHandleResponse(resp *http.Response) (ADOOAuthClientListResponse, error) { + result := ADOOAuthClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ADOOAuthListResponse); err != nil { + return ADOOAuthClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/autorest.md b/sdk/resourcemanager/devhub/armdevhub/autorest.md index b2d899c373a6..c36899b69bf2 100644 --- a/sdk/resourcemanager/devhub/armdevhub/autorest.md +++ b/sdk/resourcemanager/devhub/armdevhub/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/developerhub/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/developerhub/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.5.0 -tag: package-preview-2022-10 +module-version: 0.6.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/devhub/armdevhub/client_factory.go b/sdk/resourcemanager/devhub/armdevhub/client_factory.go index 463513523002..a187901ddbf5 100644 --- a/sdk/resourcemanager/devhub/armdevhub/client_factory.go +++ b/sdk/resourcemanager/devhub/armdevhub/client_factory.go @@ -17,40 +17,60 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID of the target subscription. +// - 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, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } +// NewADOOAuthClient creates a new instance of ADOOAuthClient. +func (c *ClientFactory) NewADOOAuthClient() *ADOOAuthClient { + return &ADOOAuthClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + // NewDeveloperHubServiceClient creates a new instance of DeveloperHubServiceClient. func (c *ClientFactory) NewDeveloperHubServiceClient() *DeveloperHubServiceClient { - subClient, _ := NewDeveloperHubServiceClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DeveloperHubServiceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewIacProfilesClient creates a new instance of IacProfilesClient. +func (c *ClientFactory) NewIacProfilesClient() *IacProfilesClient { + return &IacProfilesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } // NewWorkflowClient creates a new instance of WorkflowClient. func (c *ClientFactory) NewWorkflowClient() *WorkflowClient { - subClient, _ := NewWorkflowClient(c.subscriptionID, c.credential, c.options) - return subClient + return &WorkflowClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/devhub/armdevhub/constants.go b/sdk/resourcemanager/devhub/armdevhub/constants.go index 43757affea50..7a13bd12f9db 100644 --- a/sdk/resourcemanager/devhub/armdevhub/constants.go +++ b/sdk/resourcemanager/devhub/armdevhub/constants.go @@ -10,7 +10,7 @@ package armdevhub const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -234,6 +234,30 @@ func PossiblePullRequestStatusValues() []PullRequestStatus { } } +// QuickStartTemplateType - Determines the authorization status of requests. +type QuickStartTemplateType string + +const ( + // QuickStartTemplateTypeHCI - The template use quick start template of HCI + QuickStartTemplateTypeHCI QuickStartTemplateType = "HCI" + // QuickStartTemplateTypeHCIAKS - The template use quick start template of HCI and AKS + QuickStartTemplateTypeHCIAKS QuickStartTemplateType = "HCIAKS" + // QuickStartTemplateTypeHCIARCVM - The template use quick start template of HCI and ArcVM + QuickStartTemplateTypeHCIARCVM QuickStartTemplateType = "HCIARCVM" + // QuickStartTemplateTypeNone - The template has not use quick start template + QuickStartTemplateTypeNone QuickStartTemplateType = "None" +) + +// PossibleQuickStartTemplateTypeValues returns the possible values for the QuickStartTemplateType const type. +func PossibleQuickStartTemplateTypeValues() []QuickStartTemplateType { + return []QuickStartTemplateType{ + QuickStartTemplateTypeHCI, + QuickStartTemplateTypeHCIAKS, + QuickStartTemplateTypeHCIARCVM, + QuickStartTemplateTypeNone, + } +} + // WorkflowRunStatus - Describes the status of the workflow run type WorkflowRunStatus string diff --git a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go index 616793f4b0a6..122e8f0095ef 100644 --- a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go +++ b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go @@ -28,7 +28,7 @@ type DeveloperHubServiceClient struct { } // NewDeveloperHubServiceClient creates a new instance of DeveloperHubServiceClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewDeveloperHubServiceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeveloperHubServiceClient, error) { @@ -46,8 +46,8 @@ func NewDeveloperHubServiceClient(subscriptionID string, credential azcore.Token // GeneratePreviewArtifacts - Generate preview dockerfile and manifests. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview -// - location - The name of Azure region. +// Generated from API version 2024-08-01-preview +// - location - The name of the Azure region. // - options - DeveloperHubServiceClientGeneratePreviewArtifactsOptions contains the optional parameters for the DeveloperHubServiceClient.GeneratePreviewArtifacts // method. func (client *DeveloperHubServiceClient) GeneratePreviewArtifacts(ctx context.Context, location string, parameters ArtifactGenerationProperties, options *DeveloperHubServiceClientGeneratePreviewArtifactsOptions) (DeveloperHubServiceClientGeneratePreviewArtifactsResponse, error) { @@ -88,7 +88,7 @@ func (client *DeveloperHubServiceClient) generatePreviewArtifactsCreateRequest(c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -106,11 +106,77 @@ func (client *DeveloperHubServiceClient) generatePreviewArtifactsHandleResponse( return result, nil } +// GetADOOAuthInfo - Gets ADOOAuth info used to authenticate users with ADO. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - location - The name of the Azure region. +// - options - DeveloperHubServiceClientGetADOOAuthInfoOptions contains the optional parameters for the DeveloperHubServiceClient.GetADOOAuthInfo +// method. +func (client *DeveloperHubServiceClient) GetADOOAuthInfo(ctx context.Context, location string, options *DeveloperHubServiceClientGetADOOAuthInfoOptions) (DeveloperHubServiceClientGetADOOAuthInfoResponse, error) { + var err error + const operationName = "DeveloperHubServiceClient.GetADOOAuthInfo" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getADOOAuthInfoCreateRequest(ctx, location, options) + if err != nil { + return DeveloperHubServiceClientGetADOOAuthInfoResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeveloperHubServiceClientGetADOOAuthInfoResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DeveloperHubServiceClientGetADOOAuthInfoResponse{}, err + } + resp, err := client.getADOOAuthInfoHandleResponse(httpResp) + return resp, err +} + +// getADOOAuthInfoCreateRequest creates the GetADOOAuthInfo request. +func (client *DeveloperHubServiceClient) getADOOAuthInfoCreateRequest(ctx context.Context, location string, options *DeveloperHubServiceClientGetADOOAuthInfoOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/adooauth/default/getADOOAuthInfo" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + 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", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Parameters != nil { + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil + } + return req, nil +} + +// getADOOAuthInfoHandleResponse handles the GetADOOAuthInfo response. +func (client *DeveloperHubServiceClient) getADOOAuthInfoHandleResponse(resp *http.Response) (DeveloperHubServiceClientGetADOOAuthInfoResponse, error) { + result := DeveloperHubServiceClientGetADOOAuthInfoResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ADOOAuthInfoResponse); err != nil { + return DeveloperHubServiceClientGetADOOAuthInfoResponse{}, err + } + return result, nil +} + // GitHubOAuth - Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview -// - location - The name of Azure region. +// Generated from API version 2024-08-01-preview +// - location - The name of the Azure region. // - options - DeveloperHubServiceClientGitHubOAuthOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuth // method. func (client *DeveloperHubServiceClient) GitHubOAuth(ctx context.Context, location string, options *DeveloperHubServiceClientGitHubOAuthOptions) (DeveloperHubServiceClientGitHubOAuthResponse, error) { @@ -151,7 +217,7 @@ func (client *DeveloperHubServiceClient) gitHubOAuthCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { @@ -175,8 +241,8 @@ func (client *DeveloperHubServiceClient) gitHubOAuthHandleResponse(resp *http.Re // GitHubOAuthCallback - Callback URL to hit once authenticated with GitHub App to have the service store the OAuth token. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview -// - location - The name of Azure region. +// Generated from API version 2024-08-01-preview +// - location - The name of the Azure region. // - code - The code response from authenticating the GitHub App. // - state - The state response from authenticating the GitHub App. // - options - DeveloperHubServiceClientGitHubOAuthCallbackOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuthCallback @@ -219,7 +285,7 @@ func (client *DeveloperHubServiceClient) gitHubOAuthCallbackCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") reqQP.Set("code", code) reqQP.Set("state", state) req.Raw().URL.RawQuery = reqQP.Encode() @@ -239,8 +305,8 @@ func (client *DeveloperHubServiceClient) gitHubOAuthCallbackHandleResponse(resp // ListGitHubOAuth - Callback URL to hit once authenticated with GitHub App to have the service store the OAuth token. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview -// - location - The name of Azure region. +// Generated from API version 2024-08-01-preview +// - location - The name of the Azure region. // - options - DeveloperHubServiceClientListGitHubOAuthOptions contains the optional parameters for the DeveloperHubServiceClient.ListGitHubOAuth // method. func (client *DeveloperHubServiceClient) ListGitHubOAuth(ctx context.Context, location string, options *DeveloperHubServiceClientListGitHubOAuthOptions) (DeveloperHubServiceClientListGitHubOAuthResponse, error) { @@ -281,7 +347,7 @@ func (client *DeveloperHubServiceClient) listGitHubOAuthCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client_example_test.go deleted file mode 100644 index 233a19a43cf5..000000000000 --- a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client_example_test.go +++ /dev/null @@ -1,143 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdevhub_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/devhub/armdevhub" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/GitHubOAuth.json -func ExampleDeveloperHubServiceClient_GitHubOAuth() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeveloperHubServiceClient().GitHubOAuth(ctx, "eastus2euap", &armdevhub.DeveloperHubServiceClientGitHubOAuthOptions{Parameters: &armdevhub.GitHubOAuthCallRequest{ - RedirectURL: to.Ptr("https://ms.portal.azure.com/aks"), - }, - }) - 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.GitHubOAuthInfoResponse = armdevhub.GitHubOAuthInfoResponse{ - // AuthURL: to.Ptr("https://github.com/login/oauth/authorize?client_id=11111111&redirect_uri=https://management.azure.com/subscriptions/subscriptionId1/providers/Microsoft.DevHub/locations/eastus2euap/githuboauth&state=2345678-3456-7890-5678-012345678901&scope=repo,user:email,workflow"), - // Token: to.Ptr(""), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/GitHubOAuthCallback.json -func ExampleDeveloperHubServiceClient_GitHubOAuthCallback() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeveloperHubServiceClient().GitHubOAuthCallback(ctx, "eastus2euap", "3584d83530557fdd1f46af8289938c8ef79f9dc5", "12345678-3456-7890-5678-012345678901", 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.GitHubOAuthResponse = armdevhub.GitHubOAuthResponse{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DevHub/locations/githuboauth"), - // ID: to.Ptr("/subscriptions/subscriptionId1/providers/Microsoft.DevHub/locations/eastus2euap/githuboauth/default"), - // Properties: &armdevhub.GitHubOAuthProperties{ - // Username: to.Ptr("user"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/GitHubOAuth_List.json -func ExampleDeveloperHubServiceClient_ListGitHubOAuth() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeveloperHubServiceClient().ListGitHubOAuth(ctx, "eastus2euap", 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.GitHubOAuthListResponse = armdevhub.GitHubOAuthListResponse{ - // Value: []*armdevhub.GitHubOAuthResponse{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DevHub/locations/githuboauth"), - // ID: to.Ptr("/subscriptions/subscriptionId1/providers/Microsoft.DevHub/locations/eastus2euap/githuboauth/default"), - // Properties: &armdevhub.GitHubOAuthProperties{ - // Username: to.Ptr("user"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/GeneratePreviewArtifacts.json -func ExampleDeveloperHubServiceClient_GeneratePreviewArtifacts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeveloperHubServiceClient().GeneratePreviewArtifacts(ctx, "location1", armdevhub.ArtifactGenerationProperties{ - AppName: to.Ptr("my-app"), - DockerfileGenerationMode: to.Ptr(armdevhub.DockerfileGenerationModeEnabled), - DockerfileOutputDirectory: to.Ptr("./"), - GenerationLanguage: to.Ptr(armdevhub.GenerationLanguageJavascript), - ImageName: to.Ptr("myimage"), - ImageTag: to.Ptr("latest"), - LanguageVersion: to.Ptr("14"), - ManifestGenerationMode: to.Ptr(armdevhub.ManifestGenerationModeEnabled), - ManifestOutputDirectory: to.Ptr("./"), - ManifestType: to.Ptr(armdevhub.GenerationManifestTypeKube), - Namespace: to.Ptr("my-namespace"), - Port: to.Ptr("80"), - }, 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.Value = map[string]*string{ - // "dockerfiles/example-dockerfile": to.Ptr("dockerfile-content \n including newlines"), - // "manifests/example-manifest-file-1": to.Ptr("manifest file 1 content \n including newlines"), - // "manifests/example-manifest-file-2": to.Ptr("manifest file 2 content \n including newlines"), - // } -} diff --git a/sdk/resourcemanager/devhub/armdevhub/fake/adooauth_server.go b/sdk/resourcemanager/devhub/armdevhub/fake/adooauth_server.go new file mode 100644 index 000000000000..9014d3836b29 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/fake/adooauth_server.go @@ -0,0 +1,144 @@ +//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/devhub/armdevhub" + "net/http" + "net/url" + "regexp" +) + +// ADOOAuthServer is a fake server for instances of the armdevhub.ADOOAuthClient type. +type ADOOAuthServer struct { + // Get is the fake for method ADOOAuthClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, location string, options *armdevhub.ADOOAuthClientGetOptions) (resp azfake.Responder[armdevhub.ADOOAuthClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ADOOAuthClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(location string, options *armdevhub.ADOOAuthClientListOptions) (resp azfake.PagerResponder[armdevhub.ADOOAuthClientListResponse]) +} + +// NewADOOAuthServerTransport creates a new instance of ADOOAuthServerTransport with the provided implementation. +// The returned ADOOAuthServerTransport instance is connected to an instance of armdevhub.ADOOAuthClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewADOOAuthServerTransport(srv *ADOOAuthServer) *ADOOAuthServerTransport { + return &ADOOAuthServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdevhub.ADOOAuthClientListResponse]](), + } +} + +// ADOOAuthServerTransport connects instances of armdevhub.ADOOAuthClient to instances of ADOOAuthServer. +// Don't use this type directly, use NewADOOAuthServerTransport instead. +type ADOOAuthServerTransport struct { + srv *ADOOAuthServer + newListPager *tracker[azfake.PagerResponder[armdevhub.ADOOAuthClientListResponse]] +} + +// Do implements the policy.Transporter interface for ADOOAuthServerTransport. +func (a *ADOOAuthServerTransport) 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 "ADOOAuthClient.Get": + resp, err = a.dispatchGet(req) + case "ADOOAuthClient.NewListPager": + resp, err = a.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *ADOOAuthServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/adooauth/default` + 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) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), locationParam, 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).ADOOAuthResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ADOOAuthServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := a.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/adooauth` + 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) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListPager(locationParam, nil) + newListPager = &resp + a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdevhub.ADOOAuthClientListResponse, 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) { + a.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + a.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/fake/developerhubservice_server.go b/sdk/resourcemanager/devhub/armdevhub/fake/developerhubservice_server.go index f4ad827bdac2..004929f235f5 100644 --- a/sdk/resourcemanager/devhub/armdevhub/fake/developerhubservice_server.go +++ b/sdk/resourcemanager/devhub/armdevhub/fake/developerhubservice_server.go @@ -28,6 +28,10 @@ type DeveloperHubServiceServer struct { // HTTP status codes to indicate success: http.StatusOK GeneratePreviewArtifacts func(ctx context.Context, location string, parameters armdevhub.ArtifactGenerationProperties, options *armdevhub.DeveloperHubServiceClientGeneratePreviewArtifactsOptions) (resp azfake.Responder[armdevhub.DeveloperHubServiceClientGeneratePreviewArtifactsResponse], errResp azfake.ErrorResponder) + // GetADOOAuthInfo is the fake for method DeveloperHubServiceClient.GetADOOAuthInfo + // HTTP status codes to indicate success: http.StatusOK + GetADOOAuthInfo func(ctx context.Context, location string, options *armdevhub.DeveloperHubServiceClientGetADOOAuthInfoOptions) (resp azfake.Responder[armdevhub.DeveloperHubServiceClientGetADOOAuthInfoResponse], errResp azfake.ErrorResponder) + // GitHubOAuth is the fake for method DeveloperHubServiceClient.GitHubOAuth // HTTP status codes to indicate success: http.StatusOK GitHubOAuth func(ctx context.Context, location string, options *armdevhub.DeveloperHubServiceClientGitHubOAuthOptions) (resp azfake.Responder[armdevhub.DeveloperHubServiceClientGitHubOAuthResponse], errResp azfake.ErrorResponder) @@ -68,6 +72,8 @@ func (d *DeveloperHubServiceServerTransport) Do(req *http.Request) (*http.Respon switch method { case "DeveloperHubServiceClient.GeneratePreviewArtifacts": resp, err = d.dispatchGeneratePreviewArtifacts(req) + case "DeveloperHubServiceClient.GetADOOAuthInfo": + resp, err = d.dispatchGetADOOAuthInfo(req) case "DeveloperHubServiceClient.GitHubOAuth": resp, err = d.dispatchGitHubOAuth(req) case "DeveloperHubServiceClient.GitHubOAuthCallback": @@ -118,6 +124,45 @@ func (d *DeveloperHubServiceServerTransport) dispatchGeneratePreviewArtifacts(re return resp, nil } +func (d *DeveloperHubServiceServerTransport) dispatchGetADOOAuthInfo(req *http.Request) (*http.Response, error) { + if d.srv.GetADOOAuthInfo == nil { + return nil, &nonRetriableError{errors.New("fake for method GetADOOAuthInfo not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/adooauth/default/getADOOAuthInfo` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdevhub.ADOOAuthCallRequest](req) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + var options *armdevhub.DeveloperHubServiceClientGetADOOAuthInfoOptions + if !reflect.ValueOf(body).IsZero() { + options = &armdevhub.DeveloperHubServiceClientGetADOOAuthInfoOptions{ + Parameters: &body, + } + } + respr, errRespr := d.srv.GetADOOAuthInfo(req.Context(), locationParam, 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).ADOOAuthInfoResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (d *DeveloperHubServiceServerTransport) dispatchGitHubOAuth(req *http.Request) (*http.Response, error) { if d.srv.GitHubOAuth == nil { return nil, &nonRetriableError{errors.New("fake for method GitHubOAuth not implemented")} diff --git a/sdk/resourcemanager/devhub/armdevhub/fake/iacprofiles_server.go b/sdk/resourcemanager/devhub/armdevhub/fake/iacprofiles_server.go new file mode 100644 index 000000000000..2c3979393dc0 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/fake/iacprofiles_server.go @@ -0,0 +1,439 @@ +//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/devhub/armdevhub" + "net/http" + "net/url" + "regexp" +) + +// IacProfilesServer is a fake server for instances of the armdevhub.IacProfilesClient type. +type IacProfilesServer struct { + // CreateOrUpdate is the fake for method IacProfilesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, iacProfileName string, parameters armdevhub.IacProfile, options *armdevhub.IacProfilesClientCreateOrUpdateOptions) (resp azfake.Responder[armdevhub.IacProfilesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IacProfilesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, iacProfileName string, options *armdevhub.IacProfilesClientDeleteOptions) (resp azfake.Responder[armdevhub.IacProfilesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Export is the fake for method IacProfilesClient.Export + // HTTP status codes to indicate success: http.StatusOK + Export func(ctx context.Context, resourceGroupName string, iacProfileName string, parameters armdevhub.ExportTemplateRequest, options *armdevhub.IacProfilesClientExportOptions) (resp azfake.Responder[armdevhub.IacProfilesClientExportResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IacProfilesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, iacProfileName string, options *armdevhub.IacProfilesClientGetOptions) (resp azfake.Responder[armdevhub.IacProfilesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IacProfilesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armdevhub.IacProfilesClientListOptions) (resp azfake.PagerResponder[armdevhub.IacProfilesClientListResponse]) + + // NewListByResourceGroupPager is the fake for method IacProfilesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armdevhub.IacProfilesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armdevhub.IacProfilesClientListByResourceGroupResponse]) + + // Scale is the fake for method IacProfilesClient.Scale + // HTTP status codes to indicate success: http.StatusOK + Scale func(ctx context.Context, resourceGroupName string, iacProfileName string, parameters armdevhub.ScaleTemplateRequest, options *armdevhub.IacProfilesClientScaleOptions) (resp azfake.Responder[armdevhub.IacProfilesClientScaleResponse], errResp azfake.ErrorResponder) + + // Sync is the fake for method IacProfilesClient.Sync + // HTTP status codes to indicate success: http.StatusOK + Sync func(ctx context.Context, resourceGroupName string, iacProfileName string, options *armdevhub.IacProfilesClientSyncOptions) (resp azfake.Responder[armdevhub.IacProfilesClientSyncResponse], errResp azfake.ErrorResponder) + + // UpdateTags is the fake for method IacProfilesClient.UpdateTags + // HTTP status codes to indicate success: http.StatusOK + UpdateTags func(ctx context.Context, resourceGroupName string, iacProfileName string, parameters armdevhub.TagsObject, options *armdevhub.IacProfilesClientUpdateTagsOptions) (resp azfake.Responder[armdevhub.IacProfilesClientUpdateTagsResponse], errResp azfake.ErrorResponder) +} + +// NewIacProfilesServerTransport creates a new instance of IacProfilesServerTransport with the provided implementation. +// The returned IacProfilesServerTransport instance is connected to an instance of armdevhub.IacProfilesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIacProfilesServerTransport(srv *IacProfilesServer) *IacProfilesServerTransport { + return &IacProfilesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdevhub.IacProfilesClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armdevhub.IacProfilesClientListByResourceGroupResponse]](), + } +} + +// IacProfilesServerTransport connects instances of armdevhub.IacProfilesClient to instances of IacProfilesServer. +// Don't use this type directly, use NewIacProfilesServerTransport instead. +type IacProfilesServerTransport struct { + srv *IacProfilesServer + newListPager *tracker[azfake.PagerResponder[armdevhub.IacProfilesClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armdevhub.IacProfilesClientListByResourceGroupResponse]] +} + +// Do implements the policy.Transporter interface for IacProfilesServerTransport. +func (i *IacProfilesServerTransport) 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 "IacProfilesClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IacProfilesClient.Delete": + resp, err = i.dispatchDelete(req) + case "IacProfilesClient.Export": + resp, err = i.dispatchExport(req) + case "IacProfilesClient.Get": + resp, err = i.dispatchGet(req) + case "IacProfilesClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + case "IacProfilesClient.NewListByResourceGroupPager": + resp, err = i.dispatchNewListByResourceGroupPager(req) + case "IacProfilesClient.Scale": + resp, err = i.dispatchScale(req) + case "IacProfilesClient.Sync": + resp, err = i.dispatchSync(req) + case "IacProfilesClient.UpdateTags": + resp, err = i.dispatchUpdateTags(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles/(?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[armdevhub.IacProfile](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + iacProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iacProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, iacProfileNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).IacProfile, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles/(?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 + } + iacProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iacProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, iacProfileNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchExport(req *http.Request) (*http.Response, error) { + if i.srv.Export == nil { + return nil, &nonRetriableError{errors.New("fake for method Export not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/export` + 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[armdevhub.ExportTemplateRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + iacProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iacProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Export(req.Context(), resourceGroupNameParam, iacProfileNameParam, 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).PrLinkResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles/(?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 + } + iacProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iacProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, iacProfileNameParam, 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).IacProfile, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles` + 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 := i.srv.NewListPager(nil) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdevhub.IacProfilesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := i.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles` + 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 := i.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + i.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armdevhub.IacProfilesClientListByResourceGroupResponse, 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) { + i.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + i.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchScale(req *http.Request) (*http.Response, error) { + if i.srv.Scale == nil { + return nil, &nonRetriableError{errors.New("fake for method Scale not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scale` + 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[armdevhub.ScaleTemplateRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + iacProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iacProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Scale(req.Context(), resourceGroupNameParam, iacProfileNameParam, 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).PrLinkResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchSync(req *http.Request) (*http.Response, error) { + if i.srv.Sync == nil { + return nil, &nonRetriableError{errors.New("fake for method Sync not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sync` + 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 + } + iacProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iacProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Sync(req.Context(), resourceGroupNameParam, iacProfileNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IacProfilesServerTransport) dispatchUpdateTags(req *http.Request) (*http.Response, error) { + if i.srv.UpdateTags == nil { + return nil, &nonRetriableError{errors.New("fake for method UpdateTags not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevHub/iacProfiles/(?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[armdevhub.TagsObject](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + iacProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iacProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.UpdateTags(req.Context(), resourceGroupNameParam, iacProfileNameParam, 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).IacProfile, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/fake/server_factory.go b/sdk/resourcemanager/devhub/armdevhub/fake/server_factory.go index 113df1907c49..6419ed3189d1 100644 --- a/sdk/resourcemanager/devhub/armdevhub/fake/server_factory.go +++ b/sdk/resourcemanager/devhub/armdevhub/fake/server_factory.go @@ -19,7 +19,9 @@ import ( // ServerFactory is a fake server for instances of the armdevhub.ClientFactory type. type ServerFactory struct { + ADOOAuthServer ADOOAuthServer DeveloperHubServiceServer DeveloperHubServiceServer + IacProfilesServer IacProfilesServer OperationsServer OperationsServer WorkflowServer WorkflowServer } @@ -38,7 +40,9 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { type ServerFactoryTransport struct { srv *ServerFactory trMu sync.Mutex + trADOOAuthServer *ADOOAuthServerTransport trDeveloperHubServiceServer *DeveloperHubServiceServerTransport + trIacProfilesServer *IacProfilesServerTransport trOperationsServer *OperationsServerTransport trWorkflowServer *WorkflowServerTransport } @@ -56,11 +60,17 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { + case "ADOOAuthClient": + initServer(s, &s.trADOOAuthServer, func() *ADOOAuthServerTransport { return NewADOOAuthServerTransport(&s.srv.ADOOAuthServer) }) + resp, err = s.trADOOAuthServer.Do(req) case "DeveloperHubServiceClient": initServer(s, &s.trDeveloperHubServiceServer, func() *DeveloperHubServiceServerTransport { return NewDeveloperHubServiceServerTransport(&s.srv.DeveloperHubServiceServer) }) resp, err = s.trDeveloperHubServiceServer.Do(req) + case "IacProfilesClient": + initServer(s, &s.trIacProfilesServer, func() *IacProfilesServerTransport { return NewIacProfilesServerTransport(&s.srv.IacProfilesServer) }) + resp, err = s.trIacProfilesServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) diff --git a/sdk/resourcemanager/devhub/armdevhub/fake/time_rfc3339.go b/sdk/resourcemanager/devhub/armdevhub/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/devhub/armdevhub/fake/time_rfc3339.go +++ b/sdk/resourcemanager/devhub/armdevhub/fake/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/devhub/armdevhub/go.mod b/sdk/resourcemanager/devhub/armdevhub/go.mod index 596d89070f42..7acfe20b9845 100644 --- a/sdk/resourcemanager/devhub/armdevhub/go.mod +++ b/sdk/resourcemanager/devhub/armdevhub/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/devhub/armdevhub/go.sum b/sdk/resourcemanager/devhub/armdevhub/go.sum index 09d275cb9a37..917448a001b7 100644 --- a/sdk/resourcemanager/devhub/armdevhub/go.sum +++ b/sdk/resourcemanager/devhub/armdevhub/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/devhub/armdevhub/iacprofiles_client.go b/sdk/resourcemanager/devhub/armdevhub/iacprofiles_client.go new file mode 100644 index 000000000000..621cc95fa744 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/iacprofiles_client.go @@ -0,0 +1,600 @@ +//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 armdevhub + +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" +) + +// IacProfilesClient contains the methods for the IacProfiles group. +// Don't use this type directly, use NewIacProfilesClient() instead. +type IacProfilesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewIacProfilesClient creates a new instance of IacProfilesClient 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 NewIacProfilesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IacProfilesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &IacProfilesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a IacProfile +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - iacProfileName - The name of the IacProfile. +// - options - IacProfilesClientCreateOrUpdateOptions contains the optional parameters for the IacProfilesClient.CreateOrUpdate +// method. +func (client *IacProfilesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, iacProfileName string, parameters IacProfile, options *IacProfilesClientCreateOrUpdateOptions) (IacProfilesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IacProfilesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, iacProfileName, parameters, options) + if err != nil { + return IacProfilesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IacProfilesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IacProfilesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *IacProfilesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, iacProfileName string, parameters IacProfile, options *IacProfilesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}" + 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 iacProfileName == "" { + return nil, errors.New("parameter iacProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{iacProfileName}", url.PathEscape(iacProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *IacProfilesClient) createOrUpdateHandleResponse(resp *http.Response) (IacProfilesClientCreateOrUpdateResponse, error) { + result := IacProfilesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IacProfile); err != nil { + return IacProfilesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a IacProfile +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - iacProfileName - The name of the IacProfile. +// - options - IacProfilesClientDeleteOptions contains the optional parameters for the IacProfilesClient.Delete method. +func (client *IacProfilesClient) Delete(ctx context.Context, resourceGroupName string, iacProfileName string, options *IacProfilesClientDeleteOptions) (IacProfilesClientDeleteResponse, error) { + var err error + const operationName = "IacProfilesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, iacProfileName, options) + if err != nil { + return IacProfilesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IacProfilesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IacProfilesClientDeleteResponse{}, err + } + return IacProfilesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *IacProfilesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, iacProfileName string, options *IacProfilesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}" + 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 iacProfileName == "" { + return nil, errors.New("parameter iacProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{iacProfileName}", url.PathEscape(iacProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Export - Export a template +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - iacProfileName - The name of the IacProfile. +// - options - IacProfilesClientExportOptions contains the optional parameters for the IacProfilesClient.Export method. +func (client *IacProfilesClient) Export(ctx context.Context, resourceGroupName string, iacProfileName string, parameters ExportTemplateRequest, options *IacProfilesClientExportOptions) (IacProfilesClientExportResponse, error) { + var err error + const operationName = "IacProfilesClient.Export" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.exportCreateRequest(ctx, resourceGroupName, iacProfileName, parameters, options) + if err != nil { + return IacProfilesClientExportResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IacProfilesClientExportResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IacProfilesClientExportResponse{}, err + } + resp, err := client.exportHandleResponse(httpResp) + return resp, err +} + +// exportCreateRequest creates the Export request. +func (client *IacProfilesClient) exportCreateRequest(ctx context.Context, resourceGroupName string, iacProfileName string, parameters ExportTemplateRequest, options *IacProfilesClientExportOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}/export" + 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 iacProfileName == "" { + return nil, errors.New("parameter iacProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{iacProfileName}", url.PathEscape(iacProfileName)) + 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", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// exportHandleResponse handles the Export response. +func (client *IacProfilesClient) exportHandleResponse(resp *http.Response) (IacProfilesClientExportResponse, error) { + result := IacProfilesClientExportResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrLinkResponse); err != nil { + return IacProfilesClientExportResponse{}, err + } + return result, nil +} + +// Get - Gets a IacProfile. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - iacProfileName - The name of the IacProfile. +// - options - IacProfilesClientGetOptions contains the optional parameters for the IacProfilesClient.Get method. +func (client *IacProfilesClient) Get(ctx context.Context, resourceGroupName string, iacProfileName string, options *IacProfilesClientGetOptions) (IacProfilesClientGetResponse, error) { + var err error + const operationName = "IacProfilesClient.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, iacProfileName, options) + if err != nil { + return IacProfilesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IacProfilesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IacProfilesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *IacProfilesClient) getCreateRequest(ctx context.Context, resourceGroupName string, iacProfileName string, options *IacProfilesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}" + 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 iacProfileName == "" { + return nil, errors.New("parameter iacProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{iacProfileName}", url.PathEscape(iacProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *IacProfilesClient) getHandleResponse(resp *http.Response) (IacProfilesClientGetResponse, error) { + result := IacProfilesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IacProfile); err != nil { + return IacProfilesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets a list of IacProfiles associated with the specified subscription. +// +// Generated from API version 2024-08-01-preview +// - options - IacProfilesClientListOptions contains the optional parameters for the IacProfilesClient.NewListPager method. +func (client *IacProfilesClient) NewListPager(options *IacProfilesClientListOptions) *runtime.Pager[IacProfilesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[IacProfilesClientListResponse]{ + More: func(page IacProfilesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *IacProfilesClientListResponse) (IacProfilesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IacProfilesClient.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 IacProfilesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *IacProfilesClient) listCreateRequest(ctx context.Context, options *IacProfilesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/iacProfiles" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *IacProfilesClient) listHandleResponse(resp *http.Response) (IacProfilesClientListResponse, error) { + result := IacProfilesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IacProfileListResult); err != nil { + return IacProfilesClientListResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets a list of iacProfiles within a resource group. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - IacProfilesClientListByResourceGroupOptions contains the optional parameters for the IacProfilesClient.NewListByResourceGroupPager +// method. +func (client *IacProfilesClient) NewListByResourceGroupPager(resourceGroupName string, options *IacProfilesClientListByResourceGroupOptions) *runtime.Pager[IacProfilesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[IacProfilesClientListByResourceGroupResponse]{ + More: func(page IacProfilesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *IacProfilesClientListByResourceGroupResponse) (IacProfilesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IacProfilesClient.NewListByResourceGroupPager") + 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.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return IacProfilesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *IacProfilesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *IacProfilesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *IacProfilesClient) listByResourceGroupHandleResponse(resp *http.Response) (IacProfilesClientListByResourceGroupResponse, error) { + result := IacProfilesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IacProfileListResult); err != nil { + return IacProfilesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// Scale - Scale by template +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - iacProfileName - The name of the IacProfile. +// - options - IacProfilesClientScaleOptions contains the optional parameters for the IacProfilesClient.Scale method. +func (client *IacProfilesClient) Scale(ctx context.Context, resourceGroupName string, iacProfileName string, parameters ScaleTemplateRequest, options *IacProfilesClientScaleOptions) (IacProfilesClientScaleResponse, error) { + var err error + const operationName = "IacProfilesClient.Scale" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.scaleCreateRequest(ctx, resourceGroupName, iacProfileName, parameters, options) + if err != nil { + return IacProfilesClientScaleResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IacProfilesClientScaleResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IacProfilesClientScaleResponse{}, err + } + resp, err := client.scaleHandleResponse(httpResp) + return resp, err +} + +// scaleCreateRequest creates the Scale request. +func (client *IacProfilesClient) scaleCreateRequest(ctx context.Context, resourceGroupName string, iacProfileName string, parameters ScaleTemplateRequest, options *IacProfilesClientScaleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}/scale" + 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 iacProfileName == "" { + return nil, errors.New("parameter iacProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{iacProfileName}", url.PathEscape(iacProfileName)) + 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", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// scaleHandleResponse handles the Scale response. +func (client *IacProfilesClient) scaleHandleResponse(resp *http.Response) (IacProfilesClientScaleResponse, error) { + result := IacProfilesClientScaleResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrLinkResponse); err != nil { + return IacProfilesClientScaleResponse{}, err + } + return result, nil +} + +// Sync - Sync template +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - iacProfileName - The name of the IacProfile. +// - options - IacProfilesClientSyncOptions contains the optional parameters for the IacProfilesClient.Sync method. +func (client *IacProfilesClient) Sync(ctx context.Context, resourceGroupName string, iacProfileName string, options *IacProfilesClientSyncOptions) (IacProfilesClientSyncResponse, error) { + var err error + const operationName = "IacProfilesClient.Sync" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.syncCreateRequest(ctx, resourceGroupName, iacProfileName, options) + if err != nil { + return IacProfilesClientSyncResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IacProfilesClientSyncResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IacProfilesClientSyncResponse{}, err + } + return IacProfilesClientSyncResponse{}, nil +} + +// syncCreateRequest creates the Sync request. +func (client *IacProfilesClient) syncCreateRequest(ctx context.Context, resourceGroupName string, iacProfileName string, options *IacProfilesClientSyncOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}/sync" + 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 iacProfileName == "" { + return nil, errors.New("parameter iacProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{iacProfileName}", url.PathEscape(iacProfileName)) + 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", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// UpdateTags - Updates tags on a IacProfile. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - iacProfileName - The name of the IacProfile. +// - parameters - Parameters supplied to the Update TagsObject Tags operation. +// - options - IacProfilesClientUpdateTagsOptions contains the optional parameters for the IacProfilesClient.UpdateTags method. +func (client *IacProfilesClient) UpdateTags(ctx context.Context, resourceGroupName string, iacProfileName string, parameters TagsObject, options *IacProfilesClientUpdateTagsOptions) (IacProfilesClientUpdateTagsResponse, error) { + var err error + const operationName = "IacProfilesClient.UpdateTags" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, iacProfileName, parameters, options) + if err != nil { + return IacProfilesClientUpdateTagsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IacProfilesClientUpdateTagsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IacProfilesClientUpdateTagsResponse{}, err + } + resp, err := client.updateTagsHandleResponse(httpResp) + return resp, err +} + +// updateTagsCreateRequest creates the UpdateTags request. +func (client *IacProfilesClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, iacProfileName string, parameters TagsObject, options *IacProfilesClientUpdateTagsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}" + 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 iacProfileName == "" { + return nil, errors.New("parameter iacProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{iacProfileName}", url.PathEscape(iacProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateTagsHandleResponse handles the UpdateTags response. +func (client *IacProfilesClient) updateTagsHandleResponse(resp *http.Response) (IacProfilesClientUpdateTagsResponse, error) { + result := IacProfilesClientUpdateTagsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IacProfile); err != nil { + return IacProfilesClientUpdateTagsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/models.go b/sdk/resourcemanager/devhub/armdevhub/models.go index 870254c1f8e3..9c59cbc51209 100644 --- a/sdk/resourcemanager/devhub/armdevhub/models.go +++ b/sdk/resourcemanager/devhub/armdevhub/models.go @@ -25,6 +25,72 @@ type ACR struct { AcrSubscriptionID *string } +// ADOOAuth - The properties of ADO OAuth. +type ADOOAuth struct { + // user making request + Username *string +} + +// ADOOAuthCallRequest - ADOOAuth request object +type ADOOAuthCallRequest struct { + // The URL the client will redirect to on successful authentication. If empty, no redirect will occur. + RedirectURL *string +} + +// ADOOAuthInfoResponse - Response containing ADO OAuth information +type ADOOAuthInfoResponse struct { + // URL used to authorize ADO app using Entra ID + AuthURL *string + + // OAuth token used to make calls to ADO APIs + Token *string +} + +// ADOOAuthListResponse - The response from List ADOOAuth operation. +type ADOOAuthListResponse struct { + // Singleton list response containing one ADOOAuthResponse + Value []*ADOOAuthResponse + + // READ-ONLY; The URL to the next set of ADO OAuth results. + NextLink *string +} + +// ADOOAuthResponse - Singleton response of ADO OAuth. +type ADOOAuthResponse struct { + // Details of ADO OAuth. + Properties *ADOOAuth + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ADORepository - Details of the ADO repository associated with the workflow. +type ADORepository struct { + // The name of the Azure DevOps organization the pipeline is associated with. + AdoOrganization *string + + // The name of the branch the workflow is associated with. + BranchName *string + + // The name of the project the pipeline is associated with. + ProjectName *string + + // The name of the repository the workflow is associated with. + RepositoryName *string + + // The owner of the repository the workflow is associated with. + RepositoryOwner *string +} + // ArtifactGenerationProperties - Properties used for generating artifacts such as Dockerfiles and manifests. type ArtifactGenerationProperties struct { // The name of the app. @@ -67,13 +133,54 @@ type ArtifactGenerationProperties struct { Port *string } +// AzurePipelineProfile - Azure Pipeline Profile +type AzurePipelineProfile struct { + // Resource identifier for azure container registry repository associated with the workflow. + Acr *string + + // The name of the ARM Service Connection the pipeline is associated with. + ArmServiceConnection *string + + // Build details of the repository associated with the workflow. + Build *Build + + // The Azure Kubernetes Cluster Resource the application will be deployed to. + ClusterID *string + + // Deployment details of the repository associated with the workflow. + Deployment *Deployment + LastWorkflowRun *WorkflowRun + + // Kubernetes namespace the application is deployed to. + Namespace *string + + // Details of the pull request containing the workflow. + PullRequest *PullRequest + + // Details of the ADO repository associated with the workflow. + Repository *ADORepository + + // READ-ONLY; Determines the authorization status of requests. + AuthStatus *AuthorizationStatus +} + +// Build details of the repository associated with the workflow. +type Build struct { + // Path to Dockerfile Build Context within the repository. + DockerBuildContext *string + + // Path to the Dockerfile within the repository. + Dockerfile *string +} + // DeleteWorkflowResponse - delete response if content must be provided on delete operation type DeleteWorkflowResponse struct { // delete status message Status *string } -type DeploymentProperties struct { +// Deployment details of the repository associated with the workflow. +type Deployment struct { // Helm chart directory path in repository. HelmChartPath *string @@ -88,6 +195,16 @@ type DeploymentProperties struct { Overrides map[string]*string } +type ExportTemplateRequest struct { + InstanceName *string + InstanceStage *string + ResourceGroupIDs []*string + SiteID *string + + // Template Name + TemplateName *string +} + // GitHubOAuthCallRequest - GitHubOAuth request object type GitHubOAuthCallRequest struct { // The URL the client will redirect to on successful authentication. If empty, no redirect will occur. @@ -120,7 +237,7 @@ type GitHubOAuthResponse struct { // Properties of a workflow. Properties *GitHubOAuthProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -142,8 +259,10 @@ type GitHubWorkflowProfile struct { AksResourceID *string // Repository Branch Name - BranchName *string - DeploymentProperties *DeploymentProperties + BranchName *string + + // Deployment details of the repository associated with the workflow. + DeploymentProperties *Deployment // Path to Dockerfile Build Context within the repository. DockerBuildContext *string @@ -186,6 +305,106 @@ type GitHubWorkflowProfileOidcCredentials struct { AzureTenantID *string } +// IacGitHubProfile - GitHub Profile of a IacProfile. +type IacGitHubProfile struct { + // Repository Branch Name + BranchName *string + + // Repository Main Branch + RepositoryMainBranch *string + + // Repository Name + RepositoryName *string + + // Repository Owner + RepositoryOwner *string + + // READ-ONLY; Determines the authorization status of requests. + AuthStatus *AuthorizationStatus + + // READ-ONLY; The status of the Pull Request submitted against the users repository. + PrStatus *PullRequestStatus + + // READ-ONLY; The number associated with the submitted pull request. + PullNumber *int32 +} + +// IacProfile - Resource representation of a IacProfile. +type IacProfile struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Properties of a IacProfile. + Properties *IacProfileProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; A unique read-only string that changes whenever the resource is updated. + Etag *string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +type IacProfileListResult struct { + // The list of IacProfiles. + Value []*IacProfile + + // READ-ONLY; The URL to the next set of IacProfile results. + NextLink *string +} + +// IacProfileProperties - Properties of a IacProfile. +type IacProfileProperties struct { + // GitHub Profile of a IacProfile + GithubProfile *IacGitHubProfile + Stages []*StageProperties + Templates []*IacTemplateProperties + + // Terraform Profile of a IacProfile + TerraformProfile *TerraformProfile +} + +type IacTemplateDetails struct { + // Count of the product + Count *int32 + + // Naming convention of this product + NamingConvention *string + + // The name of the products. + ProductName *string +} + +// IacTemplateProperties - Properties of a IacTemplate. +type IacTemplateProperties struct { + // the sample instance name of the template + InstanceName *string + + // the source stage of the template + InstanceStage *string + + // the source store of the template + SourceResourceID *string + TemplateDetails []*IacTemplateDetails + + // Template Name + TemplateName *string + + // READ-ONLY; Determines the authorization status of requests. + QuickStartTemplateType *QuickStartTemplateType +} + // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. @@ -235,6 +454,50 @@ type OperationListResult struct { Value []*Operation } +type PrLinkResponse struct { + // The link of the pull request. + PrLink *string +} + +// PullRequest - Details of the pull request containing the workflow. +type PullRequest struct { + // READ-ONLY; The status of the Pull Request submitted against the users repository. + PrStatus *PullRequestStatus + + // READ-ONLY; The URL to the Pull Request submitted against the users repository. + PrURL *string + + // READ-ONLY; The number associated with the submitted pull request. + PullNumber *int32 +} + +type ScaleProperty struct { + // Number of the store + NumberOfStore *int32 + + // The region of the store + Region *string + + // The stage of the store + Stage *string +} + +type ScaleTemplateRequest struct { + ScaleRequirement []*ScaleProperty + + // Template Name + TemplateName *string +} + +// StageProperties - Properties of a Stage. +type StageProperties struct { + Dependencies []*string + GitEnvironment *string + + // Stage Name + StageName *string +} + // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -262,6 +525,21 @@ type TagsObject struct { Tags map[string]*string } +// TerraformProfile - Terraform backend profile. +type TerraformProfile struct { + // Terraform Storage Account Name + StorageAccountName *string + + // Terraform Storage Account Resource Group + StorageAccountResourceGroup *string + + // Terraform Storage Account Subscription + StorageAccountSubscription *string + + // Terraform Container Name + StorageContainerName *string +} + // Workflow - Resource representation of a workflow type Workflow struct { // REQUIRED; The geo-location where the resource lives @@ -273,7 +551,7 @@ type Workflow struct { // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -300,20 +578,23 @@ type WorkflowProperties struct { // Properties for generating artifacts like dockerfile and manifests. ArtifactGenerationProperties *ArtifactGenerationProperties + // Profile of an azure pipeline. + AzurePipelineProfile *AzurePipelineProfile + // Profile of a github workflow. GithubWorkflowProfile *GitHubWorkflowProfile } type WorkflowRun struct { - // Describes the status of the workflow run - WorkflowRunStatus *WorkflowRunStatus - // READ-ONLY; The timestamp of the last workflow run. LastRunAt *time.Time // READ-ONLY; Describes if the workflow run succeeded. Succeeded *bool + // READ-ONLY; Describes the status of the workflow run + WorkflowRunStatus *WorkflowRunStatus + // READ-ONLY; URL to the run of the workflow. WorkflowRunURL *string } diff --git a/sdk/resourcemanager/devhub/armdevhub/models_serde.go b/sdk/resourcemanager/devhub/armdevhub/models_serde.go index a4b8756e0d56..bdb37999886c 100644 --- a/sdk/resourcemanager/devhub/armdevhub/models_serde.go +++ b/sdk/resourcemanager/devhub/armdevhub/models_serde.go @@ -54,6 +54,208 @@ func (a *ACR) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ADOOAuth. +func (a ADOOAuth) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "username", a.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ADOOAuth. +func (a *ADOOAuth) 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 "username": + err = unpopulate(val, "Username", &a.Username) + 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 ADOOAuthCallRequest. +func (a ADOOAuthCallRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "redirectUrl", a.RedirectURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ADOOAuthCallRequest. +func (a *ADOOAuthCallRequest) 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 "redirectUrl": + err = unpopulate(val, "RedirectURL", &a.RedirectURL) + 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 ADOOAuthInfoResponse. +func (a ADOOAuthInfoResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authURL", a.AuthURL) + populate(objectMap, "token", a.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ADOOAuthInfoResponse. +func (a *ADOOAuthInfoResponse) 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 "authURL": + err = unpopulate(val, "AuthURL", &a.AuthURL) + delete(rawMsg, key) + case "token": + err = unpopulate(val, "Token", &a.Token) + 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 ADOOAuthListResponse. +func (a ADOOAuthListResponse) 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 ADOOAuthListResponse. +func (a *ADOOAuthListResponse) 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 ADOOAuthResponse. +func (a ADOOAuthResponse) 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 ADOOAuthResponse. +func (a *ADOOAuthResponse) 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 ADORepository. +func (a ADORepository) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "adoOrganization", a.AdoOrganization) + populate(objectMap, "branchName", a.BranchName) + populate(objectMap, "projectName", a.ProjectName) + populate(objectMap, "repositoryName", a.RepositoryName) + populate(objectMap, "repositoryOwner", a.RepositoryOwner) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ADORepository. +func (a *ADORepository) 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 "adoOrganization": + err = unpopulate(val, "AdoOrganization", &a.AdoOrganization) + delete(rawMsg, key) + case "branchName": + err = unpopulate(val, "BranchName", &a.BranchName) + delete(rawMsg, key) + case "projectName": + err = unpopulate(val, "ProjectName", &a.ProjectName) + delete(rawMsg, key) + case "repositoryName": + err = unpopulate(val, "RepositoryName", &a.RepositoryName) + delete(rawMsg, key) + case "repositoryOwner": + err = unpopulate(val, "RepositoryOwner", &a.RepositoryOwner) + 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 ArtifactGenerationProperties. func (a ArtifactGenerationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -129,6 +331,100 @@ func (a *ArtifactGenerationProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AzurePipelineProfile. +func (a AzurePipelineProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "acr", a.Acr) + populate(objectMap, "armServiceConnection", a.ArmServiceConnection) + populate(objectMap, "authStatus", a.AuthStatus) + populate(objectMap, "build", a.Build) + populate(objectMap, "clusterId", a.ClusterID) + populate(objectMap, "deployment", a.Deployment) + populate(objectMap, "lastWorkflowRun", a.LastWorkflowRun) + populate(objectMap, "namespace", a.Namespace) + populate(objectMap, "pullRequest", a.PullRequest) + populate(objectMap, "repository", a.Repository) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzurePipelineProfile. +func (a *AzurePipelineProfile) 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 "acr": + err = unpopulate(val, "Acr", &a.Acr) + delete(rawMsg, key) + case "armServiceConnection": + err = unpopulate(val, "ArmServiceConnection", &a.ArmServiceConnection) + delete(rawMsg, key) + case "authStatus": + err = unpopulate(val, "AuthStatus", &a.AuthStatus) + delete(rawMsg, key) + case "build": + err = unpopulate(val, "Build", &a.Build) + delete(rawMsg, key) + case "clusterId": + err = unpopulate(val, "ClusterID", &a.ClusterID) + delete(rawMsg, key) + case "deployment": + err = unpopulate(val, "Deployment", &a.Deployment) + delete(rawMsg, key) + case "lastWorkflowRun": + err = unpopulate(val, "LastWorkflowRun", &a.LastWorkflowRun) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &a.Namespace) + delete(rawMsg, key) + case "pullRequest": + err = unpopulate(val, "PullRequest", &a.PullRequest) + delete(rawMsg, key) + case "repository": + err = unpopulate(val, "Repository", &a.Repository) + 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 Build. +func (b Build) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dockerBuildContext", b.DockerBuildContext) + populate(objectMap, "dockerfile", b.Dockerfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Build. +func (b *Build) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dockerBuildContext": + err = unpopulate(val, "DockerBuildContext", &b.DockerBuildContext) + delete(rawMsg, key) + case "dockerfile": + err = unpopulate(val, "Dockerfile", &b.Dockerfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DeleteWorkflowResponse. func (d DeleteWorkflowResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -156,8 +452,8 @@ func (d *DeleteWorkflowResponse) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentProperties. -func (d DeploymentProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Deployment. +func (d Deployment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "helmChartPath", d.HelmChartPath) populate(objectMap, "helmValues", d.HelmValues) @@ -167,8 +463,8 @@ func (d DeploymentProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentProperties. -func (d *DeploymentProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Deployment. +func (d *Deployment) 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", d, err) @@ -199,6 +495,49 @@ func (d *DeploymentProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ExportTemplateRequest. +func (e ExportTemplateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "instanceName", e.InstanceName) + populate(objectMap, "instanceStage", e.InstanceStage) + populate(objectMap, "resourceGroupIds", e.ResourceGroupIDs) + populate(objectMap, "siteId", e.SiteID) + populate(objectMap, "templateName", e.TemplateName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportTemplateRequest. +func (e *ExportTemplateRequest) 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", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceName": + err = unpopulate(val, "InstanceName", &e.InstanceName) + delete(rawMsg, key) + case "instanceStage": + err = unpopulate(val, "InstanceStage", &e.InstanceStage) + delete(rawMsg, key) + case "resourceGroupIds": + err = unpopulate(val, "ResourceGroupIDs", &e.ResourceGroupIDs) + delete(rawMsg, key) + case "siteId": + err = unpopulate(val, "SiteID", &e.SiteID) + delete(rawMsg, key) + case "templateName": + err = unpopulate(val, "TemplateName", &e.TemplateName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type GitHubOAuthCallRequest. func (g GitHubOAuthCallRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -468,6 +807,264 @@ func (g *GitHubWorkflowProfileOidcCredentials) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type IacGitHubProfile. +func (i IacGitHubProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authStatus", i.AuthStatus) + populate(objectMap, "branchName", i.BranchName) + populate(objectMap, "prStatus", i.PrStatus) + populate(objectMap, "pullNumber", i.PullNumber) + populate(objectMap, "repositoryMainBranch", i.RepositoryMainBranch) + populate(objectMap, "repositoryName", i.RepositoryName) + populate(objectMap, "repositoryOwner", i.RepositoryOwner) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IacGitHubProfile. +func (i *IacGitHubProfile) 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 "authStatus": + err = unpopulate(val, "AuthStatus", &i.AuthStatus) + delete(rawMsg, key) + case "branchName": + err = unpopulate(val, "BranchName", &i.BranchName) + delete(rawMsg, key) + case "prStatus": + err = unpopulate(val, "PrStatus", &i.PrStatus) + delete(rawMsg, key) + case "pullNumber": + err = unpopulate(val, "PullNumber", &i.PullNumber) + delete(rawMsg, key) + case "repositoryMainBranch": + err = unpopulate(val, "RepositoryMainBranch", &i.RepositoryMainBranch) + delete(rawMsg, key) + case "repositoryName": + err = unpopulate(val, "RepositoryName", &i.RepositoryName) + delete(rawMsg, key) + case "repositoryOwner": + err = unpopulate(val, "RepositoryOwner", &i.RepositoryOwner) + 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 IacProfile. +func (i IacProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", i.Etag) + populate(objectMap, "id", i.ID) + populate(objectMap, "location", i.Location) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "tags", i.Tags) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IacProfile. +func (i *IacProfile) 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 "etag": + err = unpopulate(val, "Etag", &i.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &i.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IacProfileListResult. +func (i IacProfileListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IacProfileListResult. +func (i *IacProfileListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IacProfileProperties. +func (i IacProfileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "githubProfile", i.GithubProfile) + populate(objectMap, "stages", i.Stages) + populate(objectMap, "templates", i.Templates) + populate(objectMap, "terraformProfile", i.TerraformProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IacProfileProperties. +func (i *IacProfileProperties) 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 "githubProfile": + err = unpopulate(val, "GithubProfile", &i.GithubProfile) + delete(rawMsg, key) + case "stages": + err = unpopulate(val, "Stages", &i.Stages) + delete(rawMsg, key) + case "templates": + err = unpopulate(val, "Templates", &i.Templates) + delete(rawMsg, key) + case "terraformProfile": + err = unpopulate(val, "TerraformProfile", &i.TerraformProfile) + 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 IacTemplateDetails. +func (i IacTemplateDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", i.Count) + populate(objectMap, "namingConvention", i.NamingConvention) + populate(objectMap, "productName", i.ProductName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IacTemplateDetails. +func (i *IacTemplateDetails) 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 "count": + err = unpopulate(val, "Count", &i.Count) + delete(rawMsg, key) + case "namingConvention": + err = unpopulate(val, "NamingConvention", &i.NamingConvention) + delete(rawMsg, key) + case "productName": + err = unpopulate(val, "ProductName", &i.ProductName) + 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 IacTemplateProperties. +func (i IacTemplateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "instanceName", i.InstanceName) + populate(objectMap, "instanceStage", i.InstanceStage) + populate(objectMap, "quickStartTemplateType", i.QuickStartTemplateType) + populate(objectMap, "sourceResourceId", i.SourceResourceID) + populate(objectMap, "templateDetails", i.TemplateDetails) + populate(objectMap, "templateName", i.TemplateName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IacTemplateProperties. +func (i *IacTemplateProperties) 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 "instanceName": + err = unpopulate(val, "InstanceName", &i.InstanceName) + delete(rawMsg, key) + case "instanceStage": + err = unpopulate(val, "InstanceStage", &i.InstanceStage) + delete(rawMsg, key) + case "quickStartTemplateType": + err = unpopulate(val, "QuickStartTemplateType", &i.QuickStartTemplateType) + delete(rawMsg, key) + case "sourceResourceId": + err = unpopulate(val, "SourceResourceID", &i.SourceResourceID) + delete(rawMsg, key) + case "templateDetails": + err = unpopulate(val, "TemplateDetails", &i.TemplateDetails) + delete(rawMsg, key) + case "templateName": + err = unpopulate(val, "TemplateName", &i.TemplateName) + 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 Operation. func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -581,6 +1178,169 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type PrLinkResponse. +func (p PrLinkResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "prLink", p.PrLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrLinkResponse. +func (p *PrLinkResponse) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "prLink": + err = unpopulate(val, "PrLink", &p.PrLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PullRequest. +func (p PullRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "prStatus", p.PrStatus) + populate(objectMap, "prURL", p.PrURL) + populate(objectMap, "pullNumber", p.PullNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PullRequest. +func (p *PullRequest) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "prStatus": + err = unpopulate(val, "PrStatus", &p.PrStatus) + delete(rawMsg, key) + case "prURL": + err = unpopulate(val, "PrURL", &p.PrURL) + delete(rawMsg, key) + case "pullNumber": + err = unpopulate(val, "PullNumber", &p.PullNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ScaleProperty. +func (s ScaleProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "numberOfStore", s.NumberOfStore) + populate(objectMap, "region", s.Region) + populate(objectMap, "stage", s.Stage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScaleProperty. +func (s *ScaleProperty) 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 "numberOfStore": + err = unpopulate(val, "NumberOfStore", &s.NumberOfStore) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &s.Region) + delete(rawMsg, key) + case "stage": + err = unpopulate(val, "Stage", &s.Stage) + 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 ScaleTemplateRequest. +func (s ScaleTemplateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "scaleRequirement", s.ScaleRequirement) + populate(objectMap, "templateName", s.TemplateName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScaleTemplateRequest. +func (s *ScaleTemplateRequest) 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 "scaleRequirement": + err = unpopulate(val, "ScaleRequirement", &s.ScaleRequirement) + delete(rawMsg, key) + case "templateName": + err = unpopulate(val, "TemplateName", &s.TemplateName) + 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 StageProperties. +func (s StageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dependencies", s.Dependencies) + populate(objectMap, "gitEnvironment", s.GitEnvironment) + populate(objectMap, "stageName", s.StageName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StageProperties. +func (s *StageProperties) 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 "dependencies": + err = unpopulate(val, "Dependencies", &s.Dependencies) + delete(rawMsg, key) + case "gitEnvironment": + err = unpopulate(val, "GitEnvironment", &s.GitEnvironment) + delete(rawMsg, key) + case "stageName": + err = unpopulate(val, "StageName", &s.StageName) + 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) @@ -655,6 +1415,45 @@ func (t *TagsObject) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TerraformProfile. +func (t TerraformProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "storageAccountName", t.StorageAccountName) + populate(objectMap, "storageAccountResourceGroup", t.StorageAccountResourceGroup) + populate(objectMap, "storageAccountSubscription", t.StorageAccountSubscription) + populate(objectMap, "storageContainerName", t.StorageContainerName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TerraformProfile. +func (t *TerraformProfile) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "storageAccountName": + err = unpopulate(val, "StorageAccountName", &t.StorageAccountName) + delete(rawMsg, key) + case "storageAccountResourceGroup": + err = unpopulate(val, "StorageAccountResourceGroup", &t.StorageAccountResourceGroup) + delete(rawMsg, key) + case "storageAccountSubscription": + err = unpopulate(val, "StorageAccountSubscription", &t.StorageAccountSubscription) + delete(rawMsg, key) + case "storageContainerName": + err = unpopulate(val, "StorageContainerName", &t.StorageContainerName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Workflow. func (w Workflow) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -741,6 +1540,7 @@ func (w *WorkflowListResult) UnmarshalJSON(data []byte) error { func (w WorkflowProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "artifactGenerationProperties", w.ArtifactGenerationProperties) + populate(objectMap, "azurePipelineProfile", w.AzurePipelineProfile) populate(objectMap, "githubWorkflowProfile", w.GithubWorkflowProfile) return json.Marshal(objectMap) } @@ -757,6 +1557,9 @@ func (w *WorkflowProperties) UnmarshalJSON(data []byte) error { case "artifactGenerationProperties": err = unpopulate(val, "ArtifactGenerationProperties", &w.ArtifactGenerationProperties) delete(rawMsg, key) + case "azurePipelineProfile": + err = unpopulate(val, "AzurePipelineProfile", &w.AzurePipelineProfile) + delete(rawMsg, key) case "githubWorkflowProfile": err = unpopulate(val, "GithubWorkflowProfile", &w.GithubWorkflowProfile) delete(rawMsg, key) @@ -818,7 +1621,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/devhub/armdevhub/operations_client.go b/sdk/resourcemanager/devhub/armdevhub/operations_client.go index c2a161a2f830..973f4b6cac45 100644 --- a/sdk/resourcemanager/devhub/armdevhub/operations_client.go +++ b/sdk/resourcemanager/devhub/armdevhub/operations_client.go @@ -40,7 +40,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // List - Returns list of operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview +// Generated from API version 2024-08-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { var err error @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/devhub/armdevhub/operations_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/operations_client_example_test.go deleted file mode 100644 index 16da99874c09..000000000000 --- a/sdk/resourcemanager/devhub/armdevhub/operations_client_example_test.go +++ /dev/null @@ -1,50 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdevhub_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Operation_List.json -func ExampleOperationsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOperationsClient().List(ctx, 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.OperationListResult = armdevhub.OperationListResult{ - // Value: []*armdevhub.Operation{ - // { - // Name: to.Ptr("Microsoft.DevHub/workflows/read"), - // Display: &armdevhub.OperationDisplay{ - // Description: to.Ptr("Gets workflow"), - // Operation: to.Ptr("Get workflow"), - // Provider: to.Ptr("Microsoft Developer Hub"), - // Resource: to.Ptr("Workflows"), - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/devhub/armdevhub/options.go b/sdk/resourcemanager/devhub/armdevhub/options.go index 6d02affffe28..4aae6ffb2a40 100644 --- a/sdk/resourcemanager/devhub/armdevhub/options.go +++ b/sdk/resourcemanager/devhub/armdevhub/options.go @@ -8,12 +8,29 @@ package armdevhub +// ADOOAuthClientGetOptions contains the optional parameters for the ADOOAuthClient.Get method. +type ADOOAuthClientGetOptions struct { + // placeholder for future optional parameters +} + +// ADOOAuthClientListOptions contains the optional parameters for the ADOOAuthClient.NewListPager method. +type ADOOAuthClientListOptions struct { + // placeholder for future optional parameters +} + // DeveloperHubServiceClientGeneratePreviewArtifactsOptions contains the optional parameters for the DeveloperHubServiceClient.GeneratePreviewArtifacts // method. type DeveloperHubServiceClientGeneratePreviewArtifactsOptions struct { // placeholder for future optional parameters } +// DeveloperHubServiceClientGetADOOAuthInfoOptions contains the optional parameters for the DeveloperHubServiceClient.GetADOOAuthInfo +// method. +type DeveloperHubServiceClientGetADOOAuthInfoOptions struct { + // The fields required in ADO OAuth call request. + Parameters *ADOOAuthCallRequest +} + // DeveloperHubServiceClientGitHubOAuthCallbackOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuthCallback // method. type DeveloperHubServiceClientGitHubOAuthCallbackOptions struct { @@ -32,6 +49,52 @@ type DeveloperHubServiceClientListGitHubOAuthOptions struct { // placeholder for future optional parameters } +// IacProfilesClientCreateOrUpdateOptions contains the optional parameters for the IacProfilesClient.CreateOrUpdate method. +type IacProfilesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IacProfilesClientDeleteOptions contains the optional parameters for the IacProfilesClient.Delete method. +type IacProfilesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IacProfilesClientExportOptions contains the optional parameters for the IacProfilesClient.Export method. +type IacProfilesClientExportOptions struct { + // placeholder for future optional parameters +} + +// IacProfilesClientGetOptions contains the optional parameters for the IacProfilesClient.Get method. +type IacProfilesClientGetOptions struct { + // placeholder for future optional parameters +} + +// IacProfilesClientListByResourceGroupOptions contains the optional parameters for the IacProfilesClient.NewListByResourceGroupPager +// method. +type IacProfilesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// IacProfilesClientListOptions contains the optional parameters for the IacProfilesClient.NewListPager method. +type IacProfilesClientListOptions struct { + // placeholder for future optional parameters +} + +// IacProfilesClientScaleOptions contains the optional parameters for the IacProfilesClient.Scale method. +type IacProfilesClientScaleOptions struct { + // placeholder for future optional parameters +} + +// IacProfilesClientSyncOptions contains the optional parameters for the IacProfilesClient.Sync method. +type IacProfilesClientSyncOptions struct { + // placeholder for future optional parameters +} + +// IacProfilesClientUpdateTagsOptions contains the optional parameters for the IacProfilesClient.UpdateTags method. +type IacProfilesClientUpdateTagsOptions struct { + // placeholder for future optional parameters +} + // OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. type OperationsClientListOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/devhub/armdevhub/response_types.go b/sdk/resourcemanager/devhub/armdevhub/responses.go similarity index 56% rename from sdk/resourcemanager/devhub/armdevhub/response_types.go rename to sdk/resourcemanager/devhub/armdevhub/responses.go index ffd0b5afdca6..a2c57b3ff789 100644 --- a/sdk/resourcemanager/devhub/armdevhub/response_types.go +++ b/sdk/resourcemanager/devhub/armdevhub/responses.go @@ -8,12 +8,30 @@ package armdevhub +// ADOOAuthClientGetResponse contains the response from method ADOOAuthClient.Get. +type ADOOAuthClientGetResponse struct { + // Singleton response of ADO OAuth. + ADOOAuthResponse +} + +// ADOOAuthClientListResponse contains the response from method ADOOAuthClient.NewListPager. +type ADOOAuthClientListResponse struct { + // The response from List ADOOAuth operation. + ADOOAuthListResponse +} + // DeveloperHubServiceClientGeneratePreviewArtifactsResponse contains the response from method DeveloperHubServiceClient.GeneratePreviewArtifacts. type DeveloperHubServiceClientGeneratePreviewArtifactsResponse struct { // Dockerfile and manifest artifacts generated as a preview are returned as a map Value map[string]*string } +// DeveloperHubServiceClientGetADOOAuthInfoResponse contains the response from method DeveloperHubServiceClient.GetADOOAuthInfo. +type DeveloperHubServiceClientGetADOOAuthInfoResponse struct { + // Response containing ADO OAuth information + ADOOAuthInfoResponse +} + // DeveloperHubServiceClientGitHubOAuthCallbackResponse contains the response from method DeveloperHubServiceClient.GitHubOAuthCallback. type DeveloperHubServiceClientGitHubOAuthCallbackResponse struct { // Singleton response of GitHubOAuth containing @@ -32,6 +50,54 @@ type DeveloperHubServiceClientListGitHubOAuthResponse struct { GitHubOAuthListResponse } +// IacProfilesClientCreateOrUpdateResponse contains the response from method IacProfilesClient.CreateOrUpdate. +type IacProfilesClientCreateOrUpdateResponse struct { + // Resource representation of a IacProfile. + IacProfile +} + +// IacProfilesClientDeleteResponse contains the response from method IacProfilesClient.Delete. +type IacProfilesClientDeleteResponse struct { + // placeholder for future response values +} + +// IacProfilesClientExportResponse contains the response from method IacProfilesClient.Export. +type IacProfilesClientExportResponse struct { + PrLinkResponse +} + +// IacProfilesClientGetResponse contains the response from method IacProfilesClient.Get. +type IacProfilesClientGetResponse struct { + // Resource representation of a IacProfile. + IacProfile +} + +// IacProfilesClientListByResourceGroupResponse contains the response from method IacProfilesClient.NewListByResourceGroupPager. +type IacProfilesClientListByResourceGroupResponse struct { + IacProfileListResult +} + +// IacProfilesClientListResponse contains the response from method IacProfilesClient.NewListPager. +type IacProfilesClientListResponse struct { + IacProfileListResult +} + +// IacProfilesClientScaleResponse contains the response from method IacProfilesClient.Scale. +type IacProfilesClientScaleResponse struct { + PrLinkResponse +} + +// IacProfilesClientSyncResponse contains the response from method IacProfilesClient.Sync. +type IacProfilesClientSyncResponse struct { + // placeholder for future response values +} + +// IacProfilesClientUpdateTagsResponse contains the response from method IacProfilesClient.UpdateTags. +type IacProfilesClientUpdateTagsResponse struct { + // Resource representation of a IacProfile. + IacProfile +} + // OperationsClientListResponse contains the response from method OperationsClient.List. type OperationsClientListResponse struct { // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. diff --git a/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go b/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go index b23964947818..371ab1ee77e4 100644 --- a/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go +++ b/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/devhub/armdevhub/workflow_client.go b/sdk/resourcemanager/devhub/armdevhub/workflow_client.go index 1f0b56e90d2b..d6d871701193 100644 --- a/sdk/resourcemanager/devhub/armdevhub/workflow_client.go +++ b/sdk/resourcemanager/devhub/armdevhub/workflow_client.go @@ -28,7 +28,7 @@ type WorkflowClient struct { } // NewWorkflowClient creates a new instance of WorkflowClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewWorkflowClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowClient, error) { @@ -46,7 +46,7 @@ func NewWorkflowClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Creates or updates a workflow // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview +// Generated from API version 2024-08-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workflowName - The name of the workflow resource. // - options - WorkflowClientCreateOrUpdateOptions contains the optional parameters for the WorkflowClient.CreateOrUpdate method. @@ -92,7 +92,7 @@ func (client *WorkflowClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -113,7 +113,7 @@ func (client *WorkflowClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes a workflow // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview +// Generated from API version 2024-08-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workflowName - The name of the workflow resource. // - options - WorkflowClientDeleteOptions contains the optional parameters for the WorkflowClient.Delete method. @@ -159,7 +159,7 @@ func (client *WorkflowClient) deleteCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -177,7 +177,7 @@ func (client *WorkflowClient) deleteHandleResponse(resp *http.Response) (Workflo // Get - Gets a workflow. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview +// Generated from API version 2024-08-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workflowName - The name of the workflow resource. // - options - WorkflowClientGetOptions contains the optional parameters for the WorkflowClient.Get method. @@ -223,7 +223,7 @@ func (client *WorkflowClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -240,7 +240,7 @@ func (client *WorkflowClient) getHandleResponse(resp *http.Response) (WorkflowCl // NewListPager - Gets a list of workflows associated with the specified subscription. // -// Generated from API version 2022-10-11-preview +// Generated from API version 2024-08-01-preview // - options - WorkflowClientListOptions contains the optional parameters for the WorkflowClient.NewListPager method. func (client *WorkflowClient) NewListPager(options *WorkflowClientListOptions) *runtime.Pager[WorkflowClientListResponse] { return runtime.NewPager(runtime.PagingHandler[WorkflowClientListResponse]{ @@ -277,7 +277,7 @@ func (client *WorkflowClient) listCreateRequest(ctx context.Context, options *Wo return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -294,7 +294,7 @@ func (client *WorkflowClient) listHandleResponse(resp *http.Response) (WorkflowC // NewListByResourceGroupPager - Gets a list of workflows within a resource group. // -// Generated from API version 2022-10-11-preview +// Generated from API version 2024-08-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - WorkflowClientListByResourceGroupOptions contains the optional parameters for the WorkflowClient.NewListByResourceGroupPager // method. @@ -337,7 +337,7 @@ func (client *WorkflowClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") if options != nil && options.ManagedClusterResource != nil { reqQP.Set("managedClusterResource", *options.ManagedClusterResource) } @@ -358,7 +358,7 @@ func (client *WorkflowClient) listByResourceGroupHandleResponse(resp *http.Respo // UpdateTags - Updates tags on a workflow. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-11-preview +// Generated from API version 2024-08-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - workflowName - The name of the workflow resource. // - parameters - Parameters supplied to the Update Workflow Tags operation. @@ -405,7 +405,7 @@ func (client *WorkflowClient) updateTagsCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-11-preview") + reqQP.Set("api-version", "2024-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/devhub/armdevhub/workflow_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/workflow_client_example_test.go deleted file mode 100644 index 6c7928263993..000000000000 --- a/sdk/resourcemanager/devhub/armdevhub/workflow_client_example_test.go +++ /dev/null @@ -1,570 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdevhub_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/devhub/armdevhub" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_List.json -func ExampleWorkflowClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewWorkflowClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.WorkflowListResult = armdevhub.WorkflowListResult{ - // Value: []*armdevhub.Workflow{ - // { - // Name: to.Ptr("workflow1"), - // Type: to.Ptr("Micfosoft.DevHub/Workflow"), - // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), - // SystemData: &armdevhub.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // CreatedBy: to.Ptr("foo@contoso.com"), - // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // }, - // Location: to.Ptr("location1"), - // Tags: map[string]*string{ - // "appname": to.Ptr("testapp"), - // }, - // Properties: &armdevhub.WorkflowProperties{ - // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ - // Acr: &armdevhub.ACR{ - // AcrRegistryName: to.Ptr("registry1"), - // AcrRepositoryName: to.Ptr("repo1"), - // AcrResourceGroup: to.Ptr("resourceGroup1"), - // AcrSubscriptionID: to.Ptr("subscriptionId1"), - // }, - // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), - // AuthStatus: to.Ptr(armdevhub.AuthorizationStatusAuthorized), - // BranchName: to.Ptr("branch1"), - // DeploymentProperties: &armdevhub.DeploymentProperties{ - // ManifestType: to.Ptr(armdevhub.ManifestTypeKube), - // Overrides: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // DockerBuildContext: to.Ptr("repo1/src/"), - // Dockerfile: to.Ptr("repo1/images/Dockerfile"), - // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ - // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), - // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), - // }, - // PrStatus: to.Ptr(armdevhub.PullRequestStatusSubmitted), - // PrURL: to.Ptr("https://github.com/User/repo1/pull/6567"), - // PullNumber: to.Ptr[int32](6567), - // RepositoryName: to.Ptr("repo1"), - // RepositoryOwner: to.Ptr("owner1"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_ListByResourceGroup.json -func ExampleWorkflowClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewWorkflowClient().NewListByResourceGroupPager("resourceGroup1", &armdevhub.WorkflowClientListByResourceGroupOptions{ManagedClusterResource: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.WorkflowListResult = armdevhub.WorkflowListResult{ - // Value: []*armdevhub.Workflow{ - // { - // Name: to.Ptr("workflow1"), - // Type: to.Ptr("Micfosoft.DevHub/Workflow"), - // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), - // SystemData: &armdevhub.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // CreatedBy: to.Ptr("foo@contoso.com"), - // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // }, - // Location: to.Ptr("location1"), - // Tags: map[string]*string{ - // "appname": to.Ptr("testapp"), - // }, - // Properties: &armdevhub.WorkflowProperties{ - // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ - // Acr: &armdevhub.ACR{ - // AcrRegistryName: to.Ptr("registry1"), - // AcrRepositoryName: to.Ptr("repo1"), - // AcrResourceGroup: to.Ptr("resourceGroup1"), - // AcrSubscriptionID: to.Ptr("subscriptionId1"), - // }, - // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), - // AuthStatus: to.Ptr(armdevhub.AuthorizationStatusAuthorized), - // BranchName: to.Ptr("branch1"), - // DeploymentProperties: &armdevhub.DeploymentProperties{ - // ManifestType: to.Ptr(armdevhub.ManifestTypeKube), - // Overrides: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // DockerBuildContext: to.Ptr("repo1/src/"), - // Dockerfile: to.Ptr("repo1/images/Dockerfile"), - // LastWorkflowRun: &armdevhub.WorkflowRun{ - // LastRunAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-01T12:34:56.000Z"); return t}()), - // Succeeded: to.Ptr(true), - // WorkflowRunStatus: to.Ptr(armdevhub.WorkflowRunStatusCompleted), - // WorkflowRunURL: to.Ptr("https://github.com/User/repo1/actions/runs/1820640230"), - // }, - // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ - // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), - // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), - // }, - // PrStatus: to.Ptr(armdevhub.PullRequestStatusMerged), - // PrURL: to.Ptr("https://github.com/User/repo1/pull/6567"), - // PullNumber: to.Ptr[int32](6567), - // RepositoryName: to.Ptr("repo1"), - // RepositoryOwner: to.Ptr("owner1"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_Get.json -func ExampleWorkflowClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewWorkflowClient().Get(ctx, "resourceGroup1", "workflow1", 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.Workflow = armdevhub.Workflow{ - // Name: to.Ptr("workflow1"), - // Type: to.Ptr("Micfosoft.DevHub/Workflow"), - // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), - // SystemData: &armdevhub.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // CreatedBy: to.Ptr("foo@contoso.com"), - // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // }, - // Location: to.Ptr("location1"), - // Tags: map[string]*string{ - // "appname": to.Ptr("testapp"), - // }, - // Properties: &armdevhub.WorkflowProperties{ - // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ - // Acr: &armdevhub.ACR{ - // AcrRegistryName: to.Ptr("registry1"), - // AcrRepositoryName: to.Ptr("repo1"), - // AcrResourceGroup: to.Ptr("resourceGroup1"), - // AcrSubscriptionID: to.Ptr("subscriptionId1"), - // }, - // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), - // AuthStatus: to.Ptr(armdevhub.AuthorizationStatusAuthorized), - // BranchName: to.Ptr("branch1"), - // DeploymentProperties: &armdevhub.DeploymentProperties{ - // ManifestType: to.Ptr(armdevhub.ManifestTypeKube), - // Overrides: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // DockerBuildContext: to.Ptr("repo1/src/"), - // Dockerfile: to.Ptr("repo1/images/Dockerfile"), - // LastWorkflowRun: &armdevhub.WorkflowRun{ - // LastRunAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-01T12:34:56.000Z"); return t}()), - // Succeeded: to.Ptr(true), - // WorkflowRunStatus: to.Ptr(armdevhub.WorkflowRunStatusCompleted), - // WorkflowRunURL: to.Ptr("https://github.com/User/repo1/actions/runs/1820640230"), - // }, - // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ - // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), - // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), - // }, - // PrStatus: to.Ptr(armdevhub.PullRequestStatusMerged), - // PrURL: to.Ptr("https://github.com/User/repo1/pull/6567"), - // PullNumber: to.Ptr[int32](6567), - // RepositoryName: to.Ptr("repo1"), - // RepositoryOwner: to.Ptr("owner1"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_CreateOrUpdate.json -func ExampleWorkflowClient_CreateOrUpdate_createWorkflow() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewWorkflowClient().CreateOrUpdate(ctx, "resourceGroup1", "workflow1", armdevhub.Workflow{ - Location: to.Ptr("location1"), - Tags: map[string]*string{ - "appname": to.Ptr("testApp"), - }, - Properties: &armdevhub.WorkflowProperties{ - GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ - Acr: &armdevhub.ACR{ - AcrRegistryName: to.Ptr("registry1"), - AcrRepositoryName: to.Ptr("repo1"), - AcrResourceGroup: to.Ptr("resourceGroup1"), - AcrSubscriptionID: to.Ptr("subscriptionId1"), - }, - AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), - BranchName: to.Ptr("branch1"), - DeploymentProperties: &armdevhub.DeploymentProperties{ - KubeManifestLocations: []*string{ - to.Ptr("/src/manifests/")}, - ManifestType: to.Ptr(armdevhub.ManifestTypeKube), - Overrides: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }, - DockerBuildContext: to.Ptr("repo1/src/"), - Dockerfile: to.Ptr("repo1/images/Dockerfile"), - Namespace: to.Ptr("namespace1"), - OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ - AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), - AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), - }, - RepositoryName: to.Ptr("repo1"), - RepositoryOwner: to.Ptr("owner1"), - }, - }, - }, 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.Workflow = armdevhub.Workflow{ - // Name: to.Ptr("workflow1"), - // Type: to.Ptr("Micfosoft.DevHub/Workflow"), - // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), - // SystemData: &armdevhub.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // CreatedBy: to.Ptr("foo@contoso.com"), - // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // }, - // Location: to.Ptr("location1"), - // Tags: map[string]*string{ - // "appname": to.Ptr("testapp"), - // }, - // Properties: &armdevhub.WorkflowProperties{ - // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ - // Acr: &armdevhub.ACR{ - // AcrRegistryName: to.Ptr("registry1"), - // AcrRepositoryName: to.Ptr("repo1"), - // AcrResourceGroup: to.Ptr("resourceGroup1"), - // AcrSubscriptionID: to.Ptr("subscriptionId1"), - // }, - // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), - // AuthStatus: to.Ptr(armdevhub.AuthorizationStatusAuthorized), - // BranchName: to.Ptr("branch2"), - // DeploymentProperties: &armdevhub.DeploymentProperties{ - // HelmChartPath: to.Ptr("/src/charts"), - // HelmValues: to.Ptr("/src/chars/values.yaml"), - // ManifestType: to.Ptr(armdevhub.ManifestTypeHelm), - // Overrides: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // DockerBuildContext: to.Ptr("repo2/src/"), - // Dockerfile: to.Ptr("repo2/images/Dockerfile"), - // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ - // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), - // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), - // }, - // PrStatus: to.Ptr(armdevhub.PullRequestStatusSubmitted), - // PrURL: to.Ptr("https://github.com/User/repo2/pull/6567"), - // PullNumber: to.Ptr[int32](6567), - // RepositoryName: to.Ptr("repo2"), - // RepositoryOwner: to.Ptr("owner1"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_CreateOrUpdate_WithArtifactGen.json -func ExampleWorkflowClient_CreateOrUpdate_createWorkflowWithArtifactGeneration() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewWorkflowClient().CreateOrUpdate(ctx, "resourceGroup1", "workflow1", armdevhub.Workflow{ - Location: to.Ptr("location1"), - Tags: map[string]*string{ - "appname": to.Ptr("testApp"), - }, - Properties: &armdevhub.WorkflowProperties{ - ArtifactGenerationProperties: &armdevhub.ArtifactGenerationProperties{ - AppName: to.Ptr("my-app"), - DockerfileGenerationMode: to.Ptr(armdevhub.DockerfileGenerationModeEnabled), - DockerfileOutputDirectory: to.Ptr("./"), - GenerationLanguage: to.Ptr(armdevhub.GenerationLanguageJavascript), - ImageName: to.Ptr("myimage"), - ImageTag: to.Ptr("latest"), - LanguageVersion: to.Ptr("14"), - ManifestGenerationMode: to.Ptr(armdevhub.ManifestGenerationModeEnabled), - ManifestOutputDirectory: to.Ptr("./"), - ManifestType: to.Ptr(armdevhub.GenerationManifestTypeKube), - Namespace: to.Ptr("my-namespace"), - Port: to.Ptr("80"), - }, - GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ - Acr: &armdevhub.ACR{ - AcrRegistryName: to.Ptr("registry1"), - AcrRepositoryName: to.Ptr("repo1"), - AcrResourceGroup: to.Ptr("resourceGroup1"), - AcrSubscriptionID: to.Ptr("subscriptionId1"), - }, - AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), - BranchName: to.Ptr("branch1"), - DeploymentProperties: &armdevhub.DeploymentProperties{ - KubeManifestLocations: []*string{ - to.Ptr("/src/manifests/")}, - ManifestType: to.Ptr(armdevhub.ManifestTypeKube), - Overrides: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }, - DockerBuildContext: to.Ptr("repo1/src/"), - Dockerfile: to.Ptr("repo1/images/Dockerfile"), - OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ - AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), - AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), - }, - RepositoryName: to.Ptr("repo1"), - RepositoryOwner: to.Ptr("owner1"), - }, - }, - }, 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.Workflow = armdevhub.Workflow{ - // Name: to.Ptr("workflow1"), - // Type: to.Ptr("Micfosoft.DevHub/Workflow"), - // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), - // SystemData: &armdevhub.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // CreatedBy: to.Ptr("foo@contoso.com"), - // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // }, - // Location: to.Ptr("location1"), - // Tags: map[string]*string{ - // "appname": to.Ptr("testapp"), - // }, - // Properties: &armdevhub.WorkflowProperties{ - // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ - // Acr: &armdevhub.ACR{ - // AcrRegistryName: to.Ptr("registry1"), - // AcrRepositoryName: to.Ptr("repo1"), - // AcrResourceGroup: to.Ptr("resourceGroup1"), - // AcrSubscriptionID: to.Ptr("subscriptionId1"), - // }, - // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), - // AuthStatus: to.Ptr(armdevhub.AuthorizationStatusAuthorized), - // BranchName: to.Ptr("branch2"), - // DeploymentProperties: &armdevhub.DeploymentProperties{ - // HelmChartPath: to.Ptr("/src/charts"), - // HelmValues: to.Ptr("/src/chars/values.yaml"), - // ManifestType: to.Ptr(armdevhub.ManifestTypeHelm), - // Overrides: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // DockerBuildContext: to.Ptr("repo2/src/"), - // Dockerfile: to.Ptr("repo2/images/Dockerfile"), - // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ - // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), - // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), - // }, - // PrStatus: to.Ptr(armdevhub.PullRequestStatusSubmitted), - // PrURL: to.Ptr("https://github.com/User/repo2/pull/6567"), - // PullNumber: to.Ptr[int32](6567), - // RepositoryName: to.Ptr("repo2"), - // RepositoryOwner: to.Ptr("owner1"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_Delete.json -func ExampleWorkflowClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewWorkflowClient().Delete(ctx, "resourceGroup1", "workflow1", 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.DeleteWorkflowResponse = armdevhub.DeleteWorkflowResponse{ - // Status: to.Ptr("workflow deleted successfully"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_UpdateTags.json -func ExampleWorkflowClient_UpdateTags() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevhub.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewWorkflowClient().UpdateTags(ctx, "resourceGroup1", "workflow1", armdevhub.TagsObject{ - Tags: map[string]*string{ - "promote": to.Ptr("false"), - "resourceEnv": to.Ptr("testing"), - }, - }, 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.Workflow = armdevhub.Workflow{ - // Name: to.Ptr("workflow1"), - // Type: to.Ptr("Micfosoft.DevHub/Workflow"), - // ID: to.Ptr("/subscription/subscriptionId1/resourceGroups/resourceGroup1/providers/Microsoft.DevHub/workflow/workflow1"), - // SystemData: &armdevhub.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // CreatedBy: to.Ptr("foo@contoso.com"), - // CreatedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-24T16:30:55.000Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armdevhub.CreatedByTypeUser), - // }, - // Location: to.Ptr("location1"), - // Tags: map[string]*string{ - // "previousValue": to.Ptr("stillExists"), - // "promote": to.Ptr("false"), - // "resourceEnv": to.Ptr("testing"), - // }, - // Properties: &armdevhub.WorkflowProperties{ - // GithubWorkflowProfile: &armdevhub.GitHubWorkflowProfile{ - // Acr: &armdevhub.ACR{ - // AcrRegistryName: to.Ptr("registry1"), - // AcrRepositoryName: to.Ptr("repo1"), - // AcrResourceGroup: to.Ptr("resourceGroup1"), - // AcrSubscriptionID: to.Ptr("subscriptionId1"), - // }, - // AksResourceID: to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), - // AuthStatus: to.Ptr(armdevhub.AuthorizationStatusAuthorized), - // BranchName: to.Ptr("branch1"), - // DeploymentProperties: &armdevhub.DeploymentProperties{ - // ManifestType: to.Ptr(armdevhub.ManifestTypeKube), - // Overrides: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // DockerBuildContext: to.Ptr("repo1/src/"), - // Dockerfile: to.Ptr("repo1/images/Dockerfile"), - // LastWorkflowRun: &armdevhub.WorkflowRun{ - // LastRunAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-01T12:34:56.000Z"); return t}()), - // Succeeded: to.Ptr(true), - // WorkflowRunStatus: to.Ptr(armdevhub.WorkflowRunStatusCompleted), - // WorkflowRunURL: to.Ptr("https://github.com/User/repo1/actions/runs/1820640230"), - // }, - // OidcCredentials: &armdevhub.GitHubWorkflowProfileOidcCredentials{ - // AzureClientID: to.Ptr("12345678-3456-7890-5678-012345678901"), - // AzureTenantID: to.Ptr("66666666-3456-7890-5678-012345678901"), - // }, - // PrStatus: to.Ptr(armdevhub.PullRequestStatusMerged), - // PrURL: to.Ptr("https://github.com/owner1/repo1/pull/6567"), - // PullNumber: to.Ptr[int32](6567), - // RepositoryName: to.Ptr("repo1"), - // RepositoryOwner: to.Ptr("owner1"), - // }, - // }, - // } -}