diff --git a/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md b/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md new file mode 100644 index 000000000000..6c5dd59ce45c --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/CHANGELOG.md @@ -0,0 +1,9 @@ +# Release History + +## 0.1.0 (2022-09-24) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.1.0, which contains breaking changes. + +To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/azsdk/go/mgmt/migration). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/devhub/armdevhub/LICENSE.txt b/sdk/resourcemanager/devhub/armdevhub/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/devhub/armdevhub/README.md b/sdk/resourcemanager/devhub/armdevhub/README.md new file mode 100644 index 000000000000..880c545264a1 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/README.md @@ -0,0 +1,77 @@ +# Azure Devhub Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub) + +The `armdevhub` module provides operations for working with Azure Devhub. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/devhub/armdevhub) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.19 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Devhub module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Devhub. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Clients + +Azure Devhub modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client, err := armdevhub.(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armdevhub.(, cred, &options) +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Devhub` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/devhub/armdevhub/autorest.md b/sdk/resourcemanager/devhub/armdevhub/autorest.md new file mode 100644 index 000000000000..740d8d2a3009 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/34ba022add0034e30462b76e1548ce5a7e053e33/specification/developerhub/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/34ba022add0034e30462b76e1548ce5a7e053e33/specification/developerhub/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/devhub/armdevhub/build.go b/sdk/resourcemanager/devhub/armdevhub/build.go new file mode 100644 index 000000000000..3c477179292e --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/devhub/armdevhub + +package armdevhub diff --git a/sdk/resourcemanager/devhub/armdevhub/ci.yml b/sdk/resourcemanager/devhub/armdevhub/ci.yml new file mode 100644 index 000000000000..d377950d08ee --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/devhub/armdevhub/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/devhub/armdevhub/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/devhub/armdevhub' diff --git a/sdk/resourcemanager/devhub/armdevhub/constants.go b/sdk/resourcemanager/devhub/armdevhub/constants.go new file mode 100644 index 000000000000..361e6a6f9961 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/constants.go @@ -0,0 +1,110 @@ +//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 + +const ( + moduleName = "armdevhub" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ManifestType - Determines the type of manifests within the repository. +type ManifestType string + +const ( + // ManifestTypeHelm - Repositories using helm + ManifestTypeHelm ManifestType = "helm" + // ManifestTypeKube - Repositories using kubernetes manifests + ManifestTypeKube ManifestType = "kube" +) + +// PossibleManifestTypeValues returns the possible values for the ManifestType const type. +func PossibleManifestTypeValues() []ManifestType { + return []ManifestType{ + ManifestTypeHelm, + ManifestTypeKube, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// PullRequestStatus - The status of the Pull Request submitted against the users repository. +type PullRequestStatus string + +const ( + // PullRequestStatusMerged - Pull Request merged into repository. + PullRequestStatusMerged PullRequestStatus = "merged" + // PullRequestStatusRemoved - Workflow no longer found within repository. + PullRequestStatusRemoved PullRequestStatus = "removed" + // PullRequestStatusSubmitted - Pull Request submitted to repository. + PullRequestStatusSubmitted PullRequestStatus = "submitted" + // PullRequestStatusUnknown - Pull Request state unknown. + PullRequestStatusUnknown PullRequestStatus = "unknown" +) + +// PossiblePullRequestStatusValues returns the possible values for the PullRequestStatus const type. +func PossiblePullRequestStatusValues() []PullRequestStatus { + return []PullRequestStatus{ + PullRequestStatusMerged, + PullRequestStatusRemoved, + PullRequestStatusSubmitted, + PullRequestStatusUnknown, + } +} diff --git a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go new file mode 100644 index 000000000000..7507219bed08 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client.go @@ -0,0 +1,223 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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" +) + +// DeveloperHubServiceClient contains the methods for the DeveloperHubServiceClient group. +// Don't use this type directly, use NewDeveloperHubServiceClient() instead. +type DeveloperHubServiceClient struct { + host string + subscriptionID string + code string + state string + pl runtime.Pipeline +} + +// NewDeveloperHubServiceClient creates a new instance of DeveloperHubServiceClient with the specified values. +// subscriptionID - The ID of the target subscription. +// code - The code response from authenticating the GitHub App. +// state - The state response from authenticating the GitHub App. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewDeveloperHubServiceClient(subscriptionID string, code string, state string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeveloperHubServiceClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &DeveloperHubServiceClient{ + subscriptionID: subscriptionID, + code: code, + state: state, + host: ep, + pl: pl, + } + return client, 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-04-01-preview +// location - The name of 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) { + req, err := client.gitHubOAuthCreateRequest(ctx, location, options) + if err != nil { + return DeveloperHubServiceClientGitHubOAuthResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DeveloperHubServiceClientGitHubOAuthResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeveloperHubServiceClientGitHubOAuthResponse{}, runtime.NewResponseError(resp) + } + return client.gitHubOAuthHandleResponse(resp) +} + +// gitHubOAuthCreateRequest creates the GitHubOAuth request. +func (client *DeveloperHubServiceClient) gitHubOAuthCreateRequest(ctx context.Context, location string, options *DeveloperHubServiceClientGitHubOAuthOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth/default/getGitHubOAuthInfo" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Parameters != nil { + return req, runtime.MarshalAsJSON(req, *options.Parameters) + } + return req, nil +} + +// gitHubOAuthHandleResponse handles the GitHubOAuth response. +func (client *DeveloperHubServiceClient) gitHubOAuthHandleResponse(resp *http.Response) (DeveloperHubServiceClientGitHubOAuthResponse, error) { + result := DeveloperHubServiceClientGitHubOAuthResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GitHubOAuthInfoResponse); err != nil { + return DeveloperHubServiceClientGitHubOAuthResponse{}, err + } + return result, nil +} + +// 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-04-01-preview +// location - The name of Azure region. +// options - DeveloperHubServiceClientGitHubOAuthCallbackOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuthCallback +// method. +func (client *DeveloperHubServiceClient) GitHubOAuthCallback(ctx context.Context, location string, options *DeveloperHubServiceClientGitHubOAuthCallbackOptions) (DeveloperHubServiceClientGitHubOAuthCallbackResponse, error) { + req, err := client.gitHubOAuthCallbackCreateRequest(ctx, location, options) + if err != nil { + return DeveloperHubServiceClientGitHubOAuthCallbackResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DeveloperHubServiceClientGitHubOAuthCallbackResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeveloperHubServiceClientGitHubOAuthCallbackResponse{}, runtime.NewResponseError(resp) + } + return client.gitHubOAuthCallbackHandleResponse(resp) +} + +// gitHubOAuthCallbackCreateRequest creates the GitHubOAuthCallback request. +func (client *DeveloperHubServiceClient) gitHubOAuthCallbackCreateRequest(ctx context.Context, location string, options *DeveloperHubServiceClientGitHubOAuthCallbackOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01-preview") + reqQP.Set("code", client.code) + reqQP.Set("state", client.state) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// gitHubOAuthCallbackHandleResponse handles the GitHubOAuthCallback response. +func (client *DeveloperHubServiceClient) gitHubOAuthCallbackHandleResponse(resp *http.Response) (DeveloperHubServiceClientGitHubOAuthCallbackResponse, error) { + result := DeveloperHubServiceClientGitHubOAuthCallbackResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GitHubOAuthResponse); err != nil { + return DeveloperHubServiceClientGitHubOAuthCallbackResponse{}, err + } + return result, nil +} + +// 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-04-01-preview +// location - The name of 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) { + req, err := client.listGitHubOAuthCreateRequest(ctx, location, options) + if err != nil { + return DeveloperHubServiceClientListGitHubOAuthResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DeveloperHubServiceClientListGitHubOAuthResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeveloperHubServiceClientListGitHubOAuthResponse{}, runtime.NewResponseError(resp) + } + return client.listGitHubOAuthHandleResponse(resp) +} + +// listGitHubOAuthCreateRequest creates the ListGitHubOAuth request. +func (client *DeveloperHubServiceClient) listGitHubOAuthCreateRequest(ctx context.Context, location string, options *DeveloperHubServiceClientListGitHubOAuthOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listGitHubOAuthHandleResponse handles the ListGitHubOAuth response. +func (client *DeveloperHubServiceClient) listGitHubOAuthHandleResponse(resp *http.Response) (DeveloperHubServiceClientListGitHubOAuthResponse, error) { + result := DeveloperHubServiceClientListGitHubOAuthResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GitHubOAuthListResponse); err != nil { + return DeveloperHubServiceClientListGitHubOAuthResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client_example_test.go new file mode 100644 index 000000000000..14e633cfd290 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/developerhubservice_client_example_test.go @@ -0,0 +1,78 @@ +//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. + +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/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewDeveloperHubServiceClient("subscriptionId1", "", "", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.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) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewDeveloperHubServiceClient("subscriptionId1", "3584d83530557fdd1f46af8289938c8ef79f9dc5", "12345678-3456-7890-5678-012345678901", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.GitHubOAuthCallback(ctx, "eastus2euap", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewDeveloperHubServiceClient("subscriptionId1", "", "", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.ListGitHubOAuth(ctx, "eastus2euap", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/devhub/armdevhub/go.mod b/sdk/resourcemanager/devhub/armdevhub/go.mod new file mode 100644 index 000000000000..c3e5eee24b2b --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devhub/armdevhub + +go 1.19 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect + github.com/golang-jwt/jwt v3.2.1+incompatible // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect + golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/sdk/resourcemanager/devhub/armdevhub/go.sum b/sdk/resourcemanager/devhub/armdevhub/go.sum new file mode 100644 index 000000000000..8828b17b1853 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/go.sum @@ -0,0 +1,33 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= +github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= +golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/devhub/armdevhub/models.go b/sdk/resourcemanager/devhub/armdevhub/models.go new file mode 100644 index 000000000000..aff75e560da3 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/models.go @@ -0,0 +1,324 @@ +//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 + +import "time" + +// ACR - Information on the azure container registry +type ACR struct { + // ACR registry + AcrRegistryName *string `json:"acrRegistryName,omitempty"` + + // ACR repository + AcrRepositoryName *string `json:"acrRepositoryName,omitempty"` + + // ACR resource group + AcrResourceGroup *string `json:"acrResourceGroup,omitempty"` + + // ACR subscription id + AcrSubscriptionID *string `json:"acrSubscriptionId,omitempty"` +} + +// DeleteWorkflowResponse - delete response if content must be provided on delete operation +type DeleteWorkflowResponse struct { + // delete status message + Status *string `json:"status,omitempty"` +} + +type DeploymentProperties struct { + // Helm chart directory path in repository. + HelmChartPath *string `json:"helmChartPath,omitempty"` + + // Helm Values.yaml file location in repository. + HelmValues *string `json:"helmValues,omitempty"` + KubeManifestLocations []*string `json:"kubeManifestLocations,omitempty"` + + // Determines the type of manifests within the repository. + ManifestType *ManifestType `json:"manifestType,omitempty"` + + // Manifest override values. + Overrides map[string]*string `json:"overrides,omitempty"` +} + +// DeveloperHubServiceClientGitHubOAuthCallbackOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuthCallback +// method. +type DeveloperHubServiceClientGitHubOAuthCallbackOptions struct { + // placeholder for future optional parameters +} + +// DeveloperHubServiceClientGitHubOAuthOptions contains the optional parameters for the DeveloperHubServiceClient.GitHubOAuth +// method. +type DeveloperHubServiceClientGitHubOAuthOptions struct { + Parameters *GitHubOAuthCallRequest +} + +// DeveloperHubServiceClientListGitHubOAuthOptions contains the optional parameters for the DeveloperHubServiceClient.ListGitHubOAuth +// method. +type DeveloperHubServiceClientListGitHubOAuthOptions struct { + // placeholder for future optional parameters +} + +// GitHubOAuthCallRequest - GitHubOAuth request object +type GitHubOAuthCallRequest struct { + // The URL the client will redirect to on successful authentication. If empty, no redirect will occur. + RedirectURL *string `json:"redirectUrl,omitempty"` +} + +// GitHubOAuthInfoResponse - URL used to authorize the Developer Hub GitHub App +type GitHubOAuthInfoResponse struct { + // URL for authorizing the Developer Hub GitHub App + AuthURL *string `json:"authURL,omitempty"` + + // OAuth token used to make calls to GitHub + Token *string `json:"token,omitempty"` +} + +// GitHubOAuthListResponse - The response from List GitHubOAuth operation. +type GitHubOAuthListResponse struct { + // Singleton list response containing one GitHubOAuthResponse response + Value []*GitHubOAuthResponse `json:"value,omitempty"` +} + +// GitHubOAuthProperties - The response from List GitHubOAuth operation. +type GitHubOAuthProperties struct { + // user making request + Username *string `json:"username,omitempty"` +} + +// GitHubOAuthResponse - Singleton response of GitHubOAuth containing +type GitHubOAuthResponse struct { + // Properties of a workflow. + Properties *GitHubOAuthProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// GitHubWorkflowProfile - GitHub Workflow Profile +type GitHubWorkflowProfile struct { + // Information on the azure container registry + Acr *ACR `json:"acr,omitempty"` + + // The Azure Kubernetes Cluster Resource the application will be deployed to. + AksResourceID *string `json:"aksResourceId,omitempty"` + + // Determines the type of manifests within the repository. + AuthStatus *ManifestType `json:"authStatus,omitempty"` + + // Repository Branch Name + BranchName *string `json:"branchName,omitempty"` + DeploymentProperties *DeploymentProperties `json:"deploymentProperties,omitempty"` + + // Path to Dockerfile Build Context within the repository. + DockerBuildContext *string `json:"dockerBuildContext,omitempty"` + + // Path to the Dockerfile within the repository. + Dockerfile *string `json:"dockerfile,omitempty"` + LastWorkflowRun *WorkflowRun `json:"lastWorkflowRun,omitempty"` + + // Kubernetes namespace the application is deployed to. + Namespace *string `json:"namespace,omitempty"` + + // The fields needed for OIDC with GitHub. + OidcCredentials *GitHubWorkflowProfileOidcCredentials `json:"oidcCredentials,omitempty"` + + // Repository Name + RepositoryName *string `json:"repositoryName,omitempty"` + + // Repository Owner + RepositoryOwner *string `json:"repositoryOwner,omitempty"` + + // READ-ONLY; The status of the Pull Request submitted against the users repository. + PrStatus *PullRequestStatus `json:"prStatus,omitempty" azure:"ro"` + + // READ-ONLY; The URL to the Pull Request submitted against the users repository. + PrURL *string `json:"prURL,omitempty" azure:"ro"` + + // READ-ONLY; The number associated with the submitted pull request. + PullNumber *int32 `json:"pullNumber,omitempty" azure:"ro"` +} + +// GitHubWorkflowProfileOidcCredentials - The fields needed for OIDC with GitHub. +type GitHubWorkflowProfileOidcCredentials struct { + // Azure Application Client ID + AzureClientID *string `json:"azureClientId,omitempty"` + + // Azure Directory (tenant) ID + AzureTenantID *string `json:"azureTenantId,omitempty"` +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// TagsObject - Resource tags. +type TagsObject struct { + // Dictionary of + Tags map[string]*string `json:"tags,omitempty"` +} + +// Workflow - Resource representation of a workflow +type Workflow struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Properties of a workflow. + Properties *WorkflowProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// WorkflowClientCreateOrUpdateOptions contains the optional parameters for the WorkflowClient.CreateOrUpdate method. +type WorkflowClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkflowClientDeleteOptions contains the optional parameters for the WorkflowClient.Delete method. +type WorkflowClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkflowClientGetOptions contains the optional parameters for the WorkflowClient.Get method. +type WorkflowClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowClientListByResourceGroupOptions contains the optional parameters for the WorkflowClient.ListByResourceGroup method. +type WorkflowClientListByResourceGroupOptions struct { +} + +// WorkflowClientListOptions contains the optional parameters for the WorkflowClient.List method. +type WorkflowClientListOptions struct { + // placeholder for future optional parameters +} + +// WorkflowClientUpdateTagsOptions contains the optional parameters for the WorkflowClient.UpdateTags method. +type WorkflowClientUpdateTagsOptions struct { + // placeholder for future optional parameters +} + +// WorkflowListResult - The response from List Workflows operation. +type WorkflowListResult struct { + // The list of workflows. + Value []*Workflow `json:"value,omitempty"` + + // READ-ONLY; The URL to the next set of workflow results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// WorkflowProperties - Workflow properties +type WorkflowProperties struct { + // Profile of a github workflow. + GithubWorkflowProfile *GitHubWorkflowProfile `json:"githubWorkflowProfile,omitempty"` +} + +type WorkflowRun struct { + // READ-ONLY; The timestamp of the last workflow run. + LastRunAt *time.Time `json:"lastRunAt,omitempty" azure:"ro"` + + // READ-ONLY; Describes if the workflow run succeeded. + Succeeded *bool `json:"succeeded,omitempty" azure:"ro"` + + // READ-ONLY; URL to the run of the workflow. + WorkflowRunURL *string `json:"workflowRunURL,omitempty" azure:"ro"` +} diff --git a/sdk/resourcemanager/devhub/armdevhub/models_serde.go b/sdk/resourcemanager/devhub/armdevhub/models_serde.go new file mode 100644 index 000000000000..064c3efa8269 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/models_serde.go @@ -0,0 +1,746 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ACR. +func (a ACR) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "acrRegistryName", a.AcrRegistryName) + populate(objectMap, "acrRepositoryName", a.AcrRepositoryName) + populate(objectMap, "acrResourceGroup", a.AcrResourceGroup) + populate(objectMap, "acrSubscriptionId", a.AcrSubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ACR. +func (a *ACR) 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 "acrRegistryName": + err = unpopulate(val, "AcrRegistryName", &a.AcrRegistryName) + delete(rawMsg, key) + case "acrRepositoryName": + err = unpopulate(val, "AcrRepositoryName", &a.AcrRepositoryName) + delete(rawMsg, key) + case "acrResourceGroup": + err = unpopulate(val, "AcrResourceGroup", &a.AcrResourceGroup) + delete(rawMsg, key) + case "acrSubscriptionId": + err = unpopulate(val, "AcrSubscriptionID", &a.AcrSubscriptionID) + 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 DeleteWorkflowResponse. +func (d DeleteWorkflowResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "status", d.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeleteWorkflowResponse. +func (d *DeleteWorkflowResponse) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "status": + err = unpopulate(val, "Status", &d.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentProperties. +func (d DeploymentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "helmChartPath", d.HelmChartPath) + populate(objectMap, "helmValues", d.HelmValues) + populate(objectMap, "kubeManifestLocations", d.KubeManifestLocations) + populate(objectMap, "manifestType", d.ManifestType) + populate(objectMap, "overrides", d.Overrides) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentProperties. +func (d *DeploymentProperties) 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "helmChartPath": + err = unpopulate(val, "HelmChartPath", &d.HelmChartPath) + delete(rawMsg, key) + case "helmValues": + err = unpopulate(val, "HelmValues", &d.HelmValues) + delete(rawMsg, key) + case "kubeManifestLocations": + err = unpopulate(val, "KubeManifestLocations", &d.KubeManifestLocations) + delete(rawMsg, key) + case "manifestType": + err = unpopulate(val, "ManifestType", &d.ManifestType) + delete(rawMsg, key) + case "overrides": + err = unpopulate(val, "Overrides", &d.Overrides) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitHubOAuthCallRequest. +func (g GitHubOAuthCallRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "redirectUrl", g.RedirectURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitHubOAuthCallRequest. +func (g *GitHubOAuthCallRequest) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "redirectUrl": + err = unpopulate(val, "RedirectURL", &g.RedirectURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitHubOAuthInfoResponse. +func (g GitHubOAuthInfoResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authURL", g.AuthURL) + populate(objectMap, "token", g.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitHubOAuthInfoResponse. +func (g *GitHubOAuthInfoResponse) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authURL": + err = unpopulate(val, "AuthURL", &g.AuthURL) + delete(rawMsg, key) + case "token": + err = unpopulate(val, "Token", &g.Token) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitHubOAuthListResponse. +func (g GitHubOAuthListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitHubOAuthListResponse. +func (g *GitHubOAuthListResponse) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitHubOAuthProperties. +func (g GitHubOAuthProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "username", g.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitHubOAuthProperties. +func (g *GitHubOAuthProperties) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "username": + err = unpopulate(val, "Username", &g.Username) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitHubOAuthResponse. +func (g GitHubOAuthResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "systemData", g.SystemData) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitHubOAuthResponse. +func (g *GitHubOAuthResponse) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitHubWorkflowProfile. +func (g GitHubWorkflowProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "acr", g.Acr) + populate(objectMap, "aksResourceId", g.AksResourceID) + populate(objectMap, "authStatus", g.AuthStatus) + populate(objectMap, "branchName", g.BranchName) + populate(objectMap, "deploymentProperties", g.DeploymentProperties) + populate(objectMap, "dockerBuildContext", g.DockerBuildContext) + populate(objectMap, "dockerfile", g.Dockerfile) + populate(objectMap, "lastWorkflowRun", g.LastWorkflowRun) + populate(objectMap, "namespace", g.Namespace) + populate(objectMap, "oidcCredentials", g.OidcCredentials) + populate(objectMap, "prStatus", g.PrStatus) + populate(objectMap, "prURL", g.PrURL) + populate(objectMap, "pullNumber", g.PullNumber) + populate(objectMap, "repositoryName", g.RepositoryName) + populate(objectMap, "repositoryOwner", g.RepositoryOwner) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitHubWorkflowProfile. +func (g *GitHubWorkflowProfile) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "acr": + err = unpopulate(val, "Acr", &g.Acr) + delete(rawMsg, key) + case "aksResourceId": + err = unpopulate(val, "AksResourceID", &g.AksResourceID) + delete(rawMsg, key) + case "authStatus": + err = unpopulate(val, "AuthStatus", &g.AuthStatus) + delete(rawMsg, key) + case "branchName": + err = unpopulate(val, "BranchName", &g.BranchName) + delete(rawMsg, key) + case "deploymentProperties": + err = unpopulate(val, "DeploymentProperties", &g.DeploymentProperties) + delete(rawMsg, key) + case "dockerBuildContext": + err = unpopulate(val, "DockerBuildContext", &g.DockerBuildContext) + delete(rawMsg, key) + case "dockerfile": + err = unpopulate(val, "Dockerfile", &g.Dockerfile) + delete(rawMsg, key) + case "lastWorkflowRun": + err = unpopulate(val, "LastWorkflowRun", &g.LastWorkflowRun) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &g.Namespace) + delete(rawMsg, key) + case "oidcCredentials": + err = unpopulate(val, "OidcCredentials", &g.OidcCredentials) + delete(rawMsg, key) + case "prStatus": + err = unpopulate(val, "PrStatus", &g.PrStatus) + delete(rawMsg, key) + case "prURL": + err = unpopulate(val, "PrURL", &g.PrURL) + delete(rawMsg, key) + case "pullNumber": + err = unpopulate(val, "PullNumber", &g.PullNumber) + delete(rawMsg, key) + case "repositoryName": + err = unpopulate(val, "RepositoryName", &g.RepositoryName) + delete(rawMsg, key) + case "repositoryOwner": + err = unpopulate(val, "RepositoryOwner", &g.RepositoryOwner) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitHubWorkflowProfileOidcCredentials. +func (g GitHubWorkflowProfileOidcCredentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "azureClientId", g.AzureClientID) + populate(objectMap, "azureTenantId", g.AzureTenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitHubWorkflowProfileOidcCredentials. +func (g *GitHubWorkflowProfileOidcCredentials) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureClientId": + err = unpopulate(val, "AzureClientID", &g.AzureClientID) + delete(rawMsg, key) + case "azureTenantId": + err = unpopulate(val, "AzureTenantID", &g.AzureTenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) 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", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) 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", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) 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", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + 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 TagsObject. +func (t TagsObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagsObject. +func (t *TagsObject) 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 "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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]interface{}) + populate(objectMap, "id", w.ID) + populate(objectMap, "location", w.Location) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "systemData", w.SystemData) + populate(objectMap, "tags", w.Tags) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Workflow. +func (w *Workflow) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &w.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &w.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &w.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &w.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkflowListResult. +func (w WorkflowListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkflowListResult. +func (w *WorkflowListResult) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &w.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkflowProperties. +func (w WorkflowProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "githubWorkflowProfile", w.GithubWorkflowProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkflowProperties. +func (w *WorkflowProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "githubWorkflowProfile": + err = unpopulate(val, "GithubWorkflowProfile", &w.GithubWorkflowProfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkflowRun. +func (w WorkflowRun) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "lastRunAt", w.LastRunAt) + populate(objectMap, "succeeded", w.Succeeded) + populate(objectMap, "workflowRunURL", w.WorkflowRunURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkflowRun. +func (w *WorkflowRun) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "lastRunAt": + err = unpopulateTimeRFC3339(val, "LastRunAt", &w.LastRunAt) + delete(rawMsg, key) + case "succeeded": + err = unpopulate(val, "Succeeded", &w.Succeeded) + delete(rawMsg, key) + case "workflowRunURL": + err = unpopulate(val, "WorkflowRunURL", &w.WorkflowRunURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/operations_client.go b/sdk/resourcemanager/devhub/armdevhub/operations_client.go new file mode 100644 index 000000000000..f4532c4d90ef --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/operations_client.go @@ -0,0 +1,92 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevhub + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// List - Returns list of operations. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-04-01-preview +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.DevHub/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-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 *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/operations_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/operations_client_example_test.go new file mode 100644 index 000000000000..6ad34d3f2ae4 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/operations_client_example_test.go @@ -0,0 +1,36 @@ +//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. + +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/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewOperationsClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.List(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/devhub/armdevhub/response_types.go b/sdk/resourcemanager/devhub/armdevhub/response_types.go new file mode 100644 index 000000000000..d2abb036052a --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/response_types.go @@ -0,0 +1,60 @@ +//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 + +// DeveloperHubServiceClientGitHubOAuthCallbackResponse contains the response from method DeveloperHubServiceClient.GitHubOAuthCallback. +type DeveloperHubServiceClientGitHubOAuthCallbackResponse struct { + GitHubOAuthResponse +} + +// DeveloperHubServiceClientGitHubOAuthResponse contains the response from method DeveloperHubServiceClient.GitHubOAuth. +type DeveloperHubServiceClientGitHubOAuthResponse struct { + GitHubOAuthInfoResponse +} + +// DeveloperHubServiceClientListGitHubOAuthResponse contains the response from method DeveloperHubServiceClient.ListGitHubOAuth. +type DeveloperHubServiceClientListGitHubOAuthResponse struct { + GitHubOAuthListResponse +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + OperationListResult +} + +// WorkflowClientCreateOrUpdateResponse contains the response from method WorkflowClient.CreateOrUpdate. +type WorkflowClientCreateOrUpdateResponse struct { + Workflow +} + +// WorkflowClientDeleteResponse contains the response from method WorkflowClient.Delete. +type WorkflowClientDeleteResponse struct { + DeleteWorkflowResponse +} + +// WorkflowClientGetResponse contains the response from method WorkflowClient.Get. +type WorkflowClientGetResponse struct { + Workflow +} + +// WorkflowClientListByResourceGroupResponse contains the response from method WorkflowClient.ListByResourceGroup. +type WorkflowClientListByResourceGroupResponse struct { + WorkflowListResult +} + +// WorkflowClientListResponse contains the response from method WorkflowClient.List. +type WorkflowClientListResponse struct { + WorkflowListResult +} + +// WorkflowClientUpdateTagsResponse contains the response from method WorkflowClient.UpdateTags. +type WorkflowClientUpdateTagsResponse struct { + Workflow +} diff --git a/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go b/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go new file mode 100644 index 000000000000..cc5fb17bbbe2 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/time_rfc3339.go @@ -0,0 +1,87 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/workflow_client.go b/sdk/resourcemanager/devhub/armdevhub/workflow_client.go new file mode 100644 index 000000000000..804a26a015fa --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/workflow_client.go @@ -0,0 +1,409 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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" +) + +// WorkflowClient contains the methods for the Workflow group. +// Don't use this type directly, use NewWorkflowClient() instead. +type WorkflowClient struct { + host string + subscriptionID string + managedClusterResource *string + pl runtime.Pipeline +} + +// NewWorkflowClient creates a new instance of WorkflowClient with the specified values. +// subscriptionID - The ID of the target subscription. +// managedClusterResource - The ManagedCluster resource associated with the workflows. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewWorkflowClient(subscriptionID string, managedClusterResource *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &WorkflowClient{ + subscriptionID: subscriptionID, + managedClusterResource: managedClusterResource, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a workflow +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-04-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. +func (client *WorkflowClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workflowName string, parameters Workflow, options *WorkflowClientCreateOrUpdateOptions) (WorkflowClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workflowName, parameters, options) + if err != nil { + return WorkflowClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkflowClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return WorkflowClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkflowClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workflowName string, parameters Workflow, options *WorkflowClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" + 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 workflowName == "" { + return nil, errors.New("parameter workflowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workflowName}", url.PathEscape(workflowName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkflowClient) createOrUpdateHandleResponse(resp *http.Response) (WorkflowClientCreateOrUpdateResponse, error) { + result := WorkflowClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Workflow); err != nil { + return WorkflowClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a workflow +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-04-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. +func (client *WorkflowClient) Delete(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowClientDeleteOptions) (WorkflowClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workflowName, options) + if err != nil { + return WorkflowClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkflowClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return WorkflowClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return client.deleteHandleResponse(resp) +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkflowClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" + 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 workflowName == "" { + return nil, errors.New("parameter workflowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workflowName}", url.PathEscape(workflowName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// deleteHandleResponse handles the Delete response. +func (client *WorkflowClient) deleteHandleResponse(resp *http.Response) (WorkflowClientDeleteResponse, error) { + result := WorkflowClientDeleteResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeleteWorkflowResponse); err != nil { + return WorkflowClientDeleteResponse{}, err + } + return result, nil +} + +// Get - Gets a workflow. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-04-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. +func (client *WorkflowClient) Get(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowClientGetOptions) (WorkflowClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workflowName, options) + if err != nil { + return WorkflowClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkflowClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkflowClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *WorkflowClient) getCreateRequest(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" + 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 workflowName == "" { + return nil, errors.New("parameter workflowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workflowName}", url.PathEscape(workflowName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-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 *WorkflowClient) getHandleResponse(resp *http.Response) (WorkflowClientGetResponse, error) { + result := WorkflowClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Workflow); err != nil { + return WorkflowClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets a list of workflows associated with the specified subscription. +// Generated from API version 2022-04-01-preview +// options - WorkflowClientListOptions contains the optional parameters for the WorkflowClient.List method. +func (client *WorkflowClient) NewListPager(options *WorkflowClientListOptions) *runtime.Pager[WorkflowClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkflowClientListResponse]{ + More: func(page WorkflowClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkflowClientListResponse) (WorkflowClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return WorkflowClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkflowClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkflowClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *WorkflowClient) listCreateRequest(ctx context.Context, options *WorkflowClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/workflows" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-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 *WorkflowClient) listHandleResponse(resp *http.Response) (WorkflowClientListResponse, error) { + result := WorkflowClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkflowListResult); err != nil { + return WorkflowClientListResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets a list of workflows within a resource group. +// Generated from API version 2022-04-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - WorkflowClientListByResourceGroupOptions contains the optional parameters for the WorkflowClient.ListByResourceGroup +// method. +func (client *WorkflowClient) NewListByResourceGroupPager(resourceGroupName string, options *WorkflowClientListByResourceGroupOptions) *runtime.Pager[WorkflowClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkflowClientListByResourceGroupResponse]{ + More: func(page WorkflowClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkflowClientListByResourceGroupResponse) (WorkflowClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return WorkflowClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkflowClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkflowClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *WorkflowClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *WorkflowClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01-preview") + if client.managedClusterResource != nil { + reqQP.Set("managedClusterResource", *client.managedClusterResource) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *WorkflowClient) listByResourceGroupHandleResponse(resp *http.Response) (WorkflowClientListByResourceGroupResponse, error) { + result := WorkflowClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkflowListResult); err != nil { + return WorkflowClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// UpdateTags - Updates tags on a workflow. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-04-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. +// options - WorkflowClientUpdateTagsOptions contains the optional parameters for the WorkflowClient.UpdateTags method. +func (client *WorkflowClient) UpdateTags(ctx context.Context, resourceGroupName string, workflowName string, parameters TagsObject, options *WorkflowClientUpdateTagsOptions) (WorkflowClientUpdateTagsResponse, error) { + req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, workflowName, parameters, options) + if err != nil { + return WorkflowClientUpdateTagsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return WorkflowClientUpdateTagsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkflowClientUpdateTagsResponse{}, runtime.NewResponseError(resp) + } + return client.updateTagsHandleResponse(resp) +} + +// updateTagsCreateRequest creates the UpdateTags request. +func (client *WorkflowClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, workflowName string, parameters TagsObject, options *WorkflowClientUpdateTagsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" + 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 workflowName == "" { + return nil, errors.New("parameter workflowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workflowName}", url.PathEscape(workflowName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateTagsHandleResponse handles the UpdateTags response. +func (client *WorkflowClient) updateTagsHandleResponse(resp *http.Response) (WorkflowClientUpdateTagsResponse, error) { + result := WorkflowClientUpdateTagsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Workflow); err != nil { + return WorkflowClientUpdateTagsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devhub/armdevhub/workflow_client_example_test.go b/sdk/resourcemanager/devhub/armdevhub/workflow_client_example_test.go new file mode 100644 index 000000000000..52b6cf1a3d17 --- /dev/null +++ b/sdk/resourcemanager/devhub/armdevhub/workflow_client_example_test.go @@ -0,0 +1,180 @@ +//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. + +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/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewWorkflowClient("subscriptionId1", nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewWorkflowClient("subscriptionId1", to.Ptr("/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1"), cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("resourceGroup1", nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewWorkflowClient("subscriptionId1", nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "resourceGroup1", "workflow1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-preview/examples/Workflow_CreateOrUpdate.json +func ExampleWorkflowClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armdevhub.NewWorkflowClient("subscriptionId1", nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.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"), + 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) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewWorkflowClient("subscriptionId1", nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Delete(ctx, "resourceGroup1", "workflow1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-04-01-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() + client, err := armdevhub.NewWorkflowClient("subscriptionId1", nil, cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.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) + } + // TODO: use response item + _ = res +}