From 757415ba8c36091b28c297979127ef6550a878de Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Wed, 23 Oct 2024 08:14:09 -0700 Subject: [PATCH] Skip api-version param when emitting examples (#1453) --- packages/typespec-go/.scripts/tspcompile.js | 6 +- .../typespec-go/src/tcgcadapter/clients.ts | 4 + packages/typespec-go/test/armapicenter/go.mod | 12 +- packages/typespec-go/test/armapicenter/go.sum | 17 + .../zz_apidefinitions_client_example_test.go | 251 ++++ .../zz_apis_client_example_test.go | 239 ++++ .../zz_apiversions_client_example_test.go | 176 +++ .../zz_deletedservices_client_example_test.go | 145 +++ .../zz_deployments_client_example_test.go | 208 ++++ .../zz_environments_client_example_test.go | 225 ++++ .../zz_metadataschemas_client_example_test.go | 196 +++ .../zz_operations_client_example_test.go | 53 + .../zz_services_client_example_test.go | 315 +++++ .../zz_workspaces_client_example_test.go | 172 +++ .../typespec-go/test/armcodesigning/go.mod | 12 +- .../typespec-go/test/armcodesigning/go.sum | 17 + .../zz_accounts_client_example_test.go | 280 +++++ ...certificateprofiles_client_example_test.go | 225 ++++ .../zz_operations_client_example_test.go | 70 ++ .../test/armcommunitymanagement/go.mod | 12 +- .../test/armcommunitymanagement/go.sum | 17 + ..._communitytrainings_client_example_test.go | 414 +++++++ .../zz_operations_client_example_test.go | 103 ++ .../test/armdatabasewatcher/go.mod | 12 +- .../test/armdatabasewatcher/go.sum | 17 + ..._alertruleresources_client_example_test.go | 183 +++ .../zz_operations_client_example_test.go | 85 ++ ...rivatelinkresources_client_example_test.go | 182 +++ .../zz_targets_client_example_test.go | 178 +++ .../zz_watchers_client_example_test.go | 871 ++++++++++++++ .../test/armdevopsinfrastructure/go.mod | 12 +- .../test/armdevopsinfrastructure/go.sum | 17 + .../zz_imageversions_client_example_test.go | 51 + .../zz_operations_client_example_test.go | 41 + .../zz_pools_client_example_test.go | 272 +++++ .../zz_resourcedetails_client_example_test.go | 61 + .../zz_sku_client_example_test.go | 307 +++++ ..._subscriptionusages_client_example_test.go | 63 + .../typespec-go/test/armmongocluster/go.mod | 12 +- .../typespec-go/test/armmongocluster/go.sum | 17 + .../zz_firewallrules_client_example_test.go | 190 +++ .../zz_mongoclusters_client_example_test.go | 1058 +++++++++++++++++ .../zz_operations_client_example_test.go | 61 + ...endpointconnections_client_example_test.go | 201 ++++ .../zz_privatelinks_client_example_test.go | 57 + .../zz_replicas_client_example_test.go | 50 + 46 files changed, 7158 insertions(+), 9 deletions(-) create mode 100644 packages/typespec-go/test/armapicenter/zz_apidefinitions_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_apis_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_apiversions_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_deletedservices_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_deployments_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_environments_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_metadataschemas_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_operations_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_services_client_example_test.go create mode 100644 packages/typespec-go/test/armapicenter/zz_workspaces_client_example_test.go create mode 100644 packages/typespec-go/test/armcodesigning/zz_accounts_client_example_test.go create mode 100644 packages/typespec-go/test/armcodesigning/zz_certificateprofiles_client_example_test.go create mode 100644 packages/typespec-go/test/armcodesigning/zz_operations_client_example_test.go create mode 100644 packages/typespec-go/test/armcommunitymanagement/zz_communitytrainings_client_example_test.go create mode 100644 packages/typespec-go/test/armcommunitymanagement/zz_operations_client_example_test.go create mode 100644 packages/typespec-go/test/armdatabasewatcher/zz_alertruleresources_client_example_test.go create mode 100644 packages/typespec-go/test/armdatabasewatcher/zz_operations_client_example_test.go create mode 100644 packages/typespec-go/test/armdatabasewatcher/zz_sharedprivatelinkresources_client_example_test.go create mode 100644 packages/typespec-go/test/armdatabasewatcher/zz_targets_client_example_test.go create mode 100644 packages/typespec-go/test/armdatabasewatcher/zz_watchers_client_example_test.go create mode 100644 packages/typespec-go/test/armdevopsinfrastructure/zz_imageversions_client_example_test.go create mode 100644 packages/typespec-go/test/armdevopsinfrastructure/zz_operations_client_example_test.go create mode 100644 packages/typespec-go/test/armdevopsinfrastructure/zz_pools_client_example_test.go create mode 100644 packages/typespec-go/test/armdevopsinfrastructure/zz_resourcedetails_client_example_test.go create mode 100644 packages/typespec-go/test/armdevopsinfrastructure/zz_sku_client_example_test.go create mode 100644 packages/typespec-go/test/armdevopsinfrastructure/zz_subscriptionusages_client_example_test.go create mode 100644 packages/typespec-go/test/armmongocluster/zz_firewallrules_client_example_test.go create mode 100644 packages/typespec-go/test/armmongocluster/zz_mongoclusters_client_example_test.go create mode 100644 packages/typespec-go/test/armmongocluster/zz_operations_client_example_test.go create mode 100644 packages/typespec-go/test/armmongocluster/zz_privateendpointconnections_client_example_test.go create mode 100644 packages/typespec-go/test/armmongocluster/zz_privatelinks_client_example_test.go create mode 100644 packages/typespec-go/test/armmongocluster/zz_replicas_client_example_test.go diff --git a/packages/typespec-go/.scripts/tspcompile.js b/packages/typespec-go/.scripts/tspcompile.js index 769229149..9ba4b1052 100644 --- a/packages/typespec-go/.scripts/tspcompile.js +++ b/packages/typespec-go/.scripts/tspcompile.js @@ -129,13 +129,13 @@ const armapicenter = pkgRoot + 'test/tsp/ApiCenter.Management'; generate('armapicenter', armapicenter, 'test/armapicenter'); const armlargeinstance = pkgRoot + 'test/tsp/AzureLargeInstance.Management'; -generate('armlargeinstance', armlargeinstance, 'test/armlargeinstance', ['stutter=AzureLargeInstance']); +generate('armlargeinstance', armlargeinstance, 'test/armlargeinstance', ['stutter=AzureLargeInstance', 'generate-examples=false']); const armdatabasewatcher = pkgRoot + 'test/tsp/DatabaseWatcher.Management'; generate('armdatabasewatcher', armdatabasewatcher, 'test/armdatabasewatcher', ['remove-unreferenced-types=false', 'fix-const-stuttering=false']); const armloadtestservice = pkgRoot + 'test/tsp/LoadTestService.Management'; -generate('armloadtestservice', armloadtestservice, 'test/armloadtestservice'); +generate('armloadtestservice', armloadtestservice, 'test/armloadtestservice', ['generate-examples=false']); const armdevopsinfrastructure = pkgRoot + 'test/tsp/Microsoft.DevOpsInfrastructure'; generate('armdevopsinfrastructure', armdevopsinfrastructure, 'test/armdevopsinfrastructure'); @@ -196,7 +196,7 @@ function generate(moduleName, input, outputDir, perTestOptions) { 'remove-unreferenced-types=true', 'fix-const-stuttering=true', `examples-directory=${input}/examples`, - 'generate-examples=false' + 'generate-examples=true' ]; let allOptions = fixedOptions; diff --git a/packages/typespec-go/src/tcgcadapter/clients.ts b/packages/typespec-go/src/tcgcadapter/clients.ts index c06e3f2b4..d9ed573f2 100644 --- a/packages/typespec-go/src/tcgcadapter/clients.ts +++ b/packages/typespec-go/src/tcgcadapter/clients.ts @@ -710,6 +710,10 @@ export class clientAdapter { for (const example of sdkMethod.operation.examples) { const goExample = new go.MethodExample(example.name, {summary: example.description}, example.filePath); for (const param of example.parameters) { + if (param.parameter.isApiVersionParam && param.parameter.clientDefaultValue) { + // skip the api-version param as it's not a formal parameter + continue; + } const goParams = paramMapping.get(param.parameter); if (!goParams) { throw new Error(`can not find go param for example param ${param.parameter.name}`); diff --git a/packages/typespec-go/test/armapicenter/go.mod b/packages/typespec-go/test/armapicenter/go.mod index 62881338c..0084d4dad 100644 --- a/packages/typespec-go/test/armapicenter/go.mod +++ b/packages/typespec-go/test/armapicenter/go.mod @@ -2,10 +2,20 @@ module armapicenter go 1.18 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/packages/typespec-go/test/armapicenter/go.sum b/packages/typespec-go/test/armapicenter/go.sum index fb5e8f74b..0f58a50c0 100644 --- a/packages/typespec-go/test/armapicenter/go.sum +++ b/packages/typespec-go/test/armapicenter/go.sum @@ -1,12 +1,29 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/packages/typespec-go/test/armapicenter/zz_apidefinitions_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_apidefinitions_client_example_test.go new file mode 100644 index 000000000..314c716cc --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_apidefinitions_client_example_test.go @@ -0,0 +1,251 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/ApiDefinitions_CreateOrUpdate.json +func ExampleAPIDefinitionsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAPIDefinitionsClient().CreateOrUpdate(ctx, "contoso-resources", "contoso", "default", "openapi", "2023-01-01", "openapi", armapicenter.APIDefinition{ + Properties: &armapicenter.APIDefinitionProperties{ + Title: to.Ptr("OpenAPI"), + Description: to.Ptr("Default spec"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIDefinitionsClientCreateOrUpdateResponse{ + // APIDefinition: &armapicenter.APIDefinition{ + // Type: to.Ptr("Microsoft.ApiCenter/services/apis/versions/definitions"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi"), + // Name: to.Ptr("openapi"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIDefinitionProperties{ + // Title: to.Ptr("OpenAPI"), + // Description: to.Ptr("Default spec"), + // Specification: &armapicenter.APIDefinitionPropertiesSpecification{ + // Name: to.Ptr("openapi"), + // Version: to.Ptr("3.0.6"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiDefinitions_Delete.json +func ExampleAPIDefinitionsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAPIDefinitionsClient().Delete(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", "openapi", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIDefinitionsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiDefinitions_ExportSpecification.json +func ExampleAPIDefinitionsClient_BeginExportSpecification() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAPIDefinitionsClient().BeginExportSpecification(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", "openapi", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIDefinitionsClientExportSpecificationResponse{ + // APISpecExportResult: &armapicenter.APISpecExportResult{ + // Format: to.Ptr(armapicenter.APISpecExportResultFormatInline), + // Value: to.Ptr("{ ... }"), + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiDefinitions_Get.json +func ExampleAPIDefinitionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAPIDefinitionsClient().Get(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", "openapi", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIDefinitionsClientGetResponse{ + // APIDefinition: &armapicenter.APIDefinition{ + // Type: to.Ptr("Microsoft.ApiCenter/services/apis/versions/definitions"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi"), + // Name: to.Ptr("openapi"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIDefinitionProperties{ + // Title: to.Ptr("OpenAPI"), + // Description: to.Ptr("Default spec"), + // Specification: &armapicenter.APIDefinitionPropertiesSpecification{ + // Name: to.Ptr("openapi"), + // Version: to.Ptr("3.0.6"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiDefinitions_Head.json +func ExampleAPIDefinitionsClient_Head() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAPIDefinitionsClient().Head(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", "openapi", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIDefinitionsClientHeadResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiDefinitions_ImportSpecification.json +func ExampleAPIDefinitionsClient_BeginImportSpecification() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAPIDefinitionsClient().BeginImportSpecification(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", "openapi", armapicenter.APISpecImportRequest{ + Format: to.Ptr(armapicenter.APISpecImportSourceFormatLink), + Value: to.Ptr("https://..."), + Specification: &armapicenter.APISpecImportRequestSpecification{ + Name: to.Ptr("openapi"), + Version: to.Ptr("3.0.1"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIDefinitionsClientImportSpecificationResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiDefinitions_List.json +func ExampleAPIDefinitionsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAPIDefinitionsClient().NewListPager("contoso-resources", "contoso", "default", "echo-api", "2023-01-01", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.APIDefinitionsClientListResponse{ + // APIDefinitionListResult: armapicenter.APIDefinitionListResult{ + // Value: []*armapicenter.APIDefinition{ + // { + // Type: to.Ptr("Microsoft.ApiCenter/services/apis/versions/definitions"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi"), + // Name: to.Ptr("openapi"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIDefinitionProperties{ + // Title: to.Ptr("OpenAPI"), + // Description: to.Ptr("Default spec"), + // Specification: &armapicenter.APIDefinitionPropertiesSpecification{ + // Name: to.Ptr("openapi"), + // Version: to.Ptr("3.0.6"), + // }, + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armapicenter/zz_apis_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_apis_client_example_test.go new file mode 100644 index 000000000..0e38d921f --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_apis_client_example_test.go @@ -0,0 +1,239 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/Apis_CreateOrUpdate.json +func ExampleApisClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApisClient().CreateOrUpdate(ctx, "contoso-resources", "contoso", "default", "echo-api", armapicenter.API{ + Properties: &armapicenter.APIProperties{ + Title: to.Ptr("Echo API"), + Description: to.Ptr("A simple HTTP request/response service."), + LifecycleStage: to.Ptr(armapicenter.LifecycleStageDesign), + Kind: to.Ptr(armapicenter.APIKindRest), + TermsOfService: &armapicenter.TermsOfService{ + URL: to.Ptr("https://contoso.com/terms-of-service"), + }, + License: &armapicenter.License{ + URL: to.Ptr("https://contoso.com/license"), + }, + ExternalDocumentation: []*armapicenter.ExternalDocumentation{ + { + Title: to.Ptr("Onboarding docs"), + URL: to.Ptr("https://docs.contoso.com"), + }, + }, + CustomProperties: &armapicenter.CustomProperties{}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ApisClientCreateOrUpdateResponse{ + // API: &armapicenter.API{ + // Type: to.Ptr("Microsoft.ApiCenter/services/apis"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api"), + // Name: to.Ptr("echo-api"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIProperties{ + // Title: to.Ptr("Echo API"), + // Description: to.Ptr("A simple HTTP request/response service."), + // LifecycleStage: to.Ptr(armapicenter.LifecycleStageDesign), + // Kind: to.Ptr(armapicenter.APIKindRest), + // TermsOfService: &armapicenter.TermsOfService{ + // URL: to.Ptr("https://contoso.com/terms-of-service"), + // }, + // License: &armapicenter.License{ + // URL: to.Ptr("https://contoso.com/license"), + // }, + // ExternalDocumentation: []*armapicenter.ExternalDocumentation{ + // { + // Title: to.Ptr("Onboarding docs"), + // URL: to.Ptr("https://docs.contoso.com"), + // }, + // }, + // CustomProperties: &armapicenter.CustomProperties{ + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Apis_Delete.json +func ExampleApisClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApisClient().Delete(ctx, "contoso-resources", "contoso", "default", "echo-api", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ApisClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Apis_Get.json +func ExampleApisClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApisClient().Get(ctx, "contoso-resources", "contoso", "default", "echo-api", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ApisClientGetResponse{ + // API: &armapicenter.API{ + // Type: to.Ptr("Microsoft.ApiCenter/services/apis"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api"), + // Name: to.Ptr("public"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIProperties{ + // Title: to.Ptr("Echo API"), + // Description: to.Ptr("A simple HTTP request/response service."), + // LifecycleStage: to.Ptr(armapicenter.LifecycleStageDesign), + // Kind: to.Ptr(armapicenter.APIKindRest), + // TermsOfService: &armapicenter.TermsOfService{ + // URL: to.Ptr("https://contoso.com/terms-of-service"), + // }, + // License: &armapicenter.License{ + // URL: to.Ptr("https://contoso.com/license"), + // }, + // ExternalDocumentation: []*armapicenter.ExternalDocumentation{ + // { + // Title: to.Ptr("Onboarding docs"), + // URL: to.Ptr("https://docs.contoso.com"), + // }, + // }, + // CustomProperties: &armapicenter.CustomProperties{ + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Apis_Head.json +func ExampleApisClient_Head() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApisClient().Head(ctx, "contoso-resources", "contoso", "default", "echo-api", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ApisClientHeadResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Apis_List.json +func ExampleApisClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewApisClient().NewListPager("contoso-resources", "contoso", "default", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.ApisClientListResponse{ + // APIListResult: armapicenter.APIListResult{ + // Value: []*armapicenter.API{ + // { + // Type: to.Ptr("Microsoft.ApiCenter/services/environments"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api"), + // Name: to.Ptr("echo-api"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIProperties{ + // Title: to.Ptr("Echo API"), + // Description: to.Ptr("A simple HTTP request/response service."), + // LifecycleStage: to.Ptr(armapicenter.LifecycleStageDesign), + // Kind: to.Ptr(armapicenter.APIKindRest), + // TermsOfService: &armapicenter.TermsOfService{ + // URL: to.Ptr("https://contoso.com/terms-of-service"), + // }, + // License: &armapicenter.License{ + // URL: to.Ptr("https://contoso.com/license"), + // }, + // ExternalDocumentation: []*armapicenter.ExternalDocumentation{ + // { + // Title: to.Ptr("Onboarding docs"), + // URL: to.Ptr("https://docs.contoso.com"), + // }, + // }, + // CustomProperties: &armapicenter.CustomProperties{ + // }, + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armapicenter/zz_apiversions_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_apiversions_client_example_test.go new file mode 100644 index 000000000..ee1a67bb6 --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_apiversions_client_example_test.go @@ -0,0 +1,176 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/ApiVersions_CreateOrUpdate.json +func ExampleAPIVersionsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAPIVersionsClient().CreateOrUpdate(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", armapicenter.APIVersion{ + Properties: &armapicenter.APIVersionProperties{ + Title: to.Ptr("2023-01-01"), + LifecycleStage: to.Ptr(armapicenter.LifecycleStageProduction), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIVersionsClientCreateOrUpdateResponse{ + // APIVersion: &armapicenter.APIVersion{ + // Type: to.Ptr("Microsoft.ApiCenter/services/workspaces/apis/versions"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api/versions/2023-01-01"), + // Name: to.Ptr("2023-01-01"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIVersionProperties{ + // Title: to.Ptr("2023-01-01"), + // LifecycleStage: to.Ptr(armapicenter.LifecycleStageProduction), + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiVersions_Delete.json +func ExampleAPIVersionsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAPIVersionsClient().Delete(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIVersionsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiVersions_Get.json +func ExampleAPIVersionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAPIVersionsClient().Get(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIVersionsClientGetResponse{ + // APIVersion: &armapicenter.APIVersion{ + // Type: to.Ptr("Microsoft.ApiCenter/services/workspaces/apis/versions"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api/versions/2023-01-01"), + // Name: to.Ptr("2023-01-01"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIVersionProperties{ + // Title: to.Ptr("2023-01-01"), + // LifecycleStage: to.Ptr(armapicenter.LifecycleStageProduction), + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiVersions_Head.json +func ExampleAPIVersionsClient_Head() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAPIVersionsClient().Head(ctx, "contoso-resources", "contoso", "default", "echo-api", "2023-01-01", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.APIVersionsClientHeadResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/ApiVersions_List.json +func ExampleAPIVersionsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAPIVersionsClient().NewListPager("contoso-resources", "contoso", "default", "echo-api", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.APIVersionsClientListResponse{ + // APIVersionListResult: armapicenter.APIVersionListResult{ + // Value: []*armapicenter.APIVersion{ + // { + // Type: to.Ptr("Microsoft.ApiCenter/services/environments"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/apis/echo-api/versions/2023-01-01"), + // Name: to.Ptr("public"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.APIVersionProperties{ + // Title: to.Ptr("2023-01-01"), + // LifecycleStage: to.Ptr(armapicenter.LifecycleStageProduction), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armapicenter/zz_deletedservices_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_deletedservices_client_example_test.go new file mode 100644 index 000000000..a9b4f9da4 --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_deletedservices_client_example_test.go @@ -0,0 +1,145 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/DeletedServices_Delete.json +func ExampleDeletedServicesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDeletedServicesClient().Delete(ctx, "contoso-resources", "contoso", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.DeletedServicesClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/DeletedServices_Get.json +func ExampleDeletedServicesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDeletedServicesClient().Get(ctx, "contoso-resources", "contoso", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.DeletedServicesClientGetResponse{ + // DeletedService: &armapicenter.DeletedService{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), + // Name: to.Ptr("contoso"), + // Type: to.Ptr("Microsoft.ApiCenter/deletedServices"), + // Properties: &armapicenter.DeletedServiceProperties{ + // SoftDeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-03-01T22:15:58.348Z"); return t}()), + // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-01T22:15:58.348Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/DeletedServices_ListBySubscription.json +func ExampleDeletedServicesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDeletedServicesClient().NewListPager("contoso-resources", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.DeletedServicesClientListResponse{ + // DeletedServiceListResult: armapicenter.DeletedServiceListResult{ + // Value: []*armapicenter.DeletedService{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), + // Name: to.Ptr("contoso"), + // Type: to.Ptr("Microsoft.ApiCenter/deletedServices"), + // Properties: &armapicenter.DeletedServiceProperties{ + // SoftDeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-03-01T22:15:58.348Z"); return t}()), + // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-01T22:15:58.348Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-03-15-preview/DeletedServices_List.json +func ExampleDeletedServicesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDeletedServicesClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.DeletedServicesClientListBySubscriptionResponse{ + // DeletedServiceListResult: armapicenter.DeletedServiceListResult{ + // Value: []*armapicenter.DeletedService{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), + // Name: to.Ptr("contoso"), + // Type: to.Ptr("Microsoft.ApiCenter/deletedServices"), + // Properties: &armapicenter.DeletedServiceProperties{ + // SoftDeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-03-01T22:15:58.348Z"); return t}()), + // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-01T22:15:58.348Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armapicenter/zz_deployments_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_deployments_client_example_test.go new file mode 100644 index 000000000..2dc78f185 --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_deployments_client_example_test.go @@ -0,0 +1,208 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/Deployments_CreateOrUpdate.json +func ExampleDeploymentsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDeploymentsClient().CreateOrUpdate(ctx, "contoso-resources", "contoso", "default", "echo-api", "production", armapicenter.Deployment{ + Properties: &armapicenter.DeploymentProperties{ + Title: to.Ptr("Production deployment"), + Description: to.Ptr("Public cloud production deployment."), + EnvironmentID: to.Ptr("/workspaces/default/environments/production"), + DefinitionID: to.Ptr("/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi"), + State: to.Ptr(armapicenter.DeploymentStateActive), + Server: &armapicenter.DeploymentServer{ + RuntimeURI: []*string{ + to.Ptr("https://api.contoso.com"), + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.DeploymentsClientCreateOrUpdateResponse{ + // Deployment: &armapicenter.Deployment{ + // Type: to.Ptr("Microsoft.ApiCenter/services/apis/deployments"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/deployments/production"), + // Name: to.Ptr("production"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.DeploymentProperties{ + // Title: to.Ptr("Production deployment"), + // Description: to.Ptr("Public cloud production deployment."), + // EnvironmentID: to.Ptr("/workspaces/default/environments/production"), + // DefinitionID: to.Ptr("/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi"), + // State: to.Ptr(armapicenter.DeploymentStateActive), + // Server: &armapicenter.DeploymentServer{ + // RuntimeURI: []*string{ + // to.Ptr("https://api.contoso.com"), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Deployments_Delete.json +func ExampleDeploymentsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDeploymentsClient().Delete(ctx, "contoso-resources", "contoso", "default", "echo-api", "production", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.DeploymentsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Deployments_Get.json +func ExampleDeploymentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDeploymentsClient().Get(ctx, "contoso-resources", "contoso", "default", "echo-api", "production", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.DeploymentsClientGetResponse{ + // Deployment: &armapicenter.Deployment{ + // Type: to.Ptr("Microsoft.ApiCenter/services/apis/deployments"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/deployments/production"), + // Name: to.Ptr("public"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.DeploymentProperties{ + // Title: to.Ptr("Production deployment"), + // Description: to.Ptr("Public cloud production deployment."), + // EnvironmentID: to.Ptr("/workspaces/default/environments/production"), + // DefinitionID: to.Ptr("/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi"), + // State: to.Ptr(armapicenter.DeploymentStateActive), + // Server: &armapicenter.DeploymentServer{ + // RuntimeURI: []*string{ + // to.Ptr("https://api.contoso.com"), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Deployments_Head.json +func ExampleDeploymentsClient_Head() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDeploymentsClient().Head(ctx, "contoso-resources", "contoso", "default", "echo-api", "production", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.DeploymentsClientHeadResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Deployments_List.json +func ExampleDeploymentsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDeploymentsClient().NewListPager("contoso-resources", "contoso", "default", "echo-api", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.DeploymentsClientListResponse{ + // DeploymentListResult: armapicenter.DeploymentListResult{ + // Value: []*armapicenter.Deployment{ + // { + // Type: to.Ptr("Microsoft.ApiCenter/services/apis/deployments"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/deployments/production"), + // Name: to.Ptr("public"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.DeploymentProperties{ + // Title: to.Ptr("Development"), + // Description: to.Ptr("Public cloud production deployment."), + // EnvironmentID: to.Ptr("/workspaces/default/environments/production"), + // DefinitionID: to.Ptr("/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi"), + // State: to.Ptr(armapicenter.DeploymentStateActive), + // Server: &armapicenter.DeploymentServer{ + // RuntimeURI: []*string{ + // to.Ptr("https://api.contoso.com"), + // }, + // }, + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armapicenter/zz_environments_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_environments_client_example_test.go new file mode 100644 index 000000000..3c7617e97 --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_environments_client_example_test.go @@ -0,0 +1,225 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/Environments_CreateOrUpdate.json +func ExampleEnvironmentsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().CreateOrUpdate(ctx, "contoso-resources", "contoso", "default", "public", armapicenter.Environment{ + Properties: &armapicenter.EnvironmentProperties{ + Title: to.Ptr("Contoso Europe Azure API Management"), + Description: to.Ptr("The primary Azure API Management service for the European division of Contoso."), + Kind: to.Ptr(armapicenter.EnvironmentKindProduction), + Server: &armapicenter.EnvironmentServer{ + Type: to.Ptr(armapicenter.EnvironmentServerTypeAzureAPIManagement), + ManagementPortalURI: []*string{ + to.Ptr("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiManagement/service/contoso"), + }, + }, + Onboarding: &armapicenter.Onboarding{ + Instructions: to.Ptr("Sign in or sign up in the specified developer portal to request API access. You must complete the internal privacy training for your account to be approved."), + DeveloperPortalURI: []*string{ + to.Ptr("https://developer.contoso.com"), + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.EnvironmentsClientCreateOrUpdateResponse{ + // Environment: &armapicenter.Environment{ + // Type: to.Ptr("Microsoft.ApiCenter/services/workspaces/environments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/environments/public"), + // Name: to.Ptr("public"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.EnvironmentProperties{ + // Title: to.Ptr("Contoso Europe Azure API Management"), + // Description: to.Ptr("The primary Azure API Management service for the European division of Contoso."), + // Kind: to.Ptr(armapicenter.EnvironmentKindProduction), + // Server: &armapicenter.EnvironmentServer{ + // Type: to.Ptr(armapicenter.EnvironmentServerTypeAzureAPIManagement), + // ManagementPortalURI: []*string{ + // to.Ptr("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiManagement/service/contoso"), + // }, + // }, + // Onboarding: &armapicenter.Onboarding{ + // Instructions: to.Ptr("Sign in or sign up in the specified developer portal to request API access. You must complete the internal privacy training for your account to be approved."), + // DeveloperPortalURI: []*string{ + // to.Ptr("https://developer.contoso.com"), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Environments_Delete.json +func ExampleEnvironmentsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().Delete(ctx, "contoso-resources", "contoso", "default", "public", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.EnvironmentsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Environments_Get.json +func ExampleEnvironmentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().Get(ctx, "contoso-resources", "contoso", "default", "public", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.EnvironmentsClientGetResponse{ + // Environment: &armapicenter.Environment{ + // Type: to.Ptr("Microsoft.ApiCenter/services/environments"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/environments/public"), + // Name: to.Ptr("public"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.EnvironmentProperties{ + // Title: to.Ptr("Public"), + // Kind: to.Ptr(armapicenter.EnvironmentKindProduction), + // Server: &armapicenter.EnvironmentServer{ + // Type: to.Ptr(armapicenter.EnvironmentServerTypeAzureAPIManagement), + // ManagementPortalURI: []*string{ + // }, + // }, + // Onboarding: &armapicenter.Onboarding{ + // DeveloperPortalURI: []*string{ + // }, + // }, + // CustomProperties: &armapicenter.CustomProperties{ + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Environments_Head.json +func ExampleEnvironmentsClient_Head() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().Head(ctx, "contoso-resources", "contoso", "default", "public", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.EnvironmentsClientHeadResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Environments_List.json +func ExampleEnvironmentsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEnvironmentsClient().NewListPager("contoso-resources", "contoso", "default", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.EnvironmentsClientListResponse{ + // EnvironmentListResult: armapicenter.EnvironmentListResult{ + // Value: []*armapicenter.Environment{ + // { + // Type: to.Ptr("Microsoft.ApiCenter/services/environments"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default/environments/public"), + // Name: to.Ptr("public"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.EnvironmentProperties{ + // Title: to.Ptr("Contoso Europe Azure API Management"), + // Description: to.Ptr("The primary Azure API Management service for the European division of Contoso."), + // Kind: to.Ptr(armapicenter.EnvironmentKindProduction), + // Server: &armapicenter.EnvironmentServer{ + // Type: to.Ptr(armapicenter.EnvironmentServerTypeAzureAPIManagement), + // ManagementPortalURI: []*string{ + // }, + // }, + // Onboarding: &armapicenter.Onboarding{ + // DeveloperPortalURI: []*string{ + // }, + // }, + // CustomProperties: &armapicenter.CustomProperties{ + // }, + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armapicenter/zz_metadataschemas_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_metadataschemas_client_example_test.go new file mode 100644 index 000000000..2092b8343 --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_metadataschemas_client_example_test.go @@ -0,0 +1,196 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/MetadataSchemas_CreateOrUpdate.json +func ExampleMetadataSchemasClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMetadataSchemasClient().CreateOrUpdate(ctx, "contoso-resources", "contoso", "author", armapicenter.MetadataSchema{ + Properties: &armapicenter.MetadataSchemaProperties{ + AssignedTo: []*armapicenter.MetadataAssignment{ + { + Entity: to.Ptr(armapicenter.MetadataAssignmentEntityAPI), + Deprecated: to.Ptr(true), + }, + }, + Schema: to.Ptr("{\"type\":\"string\", \"title\":\"Author\", pattern: \"^[a-zA-Z]+$\"}"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.MetadataSchemasClientCreateOrUpdateResponse{ + // MetadataSchema: &armapicenter.MetadataSchema{ + // Type: to.Ptr("Microsoft.ApiCenter/services/metadataSchemas"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/metadataSchemas/author"), + // Name: to.Ptr("author"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.MetadataSchemaProperties{ + // AssignedTo: []*armapicenter.MetadataAssignment{ + // { + // Entity: to.Ptr(armapicenter.MetadataAssignmentEntityAPI), + // Deprecated: to.Ptr(true), + // }, + // }, + // Schema: to.Ptr("{\"type\":\"string\", \"title\":\"Author\", pattern: \"^[a-zA-Z]+$\"}"), + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/MetadataSchemas_Delete.json +func ExampleMetadataSchemasClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMetadataSchemasClient().Delete(ctx, "contoso-resources", "contoso", "author", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.MetadataSchemasClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/MetadataSchemas_Get.json +func ExampleMetadataSchemasClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMetadataSchemasClient().Get(ctx, "contoso-resources", "contoso", "lastName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.MetadataSchemasClientGetResponse{ + // MetadataSchema: &armapicenter.MetadataSchema{ + // Type: to.Ptr("Microsoft.ApiCenter/services/metadataSchemas"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/metadataSchemas/author"), + // Name: to.Ptr("author"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.MetadataSchemaProperties{ + // AssignedTo: []*armapicenter.MetadataAssignment{ + // { + // Entity: to.Ptr(armapicenter.MetadataAssignmentEntityAPI), + // Deprecated: to.Ptr(true), + // }, + // }, + // Schema: to.Ptr("{\"type\":\"string\", \"title\":\"Author\", pattern: \"^[a-zA-Z]+$\"}"), + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/MetadataSchemas_Head.json +func ExampleMetadataSchemasClient_Head() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMetadataSchemasClient().Head(ctx, "contoso-resources", "contoso", "author", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.MetadataSchemasClientHeadResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/MetadataSchemas_List.json +func ExampleMetadataSchemasClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMetadataSchemasClient().NewListPager("contoso-resources", "contoso", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.MetadataSchemasClientListResponse{ + // MetadataSchemaListResult: armapicenter.MetadataSchemaListResult{ + // Value: []*armapicenter.MetadataSchema{ + // { + // Type: to.Ptr("Microsoft.ApiCenter/services/metadataSchemas"), + // ID: to.Ptr("/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/metadataSchemas/author"), + // Name: to.Ptr("author"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.MetadataSchemaProperties{ + // AssignedTo: []*armapicenter.MetadataAssignment{ + // { + // Entity: to.Ptr(armapicenter.MetadataAssignmentEntityAPI), + // Deprecated: to.Ptr(true), + // }, + // }, + // Schema: to.Ptr("{\"type\":\"string\", \"title\":\"Author\", pattern: \"^[a-zA-Z]+$\"}"), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armapicenter/zz_operations_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_operations_client_example_test.go new file mode 100644 index 000000000..49a2105ea --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_operations_client_example_test.go @@ -0,0 +1,53 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.OperationsClientListResponse{ + // OperationListResult: armapicenter.OperationListResult{ + // Value: []*armapicenter.Operation{ + // { + // Name: to.Ptr("Microsoft.ApiCenter/services/read"), + // IsDataAction: to.Ptr(false), + // Display: &armapicenter.OperationDisplay{ + // Provider: to.Ptr("Microsoft.ApiCenter"), + // Resource: to.Ptr("services"), + // Operation: to.Ptr("Lists services"), + // Description: to.Ptr("Lists registered services"), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armapicenter/zz_services_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_services_client_example_test.go new file mode 100644 index 000000000..f2c78e593 --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_services_client_example_test.go @@ -0,0 +1,315 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/Services_CreateOrUpdate.json +func ExampleServicesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().CreateOrUpdate(ctx, "contoso-resources", "contoso", armapicenter.Service{ + Properties: &armapicenter.ServiceProperties{}, + Tags: map[string]*string{}, + Location: to.Ptr("East US"), + Identity: &armapicenter.ManagedServiceIdentity{ + UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{}, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ServicesClientCreateOrUpdateResponse{ + // Service: &armapicenter.Service{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), + // Type: to.Ptr("Microsoft.ApiCenter/services"), + // Name: to.Ptr("contoso"), + // Properties: &armapicenter.ServiceProperties{ + // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("East US"), + // Identity: &armapicenter.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Services_Delete.json +func ExampleServicesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().Delete(ctx, "contoso-resources", "contoso", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ServicesClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Services_ExportMetadataSchema.json +func ExampleServicesClient_BeginExportMetadataSchema() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServicesClient().BeginExportMetadataSchema(ctx, "contoso-resources", "contoso", armapicenter.MetadataSchemaExportRequest{ + AssignedTo: to.Ptr(armapicenter.MetadataAssignmentEntityAPI), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ServicesClientExportMetadataSchemaResponse{ + // MetadataSchemaExportResult: &armapicenter.MetadataSchemaExportResult{ + // Value: to.Ptr("{\"type\":\"object\",\"properties\":{ ... }}"), + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Services_Get.json +func ExampleServicesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().Get(ctx, "contoso-resources", "contoso", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ServicesClientGetResponse{ + // Service: &armapicenter.Service{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), + // Type: to.Ptr("Microsoft.ApiCenter/services"), + // Name: to.Ptr("contoso"), + // Properties: &armapicenter.ServiceProperties{ + // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("East US"), + // Identity: &armapicenter.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Services_ListByResourceGroup.json +func ExampleServicesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServicesClient().NewListByResourceGroupPager("contoso-resources", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.ServicesClientListByResourceGroupResponse{ + // ServiceListResult: armapicenter.ServiceListResult{ + // Value: []*armapicenter.Service{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), + // Type: to.Ptr("Microsoft.ApiCenter/services"), + // Name: to.Ptr("contoso"), + // Properties: &armapicenter.ServiceProperties{ + // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("East US"), + // Identity: &armapicenter.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-03-15-preview/Services_ListBySubscription.json +func ExampleServicesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServicesClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.ServicesClientListBySubscriptionResponse{ + // ServiceListResult: armapicenter.ServiceListResult{ + // Value: []*armapicenter.Service{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), + // Type: to.Ptr("Microsoft.ApiCenter/services"), + // Name: to.Ptr("contoso"), + // Properties: &armapicenter.ServiceProperties{ + // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("East US"), + // Identity: &armapicenter.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-03-15-preview/Services_Update.json +func ExampleServicesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().Update(ctx, "contoso-resources", "contoso", armapicenter.ServiceUpdate{ + Tags: map[string]*string{}, + Identity: &armapicenter.ManagedServiceIdentity{ + UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{}, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.ServicesClientUpdateResponse{ + // Service: &armapicenter.Service{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), + // Type: to.Ptr("Microsoft.ApiCenter/services"), + // Name: to.Ptr("contoso"), + // Properties: &armapicenter.ServiceProperties{ + // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("East US"), + // Identity: &armapicenter.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // }, + // } +} diff --git a/packages/typespec-go/test/armapicenter/zz_workspaces_client_example_test.go b/packages/typespec-go/test/armapicenter/zz_workspaces_client_example_test.go new file mode 100644 index 000000000..c2ad609fd --- /dev/null +++ b/packages/typespec-go/test/armapicenter/zz_workspaces_client_example_test.go @@ -0,0 +1,172 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armapicenter_test + +import ( + "armapicenter" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-03-15-preview/Workspaces_CreateOrUpdate.json +func ExampleWorkspacesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().CreateOrUpdate(ctx, "contoso-resources", "contoso", "default", armapicenter.Workspace{ + Properties: &armapicenter.WorkspaceProperties{ + Title: to.Ptr("default"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.WorkspacesClientCreateOrUpdateResponse{ + // Workspace: &armapicenter.Workspace{ + // Type: to.Ptr("Microsoft.ApiCenter/services/workspaces"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default"), + // Name: to.Ptr("default"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.WorkspaceProperties{ + // Title: to.Ptr("default"), + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Workspaces_Delete.json +func ExampleWorkspacesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Delete(ctx, "contoso-resources", "contoso", "default", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.WorkspacesClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Workspaces_Get.json +func ExampleWorkspacesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Get(ctx, "contoso-resources", "contoso", "default", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.WorkspacesClientGetResponse{ + // Workspace: &armapicenter.Workspace{ + // Type: to.Ptr("Microsoft.ApiCenter/services/workspaces"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default"), + // Name: to.Ptr("default"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.WorkspaceProperties{ + // Title: to.Ptr("default"), + // }, + // }, + // } +} + +// Generated from example definition: 2024-03-15-preview/Workspaces_Head.json +func ExampleWorkspacesClient_Head() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().Head(ctx, "contoso-resources", "contoso", "default", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armapicenter.WorkspacesClientHeadResponse{ + // } +} + +// Generated from example definition: 2024-03-15-preview/Workspaces_List.json +func ExampleWorkspacesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armapicenter.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkspacesClient().NewListPager("contoso-resources", "contoso", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armapicenter.WorkspacesClientListResponse{ + // WorkspaceListResult: armapicenter.WorkspaceListResult{ + // Value: []*armapicenter.Workspace{ + // { + // Type: to.Ptr("Microsoft.ApiCenter/services/workspaces"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso/workspaces/default"), + // Name: to.Ptr("default"), + // SystemData: &armapicenter.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.128871Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-03T18:27:09.1288716Z"); return t}()), + // }, + // Properties: &armapicenter.WorkspaceProperties{ + // Title: to.Ptr("default"), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armcodesigning/go.mod b/packages/typespec-go/test/armcodesigning/go.mod index 139d98b8a..434e9b5a9 100644 --- a/packages/typespec-go/test/armcodesigning/go.mod +++ b/packages/typespec-go/test/armcodesigning/go.mod @@ -2,10 +2,20 @@ module armcodesigning go 1.18 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/packages/typespec-go/test/armcodesigning/go.sum b/packages/typespec-go/test/armcodesigning/go.sum index fb5e8f74b..0f58a50c0 100644 --- a/packages/typespec-go/test/armcodesigning/go.sum +++ b/packages/typespec-go/test/armcodesigning/go.sum @@ -1,12 +1,29 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/packages/typespec-go/test/armcodesigning/zz_accounts_client_example_test.go b/packages/typespec-go/test/armcodesigning/zz_accounts_client_example_test.go new file mode 100644 index 000000000..f739adba3 --- /dev/null +++ b/packages/typespec-go/test/armcodesigning/zz_accounts_client_example_test.go @@ -0,0 +1,280 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcodesigning_test + +import ( + "armcodesigning" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-09-30-preview/CodeSigningAccounts_CheckNameAvailability.json +func ExampleAccountsClient_CheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().CheckNameAvailability(ctx, armcodesigning.CheckNameAvailability{ + Name: to.Ptr("sample-account"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcodesigning.AccountsClientCheckNameAvailabilityResponse{ + // CheckNameAvailabilityResult: &armcodesigning.CheckNameAvailabilityResult{ + // NameAvailable: to.Ptr(true), + // }, + // } +} + +// Generated from example definition: 2024-09-30-preview/CodeSigningAccounts_Create.json +func ExampleAccountsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAccountsClient().BeginCreate(ctx, "MyResourceGroup", "MyAccount", armcodesigning.Account{ + Location: to.Ptr("westus"), + Properties: &armcodesigning.AccountProperties{ + SKU: &armcodesigning.AccountSKU{ + Name: to.Ptr(armcodesigning.SKUNameBasic), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcodesigning.AccountsClientCreateResponse{ + // Account: &armcodesigning.Account{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.CodeSigning/codeSigningAccounts/MyAccount"), + // Location: to.Ptr("westus"), + // Properties: &armcodesigning.AccountProperties{ + // ProvisioningState: to.Ptr(armcodesigning.ProvisioningStateSucceeded), + // SKU: &armcodesigning.AccountSKU{ + // Name: to.Ptr(armcodesigning.SKUNameBasic), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-09-30-preview/CodeSigningAccounts_Delete.json +func ExampleAccountsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAccountsClient().BeginDelete(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-09-30-preview/CodeSigningAccounts_Get.json +func ExampleAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "MyResourceGroup", "MyAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcodesigning.AccountsClientGetResponse{ + // Account: &armcodesigning.Account{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.CodeSigning/codeSigningAccounts/MyAccount"), + // Location: to.Ptr("westus"), + // Properties: &armcodesigning.AccountProperties{ + // ProvisioningState: to.Ptr(armcodesigning.ProvisioningStateSucceeded), + // SKU: &armcodesigning.AccountSKU{ + // Name: to.Ptr(armcodesigning.SKUNameBasic), + // }, + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} + +// Generated from example definition: 2024-09-30-preview/CodeSigningAccounts_ListByResourceGroup.json +func ExampleAccountsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListByResourceGroupPager("MyResourceGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcodesigning.AccountsClientListByResourceGroupResponse{ + // AccountListResult: armcodesigning.AccountListResult{ + // Value: []*armcodesigning.Account{ + // { + // Name: to.Ptr("alpha"), + // Type: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.CodeSigning/codeSigningAccounts/MyAccount"), + // Location: to.Ptr("westcentralus"), + // Properties: &armcodesigning.AccountProperties{ + // ProvisioningState: to.Ptr(armcodesigning.ProvisioningStateSucceeded), + // SKU: &armcodesigning.AccountSKU{ + // Name: to.Ptr(armcodesigning.SKUNameBasic), + // }, + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-09-30-preview/CodeSigningAccounts_ListBySubscription.json +func ExampleAccountsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcodesigning.AccountsClientListBySubscriptionResponse{ + // AccountListResult: armcodesigning.AccountListResult{ + // Value: []*armcodesigning.Account{ + // { + // Name: to.Ptr("alpha"), + // Type: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.CodeSigning/codeSigningAccounts/MyAccount"), + // Location: to.Ptr("westus"), + // Properties: &armcodesigning.AccountProperties{ + // ProvisioningState: to.Ptr(armcodesigning.ProvisioningStateSucceeded), + // SKU: &armcodesigning.AccountSKU{ + // Name: to.Ptr(armcodesigning.SKUNameBasic), + // }, + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-09-30-preview/CodeSigningAccounts_Update.json +func ExampleAccountsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAccountsClient().BeginUpdate(ctx, "MyResourceGroup", "MyAccount", armcodesigning.AccountPatch{ + Tags: map[string]*string{ + "key1": to.Ptr("value1"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcodesigning.AccountsClientUpdateResponse{ + // Account: &armcodesigning.Account{ + // Name: to.Ptr("MyAccount"), + // Type: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.CodeSigning/codeSigningAccounts/MyAccount"), + // Location: to.Ptr("westus"), + // Properties: &armcodesigning.AccountProperties{ + // ProvisioningState: to.Ptr(armcodesigning.ProvisioningStateSucceeded), + // SKU: &armcodesigning.AccountSKU{ + // Name: to.Ptr(armcodesigning.SKUNameBasic), + // }, + // }, + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // } +} diff --git a/packages/typespec-go/test/armcodesigning/zz_certificateprofiles_client_example_test.go b/packages/typespec-go/test/armcodesigning/zz_certificateprofiles_client_example_test.go new file mode 100644 index 000000000..11e0028b9 --- /dev/null +++ b/packages/typespec-go/test/armcodesigning/zz_certificateprofiles_client_example_test.go @@ -0,0 +1,225 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcodesigning_test + +import ( + "armcodesigning" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" + "time" +) + +// Generated from example definition: 2024-09-30-preview/CertificateProfiles_Create.json +func ExampleCertificateProfilesClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCertificateProfilesClient().BeginCreate(ctx, "MyResourceGroup", "MyAccount", "profileA", armcodesigning.CertificateProfile{ + Properties: &armcodesigning.CertificateProfileProperties{ + ProfileType: to.Ptr(armcodesigning.ProfileTypePublicTrust), + IdentityValidationID: to.Ptr("00000000-1234-5678-3333-444444444444"), + IncludePostalCode: to.Ptr(true), + IncludeStreetAddress: to.Ptr(false), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcodesigning.CertificateProfilesClientCreateResponse{ + // CertificateProfile: &armcodesigning.CertificateProfile{ + // Name: to.Ptr("profileA"), + // Type: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts/certificateProfiles"), + // ID: to.Ptr("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.CodeSigning/codeSigningAccounts/MyAccount/certificateProfiles/profileA"), + // Properties: &armcodesigning.CertificateProfileProperties{ + // Certificates: []*armcodesigning.Certificate{ + // { + // CreatedDate: to.Ptr("3/14/2023 5:27:49 PM"), + // ExpiryDate: to.Ptr("3/17/2023 5:27:49 PM"), + // EnhancedKeyUsage: to.Ptr("1.3.6.1.4.1.311.yy.xxxxxxxx.xxxxxxxx.xxxxxxxxx.xxxxxxxx"), + // SerialNumber: to.Ptr("xxxxxxxxxxxxxxxxxx"), + // Status: to.Ptr(armcodesigning.CertificateStatusActive), + // SubjectName: to.Ptr("CN=Contoso Inc, O=Contoso Inc, L=New York, S=New York, C=US"), + // Thumbprint: to.Ptr("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + // }, + // }, + // IdentityValidationID: to.Ptr("00000000-1234-5678-3333-444444444444"), + // IncludeCity: to.Ptr(false), + // IncludeCountry: to.Ptr(false), + // IncludePostalCode: to.Ptr(true), + // IncludeState: to.Ptr(false), + // IncludeStreetAddress: to.Ptr(false), + // ProfileType: to.Ptr(armcodesigning.ProfileTypePublicTrust), + // ProvisioningState: to.Ptr(armcodesigning.ProvisioningStateSucceeded), + // Status: to.Ptr(armcodesigning.CertificateProfileStatusActive), + // }, + // }, + // } +} + +// Generated from example definition: 2024-09-30-preview/CertificateProfiles_Delete.json +func ExampleCertificateProfilesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCertificateProfilesClient().BeginDelete(ctx, "MyResourceGroup", "MyAccount", "profileA", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-09-30-preview/CertificateProfiles_Get.json +func ExampleCertificateProfilesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCertificateProfilesClient().Get(ctx, "MyResourceGroup", "MyAccount", "profileA", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcodesigning.CertificateProfilesClientGetResponse{ + // CertificateProfile: &armcodesigning.CertificateProfile{ + // Name: to.Ptr("profileA"), + // Type: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts/certificateProfiles"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.CodeSigning/codeSigningAccounts/MyAccount/certificateProfiles/profileA"), + // Properties: &armcodesigning.CertificateProfileProperties{ + // Certificates: []*armcodesigning.Certificate{ + // { + // CreatedDate: to.Ptr("3/14/2023 5:27:49 PM"), + // ExpiryDate: to.Ptr("3/17/2023 5:27:49 PM"), + // EnhancedKeyUsage: to.Ptr("1.3.6.1.4.1.311.yy.xxxxxxxx.xxxxxxxx.xxxxxxxxx.xxxxxxxx"), + // SerialNumber: to.Ptr("xxxxxxxxxxxxxxxxxx"), + // Status: to.Ptr(armcodesigning.CertificateStatusActive), + // SubjectName: to.Ptr("CN=Contoso Inc, O=Contoso Inc, L=New York, S=New York, C=US"), + // Thumbprint: to.Ptr("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + // }, + // }, + // IdentityValidationID: to.Ptr("123456"), + // IncludeCity: to.Ptr(false), + // IncludeCountry: to.Ptr(false), + // IncludePostalCode: to.Ptr(true), + // IncludeState: to.Ptr(false), + // IncludeStreetAddress: to.Ptr(false), + // ProfileType: to.Ptr(armcodesigning.ProfileTypePublicTrust), + // ProvisioningState: to.Ptr(armcodesigning.ProvisioningStateSucceeded), + // Status: to.Ptr(armcodesigning.CertificateProfileStatusActive), + // }, + // }, + // } +} + +// Generated from example definition: 2024-09-30-preview/CertificateProfiles_ListByCodeSigningAccount.json +func ExampleCertificateProfilesClient_NewListByCodeSigningAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCertificateProfilesClient().NewListByCodeSigningAccountPager("MyResourceGroup", "MyAccount", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcodesigning.CertificateProfilesClientListByCodeSigningAccountResponse{ + // CertificateProfileListResult: armcodesigning.CertificateProfileListResult{ + // Value: []*armcodesigning.CertificateProfile{ + // { + // Name: to.Ptr("profileA"), + // Type: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts/certificateProfiles"), + // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.CodeSigning/codeSigningAccounts/profileA"), + // Properties: &armcodesigning.CertificateProfileProperties{ + // Certificates: []*armcodesigning.Certificate{ + // { + // CreatedDate: to.Ptr("3/14/2023 5:27:49 PM"), + // ExpiryDate: to.Ptr("3/17/2023 5:27:49 PM"), + // EnhancedKeyUsage: to.Ptr("1.3.6.1.4.1.311.yy.xxxxxxxx.xxxxxxxx.xxxxxxxxx.xxxxxxxx"), + // SerialNumber: to.Ptr("xxxxxxxxxxxxxxxxxx"), + // Status: to.Ptr(armcodesigning.CertificateStatusActive), + // SubjectName: to.Ptr("CN=Contoso Inc, O=Contoso Inc, L=New York, S=New York, C=US"), + // Thumbprint: to.Ptr("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + // }, + // }, + // IdentityValidationID: to.Ptr("123456"), + // IncludeCity: to.Ptr(false), + // IncludeCountry: to.Ptr(false), + // IncludePostalCode: to.Ptr(true), + // IncludeState: to.Ptr(false), + // IncludeStreetAddress: to.Ptr(false), + // ProfileType: to.Ptr(armcodesigning.ProfileTypePublicTrust), + // ProvisioningState: to.Ptr(armcodesigning.ProvisioningStateSucceeded), + // Status: to.Ptr(armcodesigning.CertificateProfileStatusActive), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-09-30-preview/CertificateProfiles_RevokeCertificate.json +func ExampleCertificateProfilesClient_RevokeCertificate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewCertificateProfilesClient().RevokeCertificate(ctx, "MyResourceGroup", "MyAccount", "profileA", armcodesigning.RevokeCertificate{ + EffectiveAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-11-12T23:40:25+00:00"); return t }()), + Reason: to.Ptr("KeyCompromised"), + Remarks: to.Ptr("test"), + SerialNumber: to.Ptr("xxxxxxxxxxxxxxxxxx"), + Thumbprint: to.Ptr("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/packages/typespec-go/test/armcodesigning/zz_operations_client_example_test.go b/packages/typespec-go/test/armcodesigning/zz_operations_client_example_test.go new file mode 100644 index 000000000..51c295d8f --- /dev/null +++ b/packages/typespec-go/test/armcodesigning/zz_operations_client_example_test.go @@ -0,0 +1,70 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcodesigning_test + +import ( + "armcodesigning" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-09-30-preview/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcodesigning.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcodesigning.OperationsClientListResponse{ + // OperationListResult: armcodesigning.OperationListResult{ + // Value: []*armcodesigning.Operation{ + // { + // Name: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts/write"), + // Display: &armcodesigning.OperationDisplay{ + // Provider: to.Ptr("Microsoft.CodeSigning"), + // Resource: to.Ptr("codeSigningAccounts"), + // Operation: to.Ptr("Create CodeSigningAccount"), + // Description: to.Ptr("Create any CodeSigningAccount"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts/read"), + // Display: &armcodesigning.OperationDisplay{ + // Provider: to.Ptr("Microsoft.CodeSigning"), + // Resource: to.Ptr("codeSigningAccounts"), + // Operation: to.Ptr("Get CodeSigningAccount"), + // Description: to.Ptr("Get any CodeSigningAccount"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.CodeSigning/codeSigningAccounts/delete"), + // Display: &armcodesigning.OperationDisplay{ + // Provider: to.Ptr("Microsoft.CodeSigning"), + // Resource: to.Ptr("codeSigningAccounts"), + // Operation: to.Ptr("Delete CodeSigningAccount"), + // Description: to.Ptr("Delete any CodeSigningAccount"), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armcommunitymanagement/go.mod b/packages/typespec-go/test/armcommunitymanagement/go.mod index 42f61b7d0..79d11ebd0 100644 --- a/packages/typespec-go/test/armcommunitymanagement/go.mod +++ b/packages/typespec-go/test/armcommunitymanagement/go.mod @@ -2,10 +2,20 @@ module armcommunitymanagement go 1.18 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/packages/typespec-go/test/armcommunitymanagement/go.sum b/packages/typespec-go/test/armcommunitymanagement/go.sum index fb5e8f74b..0f58a50c0 100644 --- a/packages/typespec-go/test/armcommunitymanagement/go.sum +++ b/packages/typespec-go/test/armcommunitymanagement/go.sum @@ -1,12 +1,29 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/packages/typespec-go/test/armcommunitymanagement/zz_communitytrainings_client_example_test.go b/packages/typespec-go/test/armcommunitymanagement/zz_communitytrainings_client_example_test.go new file mode 100644 index 000000000..5cb0b5542 --- /dev/null +++ b/packages/typespec-go/test/armcommunitymanagement/zz_communitytrainings_client_example_test.go @@ -0,0 +1,414 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcommunitymanagement_test + +import ( + "armcommunitymanagement" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2023-11-01/CommunityTrainings_Create.json +func ExampleCommunityTrainingsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcommunitymanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityTrainingsClient().BeginCreate(ctx, "rgCommunityTaining", "ctApplication", armcommunitymanagement.CommunityTraining{ + Properties: &armcommunitymanagement.CommunityTrainingProperties{ + PortalName: to.Ptr("ctwebsite"), + PortalAdminEmailAddress: to.Ptr("ctadmin@ct.com"), + PortalOwnerOrganizationName: to.Ptr("CT Portal Owner Organization"), + PortalOwnerEmailAddress: to.Ptr("ctcontact@ct.com"), + IdentityConfiguration: &armcommunitymanagement.IdentityConfigurationProperties{ + IdentityType: to.Ptr("ADB2C"), + TeamsEnabled: to.Ptr(false), + TenantID: to.Ptr("c1ffbb60-88cf-4b83-b54f-c47ae6220c19"), + DomainName: to.Ptr("cttenant"), + ClientID: to.Ptr("8c92390f-2f30-493d-bd13-d3c3eba3709d"), + ClientSecret: to.Ptr("idenityConfigurationClientSecret"), + B2CAuthenticationPolicy: to.Ptr("B2C_1_signup_signin"), + B2CPasswordResetPolicy: to.Ptr("B2C_1_pwd_reset"), + CustomLoginParameters: to.Ptr("custom_hint"), + }, + ZoneRedundancyEnabled: to.Ptr(true), + DisasterRecoveryEnabled: to.Ptr(true), + }, + SKU: &armcommunitymanagement.SKU{ + Name: to.Ptr("Commercial"), + Tier: to.Ptr(armcommunitymanagement.SKUTierStandard), + }, + Location: to.Ptr("southeastasia"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcommunitymanagement.CommunityTrainingsClientCreateResponse{ + // CommunityTraining: &armcommunitymanagement.CommunityTraining{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgCommunityTraining/providers/Microsoft.Community/communityTrainings/ctApplication"), + // Name: to.Ptr("ctApplication"), + // Type: to.Ptr("Microsoft.Community/communityTrainings"), + // Properties: &armcommunitymanagement.CommunityTrainingProperties{ + // PortalName: to.Ptr("ctwebsite"), + // PortalAdminEmailAddress: to.Ptr("ctadmin@ct.com"), + // PortalOwnerOrganizationName: to.Ptr("CT Portal Owner Organization"), + // PortalOwnerEmailAddress: to.Ptr("ctcontact@ct.com"), + // IdentityConfiguration: &armcommunitymanagement.IdentityConfigurationProperties{ + // IdentityType: to.Ptr("ADB2C"), + // TeamsEnabled: to.Ptr(false), + // TenantID: to.Ptr("c1ffbb60-88cf-4b83-b54f-c47ae6220c19"), + // DomainName: to.Ptr("cttenant"), + // ClientID: to.Ptr("8c92390f-2f30-493d-bd13-d3c3eba3709d"), + // B2CAuthenticationPolicy: to.Ptr("B2C_1_signup_signin"), + // B2CPasswordResetPolicy: to.Ptr("B2C_1_pwd_reset"), + // CustomLoginParameters: to.Ptr("custom_hint"), + // }, + // ZoneRedundancyEnabled: to.Ptr(true), + // DisasterRecoveryEnabled: to.Ptr(true), + // ProvisioningState: to.Ptr(armcommunitymanagement.ProvisioningStateSucceeded), + // }, + // SKU: &armcommunitymanagement.SKU{ + // Name: to.Ptr("Commercial"), + // Tier: to.Ptr(armcommunitymanagement.SKUTierStandard), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("southeastasia"), + // SystemData: &armcommunitymanagement.SystemData{ + // CreatedBy: to.Ptr("ctowner@ct.com"), + // CreatedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // LastModifiedBy: to.Ptr("ctowner@ct.com"), + // LastModifiedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2023-11-01/CommunityTrainings_Delete.json +func ExampleCommunityTrainingsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcommunitymanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityTrainingsClient().BeginDelete(ctx, "rgCommunityTraining", "ctApplication", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcommunitymanagement.CommunityTrainingsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2023-11-01/CommunityTrainings_Get.json +func ExampleCommunityTrainingsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcommunitymanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCommunityTrainingsClient().Get(ctx, "rgCommunityTraining", "ctApplication", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcommunitymanagement.CommunityTrainingsClientGetResponse{ + // CommunityTraining: &armcommunitymanagement.CommunityTraining{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgCommunityTraining/providers/Microsoft.Community/communityTrainings/ctApplication"), + // Name: to.Ptr("ctApplication"), + // Type: to.Ptr("Microsoft.Community/communityTrainings"), + // Properties: &armcommunitymanagement.CommunityTrainingProperties{ + // PortalName: to.Ptr("ctwebsite"), + // PortalAdminEmailAddress: to.Ptr("ctadmin@ct.com"), + // PortalOwnerOrganizationName: to.Ptr("CT Portal Owner Organization"), + // PortalOwnerEmailAddress: to.Ptr("ctcontact@ct.com"), + // IdentityConfiguration: &armcommunitymanagement.IdentityConfigurationProperties{ + // IdentityType: to.Ptr("ADB2C"), + // TeamsEnabled: to.Ptr(false), + // TenantID: to.Ptr("c1ffbb60-88cf-4b83-b54f-c47ae6220c19"), + // DomainName: to.Ptr("cttenant"), + // ClientID: to.Ptr("8c92390f-2f30-493d-bd13-d3c3eba3709d"), + // B2CAuthenticationPolicy: to.Ptr("B2C_1_signup_signin"), + // B2CPasswordResetPolicy: to.Ptr("B2C_1_pwd_reset"), + // CustomLoginParameters: to.Ptr("custom_hint"), + // }, + // ZoneRedundancyEnabled: to.Ptr(true), + // DisasterRecoveryEnabled: to.Ptr(true), + // ProvisioningState: to.Ptr(armcommunitymanagement.ProvisioningStateSucceeded), + // }, + // SKU: &armcommunitymanagement.SKU{ + // Name: to.Ptr("Commercial"), + // Tier: to.Ptr(armcommunitymanagement.SKUTierStandard), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("southeastasia"), + // SystemData: &armcommunitymanagement.SystemData{ + // CreatedBy: to.Ptr("ctowner@ct.com"), + // CreatedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // LastModifiedBy: to.Ptr("ctowner@ct.com"), + // LastModifiedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2023-11-01/CommunityTrainings_ListByResourceGroup.json +func ExampleCommunityTrainingsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcommunitymanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunityTrainingsClient().NewListByResourceGroupPager("rgCommunityTraining", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcommunitymanagement.CommunityTrainingsClientListByResourceGroupResponse{ + // CommunityTrainingListResult: armcommunitymanagement.CommunityTrainingListResult{ + // Value: []*armcommunitymanagement.CommunityTraining{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgCommunityTraining/providers/Microsoft.Community/communityTrainings/ctApplication"), + // Name: to.Ptr("ctApplication"), + // Type: to.Ptr("Microsoft.Community/communityTrainings"), + // Properties: &armcommunitymanagement.CommunityTrainingProperties{ + // PortalName: to.Ptr("ctwebsite"), + // PortalAdminEmailAddress: to.Ptr("ctadmin@ct.com"), + // PortalOwnerOrganizationName: to.Ptr("CT Portal Owner Organization"), + // PortalOwnerEmailAddress: to.Ptr("ctcontact@ct.com"), + // IdentityConfiguration: &armcommunitymanagement.IdentityConfigurationProperties{ + // IdentityType: to.Ptr("ADB2C"), + // TeamsEnabled: to.Ptr(false), + // TenantID: to.Ptr("c1ffbb60-88cf-4b83-b54f-c47ae6220c19"), + // DomainName: to.Ptr("cttenant"), + // ClientID: to.Ptr("8c92390f-2f30-493d-bd13-d3c3eba3709d"), + // B2CAuthenticationPolicy: to.Ptr("B2C_1_signup_signin"), + // B2CPasswordResetPolicy: to.Ptr("B2C_1_pwd_reset"), + // CustomLoginParameters: to.Ptr("custom_hint"), + // }, + // ZoneRedundancyEnabled: to.Ptr(true), + // DisasterRecoveryEnabled: to.Ptr(true), + // ProvisioningState: to.Ptr(armcommunitymanagement.ProvisioningStateSucceeded), + // }, + // SKU: &armcommunitymanagement.SKU{ + // Name: to.Ptr("Commercial"), + // Tier: to.Ptr(armcommunitymanagement.SKUTierStandard), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("southeastasia"), + // SystemData: &armcommunitymanagement.SystemData{ + // CreatedBy: to.Ptr("ctowner@ct.com"), + // CreatedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // LastModifiedBy: to.Ptr("ctowner@ct.com"), + // LastModifiedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2023-11-01/CommunityTrainings_ListBySubscription.json +func ExampleCommunityTrainingsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcommunitymanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunityTrainingsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcommunitymanagement.CommunityTrainingsClientListBySubscriptionResponse{ + // CommunityTrainingListResult: armcommunitymanagement.CommunityTrainingListResult{ + // Value: []*armcommunitymanagement.CommunityTraining{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgCommunityTraining/providers/Microsoft.Community/communityTrainings/ctApplication"), + // Name: to.Ptr("ctApplication"), + // Type: to.Ptr("Microsoft.Community/communityTrainings"), + // Properties: &armcommunitymanagement.CommunityTrainingProperties{ + // PortalName: to.Ptr("ctwebsite"), + // PortalAdminEmailAddress: to.Ptr("ctadmin@ct.com"), + // PortalOwnerOrganizationName: to.Ptr("CT Portal Owner Organization"), + // PortalOwnerEmailAddress: to.Ptr("ctcontact@ct.com"), + // IdentityConfiguration: &armcommunitymanagement.IdentityConfigurationProperties{ + // IdentityType: to.Ptr("ADB2C"), + // TeamsEnabled: to.Ptr(false), + // TenantID: to.Ptr("c1ffbb60-88cf-4b83-b54f-c47ae6220c19"), + // DomainName: to.Ptr("cttenant"), + // ClientID: to.Ptr("8c92390f-2f30-493d-bd13-d3c3eba3709d"), + // B2CAuthenticationPolicy: to.Ptr("B2C_1_signup_signin"), + // B2CPasswordResetPolicy: to.Ptr("B2C_1_pwd_reset"), + // CustomLoginParameters: to.Ptr("custom_hint"), + // }, + // ZoneRedundancyEnabled: to.Ptr(true), + // DisasterRecoveryEnabled: to.Ptr(true), + // ProvisioningState: to.Ptr(armcommunitymanagement.ProvisioningStateSucceeded), + // }, + // SKU: &armcommunitymanagement.SKU{ + // Name: to.Ptr("Commercial"), + // Tier: to.Ptr(armcommunitymanagement.SKUTierStandard), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("southeastasia"), + // SystemData: &armcommunitymanagement.SystemData{ + // CreatedBy: to.Ptr("ctowner@ct.com"), + // CreatedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // LastModifiedBy: to.Ptr("ctowner@ct.com"), + // LastModifiedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2023-11-01/CommunityTrainings_Update.json +func ExampleCommunityTrainingsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcommunitymanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityTrainingsClient().BeginUpdate(ctx, "rgCommunityTraining", "ctApplication", armcommunitymanagement.CommunityTrainingUpdate{ + SKU: &armcommunitymanagement.SKU{ + Name: to.Ptr("Commercial"), + Tier: to.Ptr(armcommunitymanagement.SKUTierStandard), + }, + Tags: map[string]*string{}, + Properties: &armcommunitymanagement.CommunityTrainingUpdateProperties{ + IdentityConfiguration: &armcommunitymanagement.IdentityConfigurationProperties{ + IdentityType: to.Ptr("ADB2C"), + TeamsEnabled: to.Ptr(false), + TenantID: to.Ptr("c1ffbb60-88cf-4b83-b54f-c47ae6220c19"), + DomainName: to.Ptr("cttenant"), + ClientID: to.Ptr("8c92390f-2f30-493d-bd13-d3c3eba3709d"), + ClientSecret: to.Ptr("idenityConfigurationClientSecret"), + B2CAuthenticationPolicy: to.Ptr("B2C_1_signup_signin"), + B2CPasswordResetPolicy: to.Ptr("B2C_1_pwd_reset"), + CustomLoginParameters: to.Ptr("custom_hint"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcommunitymanagement.CommunityTrainingsClientUpdateResponse{ + // CommunityTraining: &armcommunitymanagement.CommunityTraining{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgCommunityTraining/providers/Microsoft.Community/communityTrainings/ctApplication"), + // Name: to.Ptr("ctApplication"), + // Type: to.Ptr("Microsoft.Community/communityTrainings"), + // Properties: &armcommunitymanagement.CommunityTrainingProperties{ + // PortalName: to.Ptr("ctwebsite"), + // PortalAdminEmailAddress: to.Ptr("ctadmin@ct.com"), + // PortalOwnerOrganizationName: to.Ptr("CT Portal Owner Organization"), + // PortalOwnerEmailAddress: to.Ptr("ctcontact@ct.com"), + // IdentityConfiguration: &armcommunitymanagement.IdentityConfigurationProperties{ + // IdentityType: to.Ptr("ADB2C"), + // TeamsEnabled: to.Ptr(false), + // TenantID: to.Ptr("c1ffbb60-88cf-4b83-b54f-c47ae6220c19"), + // DomainName: to.Ptr("cttenant"), + // ClientID: to.Ptr("8c92390f-2f30-493d-bd13-d3c3eba3709d"), + // B2CAuthenticationPolicy: to.Ptr("B2C_1_signup_signin"), + // B2CPasswordResetPolicy: to.Ptr("B2C_1_pwd_reset"), + // CustomLoginParameters: to.Ptr("custom_hint"), + // }, + // ZoneRedundancyEnabled: to.Ptr(true), + // DisasterRecoveryEnabled: to.Ptr(true), + // ProvisioningState: to.Ptr(armcommunitymanagement.ProvisioningStateSucceeded), + // }, + // SKU: &armcommunitymanagement.SKU{ + // Name: to.Ptr("Commercial"), + // Tier: to.Ptr(armcommunitymanagement.SKUTierStandard), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("southeastasia"), + // SystemData: &armcommunitymanagement.SystemData{ + // CreatedBy: to.Ptr("ctowner@ct.com"), + // CreatedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // LastModifiedBy: to.Ptr("ctowner@ct.com"), + // LastModifiedByType: to.Ptr(armcommunitymanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-01T11:42:44.657Z"); return t}()), + // }, + // }, + // } +} diff --git a/packages/typespec-go/test/armcommunitymanagement/zz_operations_client_example_test.go b/packages/typespec-go/test/armcommunitymanagement/zz_operations_client_example_test.go new file mode 100644 index 000000000..eb7efdaa0 --- /dev/null +++ b/packages/typespec-go/test/armcommunitymanagement/zz_operations_client_example_test.go @@ -0,0 +1,103 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcommunitymanagement_test + +import ( + "armcommunitymanagement" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2023-11-01/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcommunitymanagement.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcommunitymanagement.OperationsClientListResponse{ + // OperationListResult: armcommunitymanagement.OperationListResult{ + // Value: []*armcommunitymanagement.Operation{ + // { + // Display: &armcommunitymanagement.OperationDisplay{ + // Description: to.Ptr("List CommunityTrainings Resource resources by subscription ID"), + // Operation: to.Ptr("CommunityTrainings_ListBySubscription"), + // Provider: to.Ptr("Microsoft.Community"), + // Resource: to.Ptr("communityTrainings"), + // }, + // IsDataAction: to.Ptr(false), + // Name: to.Ptr("Microsoft.Community/communityTrainings/read"), + // }, + // { + // Display: &armcommunitymanagement.OperationDisplay{ + // Description: to.Ptr("List CommunityTrainings Resource resources by resource group"), + // Operation: to.Ptr("CommunityTrainings_ListByResourceGroup"), + // Provider: to.Ptr("Microsoft.Community"), + // Resource: to.Ptr("communityTrainings"), + // }, + // IsDataAction: to.Ptr(false), + // Name: to.Ptr("Microsoft.Community/communityTrainings/read"), + // }, + // { + // Display: &armcommunitymanagement.OperationDisplay{ + // Description: to.Ptr("Get a CommunityTrainings Resource"), + // Operation: to.Ptr("CommunityTrainings_Get"), + // Provider: to.Ptr("Microsoft.Community"), + // Resource: to.Ptr("communityTrainings"), + // }, + // IsDataAction: to.Ptr(false), + // Name: to.Ptr("Microsoft.Community/communityTrainings/read"), + // }, + // { + // Display: &armcommunitymanagement.OperationDisplay{ + // Description: to.Ptr("Create a CommunityTrainings Resource"), + // Operation: to.Ptr("CommunityTrainings_Create"), + // Provider: to.Ptr("Microsoft.Community"), + // Resource: to.Ptr("communityTrainings"), + // }, + // IsDataAction: to.Ptr(false), + // Name: to.Ptr("Microsoft.Community/communityTrainings/write"), + // }, + // { + // Display: &armcommunitymanagement.OperationDisplay{ + // Description: to.Ptr("Delete a CommunityTraining Resource"), + // Operation: to.Ptr("CommunityTrainings_Delete"), + // Provider: to.Ptr("Microsoft.Community"), + // Resource: to.Ptr("communityTrainings"), + // }, + // IsDataAction: to.Ptr(false), + // Name: to.Ptr("Microsoft.Community/communityTrainings/delete"), + // }, + // { + // Display: &armcommunitymanagement.OperationDisplay{ + // Description: to.Ptr("Update a CommunityTrainings Resource"), + // Operation: to.Ptr("CommunityTrainings_Update"), + // Provider: to.Ptr("Microsoft.Community"), + // Resource: to.Ptr("communityTrainings"), + // }, + // IsDataAction: to.Ptr(false), + // Name: to.Ptr("Microsoft.Community/communityTrainings/write"), + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdatabasewatcher/go.mod b/packages/typespec-go/test/armdatabasewatcher/go.mod index 4e836a5f9..8ccbd0c61 100644 --- a/packages/typespec-go/test/armdatabasewatcher/go.mod +++ b/packages/typespec-go/test/armdatabasewatcher/go.mod @@ -2,10 +2,20 @@ module armdatabasewatcher go 1.18 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/packages/typespec-go/test/armdatabasewatcher/go.sum b/packages/typespec-go/test/armdatabasewatcher/go.sum index fb5e8f74b..0f58a50c0 100644 --- a/packages/typespec-go/test/armdatabasewatcher/go.sum +++ b/packages/typespec-go/test/armdatabasewatcher/go.sum @@ -1,12 +1,29 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/packages/typespec-go/test/armdatabasewatcher/zz_alertruleresources_client_example_test.go b/packages/typespec-go/test/armdatabasewatcher/zz_alertruleresources_client_example_test.go new file mode 100644 index 000000000..2213fe6e7 --- /dev/null +++ b/packages/typespec-go/test/armdatabasewatcher/zz_alertruleresources_client_example_test.go @@ -0,0 +1,183 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdatabasewatcher_test + +import ( + "armdatabasewatcher" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" + "time" +) + +// Generated from example definition: 2024-07-19-preview/AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json +func ExampleAlertRuleResourcesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAlertRuleResourcesClient().CreateOrUpdate(ctx, "rgWatcher", "testWatcher", "testAlert", armdatabasewatcher.AlertRuleResource{ + Properties: &armdatabasewatcher.AlertRuleResourceProperties{ + AlertRuleResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo"), + CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.798Z"); return t }()), + AlertRuleTemplateVersion: to.Ptr("1.0"), + AlertRuleTemplateID: to.Ptr("someTemplateId"), + CreatedWithProperties: to.Ptr(armdatabasewatcher.AlertRuleCreationPropertiesCreatedWithActionGroup), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.AlertRuleResourcesClientCreateOrUpdateResponse{ + // AlertRuleResource: &armdatabasewatcher.AlertRuleResource{ + // Properties: &armdatabasewatcher.AlertRuleResourceProperties{ + // AlertRuleResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo"), + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.798Z"); return t}()), + // AlertRuleTemplateVersion: to.Ptr("1.0"), + // AlertRuleTemplateID: to.Ptr("someTemplateId"), + // CreatedWithProperties: to.Ptr(armdatabasewatcher.AlertRuleCreationPropertiesCreatedWithActionGroup), + // ProvisioningState: to.Ptr(armdatabasewatcher.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.databasewatcher/watchers/testWatcher/alertRuleResources/testAlert"), + // Name: to.Ptr("testAlert"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/alertRuleResources"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-19-preview/AlertRuleResources_Delete_MaximumSet_Gen.json +func ExampleAlertRuleResourcesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAlertRuleResourcesClient().Delete(ctx, "rgWatcher", "testWatcher", "testAlert", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.AlertRuleResourcesClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-07-19-preview/AlertRuleResources_Get_MaximumSet_Gen.json +func ExampleAlertRuleResourcesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAlertRuleResourcesClient().Get(ctx, "rgWatcher", "testWatcher", "testAlert", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.AlertRuleResourcesClientGetResponse{ + // AlertRuleResource: &armdatabasewatcher.AlertRuleResource{ + // Properties: &armdatabasewatcher.AlertRuleResourceProperties{ + // AlertRuleResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo"), + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.798Z"); return t}()), + // AlertRuleTemplateVersion: to.Ptr("1.0"), + // AlertRuleTemplateID: to.Ptr("someTemplateId"), + // CreatedWithProperties: to.Ptr(armdatabasewatcher.AlertRuleCreationPropertiesCreatedWithActionGroup), + // ProvisioningState: to.Ptr(armdatabasewatcher.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.databasewatcher/watchers/testWatcher/alertRuleResources/testAlert"), + // Name: to.Ptr("testAlert"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/alertRuleResources"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-19-preview/AlertRuleResources_ListByParent_MaximumSet_Gen.json +func ExampleAlertRuleResourcesClient_NewListByParentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAlertRuleResourcesClient().NewListByParentPager("rgWatcher", "testWatcher", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdatabasewatcher.AlertRuleResourcesClientListByParentResponse{ + // AlertRuleResourceListResult: armdatabasewatcher.AlertRuleResourceListResult{ + // Value: []*armdatabasewatcher.AlertRuleResource{ + // { + // Properties: &armdatabasewatcher.AlertRuleResourceProperties{ + // AlertRuleResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo"), + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.798Z"); return t}()), + // AlertRuleTemplateVersion: to.Ptr("1.0"), + // ProvisioningState: to.Ptr(armdatabasewatcher.ResourceProvisioningStateSucceeded), + // AlertRuleTemplateID: to.Ptr("someTemplateId"), + // CreatedWithProperties: to.Ptr(armdatabasewatcher.AlertRuleCreationPropertiesCreatedWithActionGroup), + // }, + // ID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.databasewatcher/watchers/testWatcher/alertRuleResources/testAlert"), + // Name: to.Ptr("testAlert"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/alertRuleResources"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdatabasewatcher/zz_operations_client_example_test.go b/packages/typespec-go/test/armdatabasewatcher/zz_operations_client_example_test.go new file mode 100644 index 000000000..be71c8011 --- /dev/null +++ b/packages/typespec-go/test/armdatabasewatcher/zz_operations_client_example_test.go @@ -0,0 +1,85 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdatabasewatcher_test + +import ( + "armdatabasewatcher" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-19-preview/Operations_List_MaximumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListGeneratedByMaximumSetRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdatabasewatcher.OperationsClientListResponse{ + // OperationListResult: armdatabasewatcher.OperationListResult{ + // Value: []*armdatabasewatcher.Operation{ + // { + // Name: to.Ptr("snzrdvltunnrz"), + // IsDataAction: to.Ptr(true), + // Display: &armdatabasewatcher.OperationDisplay{ + // Provider: to.Ptr("dtfrqzamclscchmghtxn"), + // Resource: to.Ptr("lvlhnsfnquorjuuutjxex"), + // Operation: to.Ptr("vbgvamoxqwthpbdghxzaw"), + // Description: to.Ptr("nvbtuwwjfehylzmoatd"), + // }, + // Origin: to.Ptr(armdatabasewatcher.OriginUser), + // ActionType: to.Ptr(armdatabasewatcher.ActionTypeInternal), + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/awfba"), + // }, + // } + } +} + +// Generated from example definition: 2024-07-19-preview/Operations_List_MinimumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListGeneratedByMinimumSetRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdatabasewatcher.OperationsClientListResponse{ + // OperationListResult: armdatabasewatcher.OperationListResult{ + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdatabasewatcher/zz_sharedprivatelinkresources_client_example_test.go b/packages/typespec-go/test/armdatabasewatcher/zz_sharedprivatelinkresources_client_example_test.go new file mode 100644 index 000000000..37f7f7815 --- /dev/null +++ b/packages/typespec-go/test/armdatabasewatcher/zz_sharedprivatelinkresources_client_example_test.go @@ -0,0 +1,182 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdatabasewatcher_test + +import ( + "armdatabasewatcher" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-19-preview/SharedPrivateLinkResources_Create_MaximumSet_Gen.json +func ExampleSharedPrivateLinkResourcesClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSharedPrivateLinkResourcesClient().BeginCreate(ctx, "apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", armdatabasewatcher.SharedPrivateLinkResource{ + Properties: &armdatabasewatcher.SharedPrivateLinkResourceProperties{ + PrivateLinkResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih"), + GroupID: to.Ptr("vault"), + RequestMessage: to.Ptr("request message"), + DNSZone: to.Ptr("ec3ae9d410ba"), + Status: to.Ptr(armdatabasewatcher.SharedPrivateLinkResourceStatusPending), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.SharedPrivateLinkResourcesClientCreateResponse{ + // SharedPrivateLinkResource: &armdatabasewatcher.SharedPrivateLinkResource{ + // Properties: &armdatabasewatcher.SharedPrivateLinkResourceProperties{ + // PrivateLinkResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih"), + // GroupID: to.Ptr("vault"), + // RequestMessage: to.Ptr("request message"), + // DNSZone: to.Ptr("ec3ae9d410ba"), + // Status: to.Ptr(armdatabasewatcher.SharedPrivateLinkResourceStatusPending), + // }, + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.DatabaseWatcher/watchers/databasemo3ej9ih/sharedPrivateLinkResources/monitoringh22eed"), + // Name: to.Ptr("monitoringh22eed"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/sharedPrivateLinkResources"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-19-preview/SharedPrivateLinkResources_Delete_MaximumSet_Gen.json +func ExampleSharedPrivateLinkResourcesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSharedPrivateLinkResourcesClient().BeginDelete(ctx, "apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-07-19-preview/SharedPrivateLinkResources_Get_MaximumSet_Gen.json +func ExampleSharedPrivateLinkResourcesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSharedPrivateLinkResourcesClient().Get(ctx, "apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.SharedPrivateLinkResourcesClientGetResponse{ + // SharedPrivateLinkResource: &armdatabasewatcher.SharedPrivateLinkResource{ + // Properties: &armdatabasewatcher.SharedPrivateLinkResourceProperties{ + // PrivateLinkResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih"), + // GroupID: to.Ptr("vault"), + // RequestMessage: to.Ptr("request message"), + // DNSZone: to.Ptr("ec3ae9d410ba"), + // Status: to.Ptr(armdatabasewatcher.SharedPrivateLinkResourceStatusPending), + // }, + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.DatabaseWatcher/watchers/databasemo3ej9ih/sharedPrivateLinkResources/monitoringh22eed"), + // Name: to.Ptr("monitoringh22eed"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/sharedPrivateLinkResources"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-19-preview/SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json +func ExampleSharedPrivateLinkResourcesClient_NewListByWatcherPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSharedPrivateLinkResourcesClient().NewListByWatcherPager("apiTest-ddat4p", "databasemo3ej9ih", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdatabasewatcher.SharedPrivateLinkResourcesClientListByWatcherResponse{ + // SharedPrivateLinkResourceListResult: armdatabasewatcher.SharedPrivateLinkResourceListResult{ + // Value: []*armdatabasewatcher.SharedPrivateLinkResource{ + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.DatabaseWatcher/watchers/databasemo3ej9ih/sharedPrivateLinkResources/monitoringh22eed"), + // Name: to.Ptr("monitoringh22eed"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/sharedPrivateLinkResources"), + // Properties: &armdatabasewatcher.SharedPrivateLinkResourceProperties{ + // PrivateLinkResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih"), + // GroupID: to.Ptr("vault"), + // RequestMessage: to.Ptr("request message"), + // DNSZone: to.Ptr("ec3ae9d410ba"), + // Status: to.Ptr(armdatabasewatcher.SharedPrivateLinkResourceStatusPending), + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/awfba"), + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdatabasewatcher/zz_targets_client_example_test.go b/packages/typespec-go/test/armdatabasewatcher/zz_targets_client_example_test.go new file mode 100644 index 000000000..ae6652b3c --- /dev/null +++ b/packages/typespec-go/test/armdatabasewatcher/zz_targets_client_example_test.go @@ -0,0 +1,178 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdatabasewatcher_test + +import ( + "armdatabasewatcher" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-19-preview/Targets_CreateOrUpdate_MaximumSet_Gen.json +func ExampleTargetsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTargetsClient().CreateOrUpdate(ctx, "apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", armdatabasewatcher.Target{ + Properties: &armdatabasewatcher.SQLDbSingleDatabaseTargetProperties{ + TargetType: to.Ptr("SqlDb"), + TargetAuthenticationType: to.Ptr(armdatabasewatcher.TargetAuthenticationTypeAAD), + ConnectionServerName: to.Ptr("sqlServero1ihe2"), + SQLDbResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.TargetsClientCreateOrUpdateResponse{ + // Target: &armdatabasewatcher.Target{ + // Properties: &armdatabasewatcher.SQLDbSingleDatabaseTargetProperties{ + // TargetType: to.Ptr("SqlDb"), + // TargetAuthenticationType: to.Ptr(armdatabasewatcher.TargetAuthenticationTypeAAD), + // ConnectionServerName: to.Ptr("sqlServero1ihe2"), + // SQLDbResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2"), + // ProvisioningState: to.Ptr(armdatabasewatcher.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-px9ma7/providers/Microsoft.DatabaseWatcher/watchers/databasemo3d9sgt/targets/monitoringzkndgm"), + // Name: to.Ptr("monitoringzkndgm"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/targets"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-19-preview/Targets_Delete_MaximumSet_Gen.json +func ExampleTargetsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTargetsClient().Delete(ctx, "apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.TargetsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2024-07-19-preview/Targets_Get_MaximumSet_Gen.json +func ExampleTargetsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTargetsClient().Get(ctx, "apiTest-ddat4p", "databasemo3ej9ih", "monitoringh22eed", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.TargetsClientGetResponse{ + // Target: &armdatabasewatcher.Target{ + // Properties: &armdatabasewatcher.SQLDbSingleDatabaseTargetProperties{ + // TargetType: to.Ptr("SqlDb"), + // TargetAuthenticationType: to.Ptr(armdatabasewatcher.TargetAuthenticationTypeAAD), + // ConnectionServerName: to.Ptr("sqlServero1ihe2"), + // SQLDbResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2"), + // ProvisioningState: to.Ptr(armdatabasewatcher.ResourceProvisioningStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-px9ma7/providers/Microsoft.DatabaseWatcher/watchers/databasemo3d9sgt/targets/monitoringzkndgm"), + // Name: to.Ptr("monitoringzkndgm"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/targets"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-19-preview/Targets_ListByWatcher_MaximumSet_Gen.json +func ExampleTargetsClient_NewListByWatcherPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTargetsClient().NewListByWatcherPager("apiTest-ddat4p", "databasemo3ej9ih", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdatabasewatcher.TargetsClientListByWatcherResponse{ + // TargetListResult: armdatabasewatcher.TargetListResult{ + // Value: []*armdatabasewatcher.Target{ + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-px9ma7/providers/Microsoft.DatabaseWatcher/watchers/databasemo3d9sgt/targets/monitoringzkndgm"), + // Name: to.Ptr("monitoringzkndgm"), + // Type: to.Ptr("microsoft.databasewatcher/watchers/targets"), + // Properties: &armdatabasewatcher.SQLDbSingleDatabaseTargetProperties{ + // TargetType: to.Ptr("SqlDb"), + // TargetAuthenticationType: to.Ptr(armdatabasewatcher.TargetAuthenticationTypeAAD), + // ConnectionServerName: to.Ptr("sqlServero1ihe2"), + // SQLDbResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2"), + // ProvisioningState: to.Ptr(armdatabasewatcher.ResourceProvisioningStateSucceeded), + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdatabasewatcher/zz_watchers_client_example_test.go b/packages/typespec-go/test/armdatabasewatcher/zz_watchers_client_example_test.go new file mode 100644 index 000000000..d1390c585 --- /dev/null +++ b/packages/typespec-go/test/armdatabasewatcher/zz_watchers_client_example_test.go @@ -0,0 +1,871 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdatabasewatcher_test + +import ( + "armdatabasewatcher" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-19-preview/Watchers_CreateOrUpdate_MaximumSet_Gen.json +func ExampleWatchersClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWatchersClient().BeginCreateOrUpdate(ctx, "rgWatcher", "testWatcher", armdatabasewatcher.Watcher{ + Properties: &armdatabasewatcher.WatcherProperties{ + Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + Datastore: &armdatabasewatcher.Datastore{ + AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + KustoManagementURL: to.Ptr("https://portal.azure.com/"), + KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + }, + }, + Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + Type: to.Ptr(armdatabasewatcher.ManagedServiceIdentityTypeSystemAssigned), + }, + Tags: map[string]*string{}, + Location: to.Ptr("eastus2euap"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.WatchersClientCreateOrUpdateResponse{ + // Watcher: &armdatabasewatcher.Watcher{ + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // Type: to.Ptr(armdatabasewatcher.ManagedServiceIdentityTypeSystemAssigned), + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("eastus2euap"), + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/dummyrg/providers/Microsoft.DatabaseWatcher/watchers/myWatcher"), + // Name: to.Ptr("myWatcher"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-19-preview/Watchers_Delete_MaximumSet_Gen.json +func ExampleWatchersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWatchersClient().BeginDelete(ctx, "rgWatcher", "testWatcher", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-07-19-preview/Watchers_Get_MaximumSet_Gen.json +func ExampleWatchersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWatchersClient().Get(ctx, "rgWatcher", "myWatcher", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.WatchersClientGetResponse{ + // Watcher: &armdatabasewatcher.Watcher{ + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("eastus2euap"), + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/dummyrg/providers/Microsoft.DatabaseWatcher/watchers/myWatcher"), + // Name: to.Ptr("myWatcher"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-19-preview/Watchers_ListByResourceGroup_MaximumSet_Gen.json +func ExampleWatchersClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWatchersClient().NewListByResourceGroupPager("rgWatcher", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdatabasewatcher.WatchersClientListByResourceGroupResponse{ + // WatcherListResult: armdatabasewatcher.WatcherListResult{ + // Value: []*armdatabasewatcher.Watcher{ + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/dummyrg/providers/Microsoft.DatabaseWatcher/watchers/myWatcher"), + // Name: to.Ptr("myWatcher"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-4sz1jg/providers/Microsoft.DatabaseWatcher/watchers/databasemo4o4zdf"), + // Name: to.Ptr("databasemo4o4zdf"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-d77ftn/providers/Microsoft.DatabaseWatcher/watchers/databasemosn3h6l"), + // Name: to.Ptr("databasemosn3h6l"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-nyb4gm/providers/Microsoft.DatabaseWatcher/watchers/databasemoyb6iar"), + // Name: to.Ptr("databasemoyb6iar"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-llis4j/providers/Microsoft.DatabaseWatcher/watchers/databasemoi04xst"), + // Name: to.Ptr("databasemoi04xst"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-thy6zd/providers/Microsoft.DatabaseWatcher/watchers/databasemonpyl24"), + // Name: to.Ptr("databasemonpyl24"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("ysoqerxnmxqsvhmvjojoyzotc"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T18:01:18.690Z"); return t}()), + // LastModifiedBy: to.Ptr("yrilzsg"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T18:01:18.690Z"); return t}()), + // }, + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.DatabaseWatcher/watchers/databasemo3ej9ih"), + // Name: to.Ptr("databasemo3ej9ih"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-07-19-preview/Watchers_ListBySubscription_MaximumSet_Gen.json +func ExampleWatchersClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWatchersClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdatabasewatcher.WatchersClientListBySubscriptionResponse{ + // WatcherListResult: armdatabasewatcher.WatcherListResult{ + // Value: []*armdatabasewatcher.Watcher{ + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/dummyrg/providers/Microsoft.DatabaseWatcher/watchers/myWatcher"), + // Name: to.Ptr("myWatcher"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // Type: to.Ptr(armdatabasewatcher.ManagedServiceIdentityTypeSystemAssigned), + // }, + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-4sz1jg/providers/Microsoft.DatabaseWatcher/watchers/databasemo4o4zdf"), + // Name: to.Ptr("databasemo4o4zdf"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-d77ftn/providers/Microsoft.DatabaseWatcher/watchers/databasemosn3h6l"), + // Name: to.Ptr("databasemosn3h6l"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-nyb4gm/providers/Microsoft.DatabaseWatcher/watchers/databasemoyb6iar"), + // Name: to.Ptr("databasemoyb6iar"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-llis4j/providers/Microsoft.DatabaseWatcher/watchers/databasemoi04xst"), + // Name: to.Ptr("databasemoi04xst"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-thy6zd/providers/Microsoft.DatabaseWatcher/watchers/databasemonpyl24"), + // Name: to.Ptr("databasemonpyl24"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("ysoqerxnmxqsvhmvjojoyzotc"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T18:01:18.690Z"); return t}()), + // LastModifiedBy: to.Ptr("yrilzsg"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T18:01:18.690Z"); return t}()), + // }, + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest-ddat4p/providers/Microsoft.DatabaseWatcher/watchers/databasemo3ej9ih"), + // Name: to.Ptr("databasemo3ej9ih"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // Location: to.Ptr("westus"), + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-07-19-preview/Watchers_Start_MaximumSet_Gen.json +func ExampleWatchersClient_BeginStart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWatchersClient().BeginStart(ctx, "rgWatcher", "testWatcher", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.WatchersClientStartResponse{ + // } +} + +// Generated from example definition: 2024-07-19-preview/Watchers_Stop_MaximumSet_Gen.json +func ExampleWatchersClient_BeginStop() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWatchersClient().BeginStop(ctx, "rgWatcher", "myWatcher", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.WatchersClientStopResponse{ + // } +} + +// Generated from example definition: 2024-07-19-preview/Watchers_Update_MaximumSet_Gen.json +func ExampleWatchersClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdatabasewatcher.NewClientFactory("6f53185c-ea09-4fc3-9075-318dec805303", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWatchersClient().BeginUpdate(ctx, "rgWatcher", "testWatcher", armdatabasewatcher.WatcherUpdate{ + Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + Type: to.Ptr(armdatabasewatcher.ManagedServiceIdentityTypeSystemAssigned), + }, + Properties: &armdatabasewatcher.WatcherUpdateProperties{ + Datastore: &armdatabasewatcher.Datastore{ + AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + KustoManagementURL: to.Ptr("https://portal.azure.com/"), + KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + }, + DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/newtest"), + }, + Tags: map[string]*string{}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdatabasewatcher.WatchersClientUpdateResponse{ + // Watcher: &armdatabasewatcher.Watcher{ + // Properties: &armdatabasewatcher.WatcherProperties{ + // Status: to.Ptr(armdatabasewatcher.WatcherStatusStarting), + // DefaultAlertRuleIdentityResourceID: to.Ptr("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + // Datastore: &armdatabasewatcher.Datastore{ + // AdxClusterResourceID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + // KustoClusterURI: to.Ptr("https://kustouri-adx.eastus.kusto.windows.net"), + // KustoClusterDisplayName: to.Ptr("kustoUri-adx"), + // KustoDataIngestionURI: to.Ptr("https://ingest-kustouri-adx.eastus.kusto.windows.net"), + // KustoDatabaseName: to.Ptr("kustoDatabaseName1"), + // KustoManagementURL: to.Ptr("https://portal.azure.com/"), + // KustoOfferingType: to.Ptr(armdatabasewatcher.KustoOfferingTypeAdx), + // }, + // ProvisioningState: to.Ptr(armdatabasewatcher.DatabaseWatcherProvisioningStateSucceeded), + // }, + // Identity: &armdatabasewatcher.ManagedServiceIdentityV4{ + // Type: to.Ptr(armdatabasewatcher.ManagedServiceIdentityTypeSystemAssigned), + // UserAssignedIdentities: map[string]*armdatabasewatcher.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // TenantID: to.Ptr("6f53185c-ea09-4fc3-9075-318dec805303"), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("eastus2euap"), + // ID: to.Ptr("/subscriptions/6f53185c-ea09-4fc3-9075-318dec805303/resourceGroups/dummyrg/providers/Microsoft.DatabaseWatcher/watchers/myWatcher"), + // Name: to.Ptr("myWatcher"), + // Type: to.Ptr("microsoft.databasewatcher/watchers"), + // SystemData: &armdatabasewatcher.SystemData{ + // CreatedBy: to.Ptr("enbpvlpqbwd"), + // CreatedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // LastModifiedBy: to.Ptr("mxp"), + // LastModifiedByType: to.Ptr(armdatabasewatcher.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-25T15:38:47.092Z"); return t}()), + // }, + // }, + // } +} diff --git a/packages/typespec-go/test/armdevopsinfrastructure/go.mod b/packages/typespec-go/test/armdevopsinfrastructure/go.mod index 0f8f92a5b..c77147ec6 100644 --- a/packages/typespec-go/test/armdevopsinfrastructure/go.mod +++ b/packages/typespec-go/test/armdevopsinfrastructure/go.mod @@ -2,10 +2,20 @@ module armdevopsinfrastructure go 1.18 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/packages/typespec-go/test/armdevopsinfrastructure/go.sum b/packages/typespec-go/test/armdevopsinfrastructure/go.sum index fb5e8f74b..0f58a50c0 100644 --- a/packages/typespec-go/test/armdevopsinfrastructure/go.sum +++ b/packages/typespec-go/test/armdevopsinfrastructure/go.sum @@ -1,12 +1,29 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/packages/typespec-go/test/armdevopsinfrastructure/zz_imageversions_client_example_test.go b/packages/typespec-go/test/armdevopsinfrastructure/zz_imageversions_client_example_test.go new file mode 100644 index 000000000..59a6ad0aa --- /dev/null +++ b/packages/typespec-go/test/armdevopsinfrastructure/zz_imageversions_client_example_test.go @@ -0,0 +1,51 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdevopsinfrastructure_test + +import ( + "armdevopsinfrastructure" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-04-04-preview/ImageVersions_ListByImage.json +func ExampleImageVersionsClient_NewListByImagePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewImageVersionsClient().NewListByImagePager("my-resource-group", "windows-2022", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdevopsinfrastructure.ImageVersionsClientListByImageResponse{ + // ImageVersionListResult: armdevopsinfrastructure.ImageVersionListResult{ + // Value: []*armdevopsinfrastructure.ImageVersion{ + // { + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/my-resource-group/providers/Microsoft.DevOpsInfrastructure/images/windows-2022/versions/2024.0417.0"), + // Name: to.Ptr("2024.0417.0"), + // }, + // { + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/my-resource-group/providers/Microsoft.DevOpsInfrastructure/images/windows-2022/versions/2024.0417.1"), + // Name: to.Ptr("2024.0417.1"), + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdevopsinfrastructure/zz_operations_client_example_test.go b/packages/typespec-go/test/armdevopsinfrastructure/zz_operations_client_example_test.go new file mode 100644 index 000000000..63ebeb1da --- /dev/null +++ b/packages/typespec-go/test/armdevopsinfrastructure/zz_operations_client_example_test.go @@ -0,0 +1,41 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdevopsinfrastructure_test + +import ( + "armdevopsinfrastructure" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-04-04-preview/ListOperations.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdevopsinfrastructure.OperationsClientListResponse{ + // OperationListResult: armdevopsinfrastructure.OperationListResult{ + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdevopsinfrastructure/zz_pools_client_example_test.go b/packages/typespec-go/test/armdevopsinfrastructure/zz_pools_client_example_test.go new file mode 100644 index 000000000..0f8605826 --- /dev/null +++ b/packages/typespec-go/test/armdevopsinfrastructure/zz_pools_client_example_test.go @@ -0,0 +1,272 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdevopsinfrastructure_test + +import ( + "armdevopsinfrastructure" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-04-04-preview/CreateOrUpdatePool.json +func ExamplePoolsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPoolsClient().BeginCreateOrUpdate(ctx, "rg", "pool", armdevopsinfrastructure.Pool{ + Location: to.Ptr("eastus"), + Properties: &armdevopsinfrastructure.PoolProperties{ + ProvisioningState: to.Ptr(armdevopsinfrastructure.ProvisioningStateSucceeded), + MaximumConcurrency: to.Ptr[int32](10), + DevCenterProjectResourceID: to.Ptr("/subscriptions/222e81d0-cf38-4dab-baa5-289bf16baaa4/resourceGroups/rg-1es-devcenter/providers/Microsoft.DevCenter/projects/1ES"), + OrganizationProfile: &armdevopsinfrastructure.AzureDevOpsOrganizationProfile{ + Kind: to.Ptr("AzureDevOps"), + Organizations: []*armdevopsinfrastructure.Organization{ + { + URL: to.Ptr("https://mseng.visualstudio.com"), + }, + }, + }, + AgentProfile: &armdevopsinfrastructure.StatelessAgentProfile{ + Kind: to.Ptr("Stateless"), + }, + FabricProfile: &armdevopsinfrastructure.VmssFabricProfile{ + Kind: to.Ptr("Vmss"), + SKU: &armdevopsinfrastructure.DevOpsAzureSKU{ + Name: to.Ptr("Standard_D4ads_v5"), + }, + Images: []*armdevopsinfrastructure.PoolImage{ + { + ResourceID: to.Ptr("/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest"), + }, + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdevopsinfrastructure.PoolsClientCreateOrUpdateResponse{ + // Pool: &armdevopsinfrastructure.Pool{ + // Properties: &armdevopsinfrastructure.PoolProperties{ + // ProvisioningState: to.Ptr(armdevopsinfrastructure.ProvisioningStateSucceeded), + // MaximumConcurrency: to.Ptr[int32](10), + // DevCenterProjectResourceID: to.Ptr("/subscriptions/222e81d0-cf38-4dab-baa5-289bf16baaa4/resourceGroups/rg-1es-devcenter/providers/Microsoft.DevCenter/projects/1ES"), + // OrganizationProfile: &armdevopsinfrastructure.AzureDevOpsOrganizationProfile{ + // Kind: to.Ptr("AzureDevOps"), + // Organizations: []*armdevopsinfrastructure.Organization{ + // { + // URL: to.Ptr("https://mseng.visualstudio.com"), + // }, + // }, + // }, + // AgentProfile: &armdevopsinfrastructure.StatelessAgentProfile{ + // Kind: to.Ptr("Stateless"), + // }, + // FabricProfile: &armdevopsinfrastructure.VmssFabricProfile{ + // Kind: to.Ptr("Vmss"), + // SKU: &armdevopsinfrastructure.DevOpsAzureSKU{ + // Name: to.Ptr("Standard_D4ads_v5"), + // }, + // Images: []*armdevopsinfrastructure.PoolImage{ + // { + // ResourceID: to.Ptr("/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest"), + // }, + // }, + // }, + // }, + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/rg/providers/Microsoft.DevOpsInfrastructure/Pools/pool"), + // Location: to.Ptr("eastus"), + // }, + // } +} + +// Generated from example definition: 2024-04-04-preview/DeletePool.json +func ExamplePoolsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPoolsClient().BeginDelete(ctx, "rg", "pool", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-04-04-preview/GetPool.json +func ExamplePoolsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPoolsClient().Get(ctx, "rg", "pool", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdevopsinfrastructure.PoolsClientGetResponse{ + // Pool: &armdevopsinfrastructure.Pool{ + // Properties: &armdevopsinfrastructure.PoolProperties{ + // ProvisioningState: to.Ptr(armdevopsinfrastructure.ProvisioningStateSucceeded), + // MaximumConcurrency: to.Ptr[int32](10), + // DevCenterProjectResourceID: to.Ptr("/subscriptions/222e81d0-cf38-4dab-baa5-289bf16baaa4/resourceGroups/rg-1es-devcenter/providers/Microsoft.DevCenter/projects/1ES"), + // OrganizationProfile: &armdevopsinfrastructure.AzureDevOpsOrganizationProfile{ + // Kind: to.Ptr("AzureDevOps"), + // Organizations: []*armdevopsinfrastructure.Organization{ + // { + // URL: to.Ptr("https://mseng.visualstudio.com"), + // }, + // }, + // }, + // AgentProfile: &armdevopsinfrastructure.StatelessAgentProfile{ + // Kind: to.Ptr("Stateless"), + // }, + // FabricProfile: &armdevopsinfrastructure.VmssFabricProfile{ + // Kind: to.Ptr("Vmss"), + // SKU: &armdevopsinfrastructure.DevOpsAzureSKU{ + // Name: to.Ptr("Standard_D4ads_v5"), + // }, + // Images: []*armdevopsinfrastructure.PoolImage{ + // { + // ResourceID: to.Ptr("/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest"), + // }, + // }, + // }, + // }, + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/rg/providers/Microsoft.DevOpsInfrastructure/Pools/pool"), + // Location: to.Ptr("eastus"), + // }, + // } +} + +// Generated from example definition: 2024-04-04-preview/ListPoolsBySubscriptionAndResourceGroup.json +func ExamplePoolsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPoolsClient().NewListByResourceGroupPager("rg", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdevopsinfrastructure.PoolsClientListByResourceGroupResponse{ + // PoolListResult: armdevopsinfrastructure.PoolListResult{ + // Value: []*armdevopsinfrastructure.Pool{ + // { + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/rg/providers/Microsoft.DevOpsInfrastructure/Pools/pool"), + // Location: to.Ptr("eastus"), + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-04-04-preview/ListPoolsBySubscription.json +func ExamplePoolsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPoolsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdevopsinfrastructure.PoolsClientListBySubscriptionResponse{ + // PoolListResult: armdevopsinfrastructure.PoolListResult{ + // Value: []*armdevopsinfrastructure.Pool{ + // { + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/aoiresourceGroupName/providers/Microsoft.DevOpsInfrastructure/Pools/pool"), + // Location: to.Ptr("eastus"), + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-04-04-preview/UpdatePool.json +func ExamplePoolsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPoolsClient().BeginUpdate(ctx, "rg", "pool", armdevopsinfrastructure.PoolUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armdevopsinfrastructure.PoolsClientUpdateResponse{ + // Pool: &armdevopsinfrastructure.Pool{ + // Location: to.Ptr("eastus"), + // }, + // } +} diff --git a/packages/typespec-go/test/armdevopsinfrastructure/zz_resourcedetails_client_example_test.go b/packages/typespec-go/test/armdevopsinfrastructure/zz_resourcedetails_client_example_test.go new file mode 100644 index 000000000..53ba5062d --- /dev/null +++ b/packages/typespec-go/test/armdevopsinfrastructure/zz_resourcedetails_client_example_test.go @@ -0,0 +1,61 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdevopsinfrastructure_test + +import ( + "armdevopsinfrastructure" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-04-04-preview/ResourceDetails_ListByPool.json +func ExampleResourceDetailsClient_NewListByPoolPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewResourceDetailsClient().NewListByPoolPager("my-resource-group", "my-dev-ops-pool", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdevopsinfrastructure.ResourceDetailsClientListByPoolResponse{ + // ResourceDetailsObjectListResult: armdevopsinfrastructure.ResourceDetailsObjectListResult{ + // Value: []*armdevopsinfrastructure.ResourceDetailsObject{ + // { + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/my-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/my-devops-pool/resources/my-dev-ops-pool:04dcde21-626e-5a7e-8659-ce12f9284b29:dd8cc705c_0"), + // Name: to.Ptr("dd8cc705c000000"), + // Properties: &armdevopsinfrastructure.ResourceDetailsObjectProperties{ + // Image: to.Ptr("my-image"), + // ImageVersion: to.Ptr("4.0.0"), + // Status: to.Ptr(armdevopsinfrastructure.ResourceStatusReady), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/my-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/my-devops-pool/resources/my-dev-ops-pool:04dcde21-626e-5a7e-8659-ce12f9284b29:dd8cc705c_1"), + // Name: to.Ptr("dd8cc705c000001"), + // Properties: &armdevopsinfrastructure.ResourceDetailsObjectProperties{ + // Image: to.Ptr("my-image"), + // ImageVersion: to.Ptr("4.0.0"), + // Status: to.Ptr(armdevopsinfrastructure.ResourceStatusAllocated), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdevopsinfrastructure/zz_sku_client_example_test.go b/packages/typespec-go/test/armdevopsinfrastructure/zz_sku_client_example_test.go new file mode 100644 index 000000000..7ad15689c --- /dev/null +++ b/packages/typespec-go/test/armdevopsinfrastructure/zz_sku_client_example_test.go @@ -0,0 +1,307 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdevopsinfrastructure_test + +import ( + "armdevopsinfrastructure" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-04-04-preview/Sku_ListByLocation.json +func ExampleSKUClient_NewListByLocationPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSKUClient().NewListByLocationPager("eastus", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdevopsinfrastructure.SKUClientListByLocationResponse{ + // ResourceSKUListResult: armdevopsinfrastructure.ResourceSKUListResult{ + // Value: []*armdevopsinfrastructure.ResourceSKU{ + // { + // Properties: &armdevopsinfrastructure.ResourceSKUProperties{ + // ResourceType: to.Ptr("virtualMachines"), + // Tier: to.Ptr("Basic"), + // Size: to.Ptr("A0"), + // Family: to.Ptr("basicAFamily"), + // Locations: []*string{ + // to.Ptr("eastus"), + // }, + // LocationInfo: []*armdevopsinfrastructure.ResourceSKULocationInfo{ + // { + // Location: to.Ptr("eastus"), + // Zones: []*string{ + // }, + // ZoneDetails: []*armdevopsinfrastructure.ResourceSKUZoneDetails{ + // }, + // }, + // }, + // Capabilities: []*armdevopsinfrastructure.ResourceSKUCapabilities{ + // { + // Name: to.Ptr("MaxResourceVolumeMB"), + // Value: to.Ptr("20480"), + // }, + // { + // Name: to.Ptr("OSVhdSizeMB"), + // Value: to.Ptr("1047552"), + // }, + // { + // Name: to.Ptr("vCPUs"), + // Value: to.Ptr("1"), + // }, + // { + // Name: to.Ptr("MemoryPreservingMaintenanceSupported"), + // Value: to.Ptr("True"), + // }, + // { + // Name: to.Ptr("HyperVGenerations"), + // Value: to.Ptr("V1"), + // }, + // { + // Name: to.Ptr("MemoryGB"), + // Value: to.Ptr("0.75"), + // }, + // { + // Name: to.Ptr("MaxDataDiskCount"), + // Value: to.Ptr("1"), + // }, + // { + // Name: to.Ptr("CpuArchitectureType"), + // Value: to.Ptr("x64"), + // }, + // { + // Name: to.Ptr("LowPriorityCapable"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("PremiumIO"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("VMDeploymentTypes"), + // Value: to.Ptr("IaaS"), + // }, + // { + // Name: to.Ptr("vCPUsAvailable"), + // Value: to.Ptr("1"), + // }, + // { + // Name: to.Ptr("ACUs"), + // Value: to.Ptr("50"), + // }, + // { + // Name: to.Ptr("vCPUsPerCore"), + // Value: to.Ptr("1"), + // }, + // { + // Name: to.Ptr("EphemeralOSDiskSupported"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("EncryptionAtHostSupported"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("CapacityReservationSupported"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("AcceleratedNetworkingEnabled"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("RdmaEnabled"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("MaxNetworkInterfaces"), + // Value: to.Ptr("2"), + // }, + // }, + // Restrictions: []*armdevopsinfrastructure.ResourceSKURestrictions{ + // { + // Type: to.Ptr(armdevopsinfrastructure.ResourceSKURestrictionsTypeLocation), + // Values: []*string{ + // to.Ptr("eastus"), + // }, + // RestrictionInfo: &armdevopsinfrastructure.ResourceSKURestrictionInfo{ + // Locations: []*string{ + // to.Ptr("eastus"), + // }, + // }, + // ReasonCode: to.Ptr(armdevopsinfrastructure.ResourceSKURestrictionsReasonCodeNotAvailableForSubscription), + // }, + // { + // Type: to.Ptr(armdevopsinfrastructure.ResourceSKURestrictionsTypeZone), + // Values: []*string{ + // to.Ptr("eastus"), + // }, + // RestrictionInfo: &armdevopsinfrastructure.ResourceSKURestrictionInfo{ + // Locations: []*string{ + // to.Ptr("eastus"), + // }, + // Zones: []*string{ + // to.Ptr("1"), + // to.Ptr("2"), + // to.Ptr("3"), + // }, + // }, + // ReasonCode: to.Ptr(armdevopsinfrastructure.ResourceSKURestrictionsReasonCodeNotAvailableForSubscription), + // }, + // }, + // }, + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/providers/Microsoft.DevOpsInfrastructure/locations/eastus/skus/Basic_A0"), + // Name: to.Ptr("Basic_A0"), + // }, + // { + // Properties: &armdevopsinfrastructure.ResourceSKUProperties{ + // ResourceType: to.Ptr("virtualMachines"), + // Tier: to.Ptr("Standard"), + // Size: to.Ptr("A2_v2"), + // Family: to.Ptr("standardAv2Family"), + // Locations: []*string{ + // to.Ptr("eastus"), + // }, + // LocationInfo: []*armdevopsinfrastructure.ResourceSKULocationInfo{ + // { + // Location: to.Ptr("eastus"), + // Zones: []*string{ + // to.Ptr("1"), + // to.Ptr("2"), + // to.Ptr("3"), + // }, + // ZoneDetails: []*armdevopsinfrastructure.ResourceSKUZoneDetails{ + // }, + // }, + // }, + // Capabilities: []*armdevopsinfrastructure.ResourceSKUCapabilities{ + // { + // Name: to.Ptr("MaxResourceVolumeMB"), + // Value: to.Ptr("20480"), + // }, + // { + // Name: to.Ptr("OSVhdSizeMB"), + // Value: to.Ptr("1047552"), + // }, + // { + // Name: to.Ptr("vCPUs"), + // Value: to.Ptr("2"), + // }, + // { + // Name: to.Ptr("MemoryPreservingMaintenanceSupported"), + // Value: to.Ptr("True"), + // }, + // { + // Name: to.Ptr("HyperVGenerations"), + // Value: to.Ptr("V1"), + // }, + // { + // Name: to.Ptr("MemoryGB"), + // Value: to.Ptr("4"), + // }, + // { + // Name: to.Ptr("MaxDataDiskCount"), + // Value: to.Ptr("4"), + // }, + // { + // Name: to.Ptr("CpuArchitectureType"), + // Value: to.Ptr("x64"), + // }, + // { + // Name: to.Ptr("LowPriorityCapable"), + // Value: to.Ptr("True"), + // }, + // { + // Name: to.Ptr("PremiumIO"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("VMDeploymentTypes"), + // Value: to.Ptr("PaaS,IaaS"), + // }, + // { + // Name: to.Ptr("vCPUsAvailable"), + // Value: to.Ptr("2"), + // }, + // { + // Name: to.Ptr("ACUs"), + // Value: to.Ptr("100"), + // }, + // { + // Name: to.Ptr("vCPUsPerCore"), + // Value: to.Ptr("1"), + // }, + // { + // Name: to.Ptr("CombinedTempDiskAndCachedIOPS"), + // Value: to.Ptr("2000"), + // }, + // { + // Name: to.Ptr("CombinedTempDiskAndCachedReadBytesPerSecond"), + // Value: to.Ptr("41943040"), + // }, + // { + // Name: to.Ptr("CombinedTempDiskAndCachedWriteBytesPerSecond"), + // Value: to.Ptr("20971520"), + // }, + // { + // Name: to.Ptr("UncachedDiskIOPS"), + // Value: to.Ptr("3200"), + // }, + // { + // Name: to.Ptr("UncachedDiskBytesPerSecond"), + // Value: to.Ptr("48000000"), + // }, + // { + // Name: to.Ptr("EphemeralOSDiskSupported"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("EncryptionAtHostSupported"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("CapacityReservationSupported"), + // Value: to.Ptr("True"), + // }, + // { + // Name: to.Ptr("AcceleratedNetworkingEnabled"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("RdmaEnabled"), + // Value: to.Ptr("False"), + // }, + // { + // Name: to.Ptr("MaxNetworkInterfaces"), + // Value: to.Ptr("2"), + // }, + // }, + // Restrictions: []*armdevopsinfrastructure.ResourceSKURestrictions{ + // }, + // }, + // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/providers/Microsoft.DevOpsInfrastructure/locations/eastus/skus/Standard_A2_v2"), + // Name: to.Ptr("Standard_A2_v2"), + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armdevopsinfrastructure/zz_subscriptionusages_client_example_test.go b/packages/typespec-go/test/armdevopsinfrastructure/zz_subscriptionusages_client_example_test.go new file mode 100644 index 000000000..4be12a946 --- /dev/null +++ b/packages/typespec-go/test/armdevopsinfrastructure/zz_subscriptionusages_client_example_test.go @@ -0,0 +1,63 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armdevopsinfrastructure_test + +import ( + "armdevopsinfrastructure" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-04-04-preview/SubscriptionUsages_Usages.json +func ExampleSubscriptionUsagesClient_NewUsagesPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armdevopsinfrastructure.NewClientFactory("a2e95d27-c161-4b61-bda4-11512c14c2c2", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSubscriptionUsagesClient().NewUsagesPager("eastus", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armdevopsinfrastructure.SubscriptionUsagesClientUsagesResponse{ + // PagedQuota: armdevopsinfrastructure.PagedQuota{ + // Value: []*armdevopsinfrastructure.Quota{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus/providers/Microsoft.DevOpsInfrastructure/Usages/standardDADSv5Family"), + // Unit: to.Ptr("Count"), + // CurrentValue: to.Ptr[int64](0), + // Limit: to.Ptr[int64](212), + // Name: &armdevopsinfrastructure.QuotaName{ + // Value: to.Ptr("standardDADSv5Family"), + // LocalizedValue: to.Ptr("Standard DADSv5 Family vCPUs (PME VMSS)"), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus/providers/Microsoft.DevOpsInfrastructure/Usages/standardDPLDSv5Family"), + // Unit: to.Ptr("Count"), + // CurrentValue: to.Ptr[int64](0), + // Limit: to.Ptr[int64](100), + // Name: &armdevopsinfrastructure.QuotaName{ + // Value: to.Ptr("standardDPLDSv5Family"), + // LocalizedValue: to.Ptr("Standard DPLDSv5 Family vCPUs (PME VMSS)"), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armmongocluster/go.mod b/packages/typespec-go/test/armmongocluster/go.mod index f08c329b4..962131b3e 100644 --- a/packages/typespec-go/test/armmongocluster/go.mod +++ b/packages/typespec-go/test/armmongocluster/go.mod @@ -2,10 +2,20 @@ module armmongocluster go 1.18 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/packages/typespec-go/test/armmongocluster/go.sum b/packages/typespec-go/test/armmongocluster/go.sum index fb5e8f74b..0f58a50c0 100644 --- a/packages/typespec-go/test/armmongocluster/go.sum +++ b/packages/typespec-go/test/armmongocluster/go.sum @@ -1,12 +1,29 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/packages/typespec-go/test/armmongocluster/zz_firewallrules_client_example_test.go b/packages/typespec-go/test/armmongocluster/zz_firewallrules_client_example_test.go new file mode 100644 index 000000000..dde8217c2 --- /dev/null +++ b/packages/typespec-go/test/armmongocluster/zz_firewallrules_client_example_test.go @@ -0,0 +1,190 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armmongocluster_test + +import ( + "armmongocluster" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleCreate.json +func ExampleFirewallRulesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFirewallRulesClient().BeginCreateOrUpdate(ctx, "TestGroup", "myMongoCluster", "rule1", armmongocluster.FirewallRule{ + Properties: &armmongocluster.FirewallRuleProperties{ + StartIPAddress: to.Ptr("0.0.0.0"), + EndIPAddress: to.Ptr("255.255.255.255"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.FirewallRulesClientCreateOrUpdateResponse{ + // FirewallRule: &armmongocluster.FirewallRule{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/firewallRules/rule1"), + // Name: to.Ptr("rule1"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters/firewallRules"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.FirewallRuleProperties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // StartIPAddress: to.Ptr("0.0.0.0"), + // EndIPAddress: to.Ptr("255.255.255.255"), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleDelete.json +func ExampleFirewallRulesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFirewallRulesClient().BeginDelete(ctx, "TestGroup", "myMongoCluster", "rule1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleGet.json +func ExampleFirewallRulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFirewallRulesClient().Get(ctx, "TestGroup", "myMongoCluster", "rule1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.FirewallRulesClientGetResponse{ + // FirewallRule: &armmongocluster.FirewallRule{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/firewallRules/rule1"), + // Name: to.Ptr("rule1"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters/firewallRules"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.FirewallRuleProperties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // StartIPAddress: to.Ptr("0.0.0.0"), + // EndIPAddress: to.Ptr("255.255.255.255"), + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleList.json +func ExampleFirewallRulesClient_NewListByMongoClusterPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFirewallRulesClient().NewListByMongoClusterPager("TestGroup", "myMongoCluster", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armmongocluster.FirewallRulesClientListByMongoClusterResponse{ + // FirewallRuleListResult: armmongocluster.FirewallRuleListResult{ + // Value: []*armmongocluster.FirewallRule{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/firewallRules/rule1"), + // Name: to.Ptr("rule1"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters/firewallRules"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.FirewallRuleProperties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // StartIPAddress: to.Ptr("0.0.0.0"), + // EndIPAddress: to.Ptr("255.255.255.255"), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/firewallRules/rule2"), + // Name: to.Ptr("rule2"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters/firewallRules"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.FirewallRuleProperties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // StartIPAddress: to.Ptr("1.0.0.0"), + // EndIPAddress: to.Ptr("255.0.0.0"), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armmongocluster/zz_mongoclusters_client_example_test.go b/packages/typespec-go/test/armmongocluster/zz_mongoclusters_client_example_test.go new file mode 100644 index 000000000..402125973 --- /dev/null +++ b/packages/typespec-go/test/armmongocluster/zz_mongoclusters_client_example_test.go @@ -0,0 +1,1058 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armmongocluster_test + +import ( + "armmongocluster" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" + "time" +) + +// Generated from example definition: 2024-07-01/MongoClusters_NameAvailability.json +func ExampleMongoClustersClient_CheckNameAvailability_checksAndConfirmsTheMongoClusterNameIsAvailabilityForUse() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMongoClustersClient().CheckNameAvailability(ctx, "westus2", armmongocluster.CheckNameAvailabilityRequest{ + Name: to.Ptr("newmongocluster"), + Type: to.Ptr("Microsoft.DocumentDB/mongoClusters"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientCheckNameAvailabilityResponse{ + // CheckNameAvailabilityResponse: &armmongocluster.CheckNameAvailabilityResponse{ + // NameAvailable: to.Ptr(true), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_NameAvailability_AlreadyExists.json +func ExampleMongoClustersClient_CheckNameAvailability_checksAndReturnsThatTheMongoClusterNameIsAlreadyInUse() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMongoClustersClient().CheckNameAvailability(ctx, "westus2", armmongocluster.CheckNameAvailabilityRequest{ + Name: to.Ptr("existingmongocluster"), + Type: to.Ptr("Microsoft.DocumentDB/mongoClusters"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientCheckNameAvailabilityResponse{ + // CheckNameAvailabilityResponse: &armmongocluster.CheckNameAvailabilityResponse{ + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr(armmongocluster.CheckNameAvailabilityReasonAlreadyExists), + // Message: to.Ptr("Cluster name 'existingmongocluster' is already in use."), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_Create.json +func ExampleMongoClustersClient_BeginCreateOrUpdate_createsANewMongoClusterResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginCreateOrUpdate(ctx, "TestResourceGroup", "myMongoCluster", armmongocluster.MongoCluster{ + Location: to.Ptr("westus2"), + Properties: &armmongocluster.Properties{ + Administrator: &armmongocluster.AdministratorProperties{ + UserName: to.Ptr("mongoAdmin"), + Password: to.Ptr("password"), + }, + ServerVersion: to.Ptr("5.0"), + Storage: &armmongocluster.StorageProperties{ + SizeGb: to.Ptr[int64](128), + }, + Compute: &armmongocluster.ComputeProperties{ + Tier: to.Ptr("M30"), + }, + Sharding: &armmongocluster.ShardingProperties{ + ShardCount: to.Ptr[int32](1), + }, + HighAvailability: &armmongocluster.HighAvailabilityProperties{ + TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientCreateOrUpdateResponse{ + // MongoCluster: &armmongocluster.MongoCluster{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](128), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](1), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_CreateGeoReplica.json +func ExampleMongoClustersClient_BeginCreateOrUpdate_createsAReplicaMongoClusterResourceFromASourceResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginCreateOrUpdate(ctx, "TestResourceGroup", "myReplicaMongoCluster", armmongocluster.MongoCluster{ + Location: to.Ptr("centralus"), + Properties: &armmongocluster.Properties{ + CreateMode: to.Ptr(armmongocluster.CreateModeGeoReplica), + ReplicaParameters: &armmongocluster.ReplicaParameters{ + SourceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/mySourceMongoCluster"), + SourceLocation: to.Ptr("eastus"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientCreateOrUpdateResponse{ + // MongoCluster: &armmongocluster.MongoCluster{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myReplicaMongoCluster"), + // Name: to.Ptr("myReplicaMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](128), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](3), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // to.Ptr(armmongocluster.PreviewFeatureGeoReplicas), + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myReplicaMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // Role: to.Ptr(armmongocluster.ReplicationRoleGeoAsyncReplica), + // SourceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/mySourceMongoCluster"), + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateProvisioning), + // }, + // }, + // Location: to.Ptr("centralus"), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_CreatePITR.json +func ExampleMongoClustersClient_BeginCreateOrUpdate_createsAMongoClusterResourceFromAPointInTimeRestore() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginCreateOrUpdate(ctx, "TestResourceGroup", "myMongoCluster", armmongocluster.MongoCluster{ + Location: to.Ptr("westus2"), + Properties: &armmongocluster.Properties{ + CreateMode: to.Ptr(armmongocluster.CreateModePointInTimeRestore), + RestoreParameters: &armmongocluster.RestoreParameters{ + PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-13T20:07:35Z"); return t }()), + SourceResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myOtherMongoCluster"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientCreateOrUpdateResponse{ + // MongoCluster: &armmongocluster.MongoCluster{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](128), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](1), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_Delete.json +func ExampleMongoClustersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginDelete(ctx, "TestResourceGroup", "myMongoCluster", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-07-01/MongoClusters_Get.json +func ExampleMongoClustersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMongoClustersClient().Get(ctx, "TestResourceGroup", "myMongoCluster", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientGetResponse{ + // MongoCluster: &armmongocluster.MongoCluster{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // Tags: map[string]*string{ + // "additionalProp1": to.Ptr("string"), + // "additionalProp2": to.Ptr("string"), + // "additionalProp3": to.Ptr("string"), + // }, + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](128), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](4), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_List.json +func ExampleMongoClustersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMongoClustersClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armmongocluster.MongoClustersClientListResponse{ + // ListResult: armmongocluster.ListResult{ + // Value: []*armmongocluster.MongoCluster{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // Tags: map[string]*string{ + // "additionalProp1": to.Ptr("string"), + // "additionalProp2": to.Ptr("string"), + // "additionalProp3": to.Ptr("string"), + // }, + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](128), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](4), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster2"), + // Name: to.Ptr("myMongoCluster2"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // Tags: map[string]*string{ + // "additionalProp1": to.Ptr("string"), + // }, + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user2"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](256), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M40"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](2), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("1.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("eastus"), + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-07-01/MongoClusters_ListByResourceGroup.json +func ExampleMongoClustersClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMongoClustersClient().NewListByResourceGroupPager("TestResourceGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armmongocluster.MongoClustersClientListByResourceGroupResponse{ + // ListResult: armmongocluster.ListResult{ + // Value: []*armmongocluster.MongoCluster{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // Tags: map[string]*string{ + // "additionalProp1": to.Ptr("string"), + // "additionalProp2": to.Ptr("string"), + // "additionalProp3": to.Ptr("string"), + // }, + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](128), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](4), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster2"), + // Name: to.Ptr("myMongoCluster2"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // Tags: map[string]*string{ + // "additionalProp1": to.Ptr("string"), + // }, + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user2"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](256), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M40"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](2), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("1.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster2.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("eastus"), + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-07-01/MongoClusters_ListConnectionStrings.json +func ExampleMongoClustersClient_ListConnectionStrings() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMongoClustersClient().ListConnectionStrings(ctx, "TestGroup", "myMongoCluster", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientListConnectionStringsResponse{ + // ListConnectionStringsResult: &armmongocluster.ListConnectionStringsResult{ + // ConnectionStrings: []*armmongocluster.ConnectionString{ + // { + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Description: to.Ptr("default connection string"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_ForcePromoteReplica.json +func ExampleMongoClustersClient_BeginPromote() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginPromote(ctx, "TestGroup", "myMongoCluster", armmongocluster.PromoteReplicaRequest{ + PromoteOption: to.Ptr(armmongocluster.PromoteOptionForced), + Mode: to.Ptr(armmongocluster.PromoteModeSwitchover), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-07-01/MongoClusters_PatchDiskSize.json +func ExampleMongoClustersClient_BeginUpdate_updatesTheDiskSizeOnAMongoClusterResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginUpdate(ctx, "TestResourceGroup", "myMongoCluster", armmongocluster.Update{ + Properties: &armmongocluster.UpdateProperties{ + Storage: &armmongocluster.StorageProperties{ + SizeGb: to.Ptr[int64](256), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientUpdateResponse{ + // MongoCluster: &armmongocluster.MongoCluster{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](256), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](4), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_PatchPrivateNetworkAccess.json +func ExampleMongoClustersClient_BeginUpdate_disablesPublicNetworkAccessOnAMongoClusterResourceWithAPrivateEndpointConnection() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginUpdate(ctx, "TestResourceGroup", "myMongoCluster", armmongocluster.Update{ + Properties: &armmongocluster.UpdateProperties{ + PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessDisabled), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientUpdateResponse{ + // MongoCluster: &armmongocluster.MongoCluster{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](256), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](4), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PrivateEndpointConnections: []*armmongocluster.PrivateEndpointConnection{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/privateEndpointConnections/mymongocluster-pe.ffffffff-ffff-ffff-ffff-ffffffffffff"), + // SystemData: &armmongocluster.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-06T04:00:25.0509765Z"); return t}()), + // CreatedBy: to.Ptr("ffffffff-ffff-ffff-ffff-ffffffffffff"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-06T04:00:25.0509765Z"); return t}()), + // LastModifiedBy: to.Ptr("ffffffff-ffff-ffff-ffff-ffffffffffff"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeApplication), + // }, + // Properties: &armmongocluster.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armmongocluster.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.Network/privateEndpoints/mymongocluster-pe"), + // }, + // GroupIDs: []*string{ + // to.Ptr("MongoCluster"), + // }, + // PrivateLinkServiceConnectionState: &armmongocluster.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armmongocluster.PrivateEndpointServiceConnectionStatusApproved), + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr("None"), + // }, + // }, + // }, + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessDisabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_ResetPassword.json +func ExampleMongoClustersClient_BeginUpdate_resetsTheAdministratorLoginPassword() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginUpdate(ctx, "TestResourceGroup", "myMongoCluster", armmongocluster.Update{ + Properties: &armmongocluster.UpdateProperties{ + Administrator: &armmongocluster.AdministratorProperties{ + UserName: to.Ptr("mongoAdmin"), + Password: to.Ptr("password"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientUpdateResponse{ + // MongoCluster: &armmongocluster.MongoCluster{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](256), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M30"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](4), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_Update.json +func ExampleMongoClustersClient_BeginUpdate_updatesAMongoClusterResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMongoClustersClient().BeginUpdate(ctx, "TestResourceGroup", "myMongoCluster", armmongocluster.Update{ + Properties: &armmongocluster.UpdateProperties{ + Administrator: &armmongocluster.AdministratorProperties{ + UserName: to.Ptr("mongoAdmin"), + }, + ServerVersion: to.Ptr("5.0"), + Storage: &armmongocluster.StorageProperties{ + SizeGb: to.Ptr[int64](256), + }, + Compute: &armmongocluster.ComputeProperties{ + Tier: to.Ptr("M50"), + }, + Sharding: &armmongocluster.ShardingProperties{ + ShardCount: to.Ptr[int32](4), + }, + HighAvailability: &armmongocluster.HighAvailabilityProperties{ + TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + }, + PreviewFeatures: []*armmongocluster.PreviewFeature{}, + PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.MongoClustersClientUpdateResponse{ + // MongoCluster: &armmongocluster.MongoCluster{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster"), + // Name: to.Ptr("myMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // SystemData: &armmongocluster.SystemData{ + // CreatedBy: to.Ptr("user1"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("user2"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), + // }, + // Properties: &armmongocluster.Properties{ + // ProvisioningState: to.Ptr(armmongocluster.ProvisioningStateSucceeded), + // Administrator: &armmongocluster.AdministratorProperties{ + // UserName: to.Ptr("mongoAdmin"), + // }, + // ServerVersion: to.Ptr("5.0"), + // Storage: &armmongocluster.StorageProperties{ + // SizeGb: to.Ptr[int64](256), + // }, + // Compute: &armmongocluster.ComputeProperties{ + // Tier: to.Ptr("M50"), + // }, + // Sharding: &armmongocluster.ShardingProperties{ + // ShardCount: to.Ptr[int32](4), + // }, + // HighAvailability: &armmongocluster.HighAvailabilityProperties{ + // TargetMode: to.Ptr(armmongocluster.HighAvailabilityModeSameZone), + // }, + // Backup: &armmongocluster.BackupProperties{ + // EarliestRestoreTime: to.Ptr("2023-01-13T20:07:35Z"), + // }, + // PreviewFeatures: []*armmongocluster.PreviewFeature{ + // }, + // InfrastructureVersion: to.Ptr("2.0"), + // PublicNetworkAccess: to.Ptr(armmongocluster.PublicNetworkAccessEnabled), + // ConnectionString: to.Ptr("mongodb+srv://:@myMongoCluster.mongocluster.cosmos.azure.com"), + // Replica: &armmongocluster.ReplicationProperties{ + // ReplicationState: to.Ptr(armmongocluster.ReplicationStateActive), + // Role: to.Ptr(armmongocluster.ReplicationRolePrimary), + // }, + // }, + // Location: to.Ptr("westus2"), + // }, + // } +} diff --git a/packages/typespec-go/test/armmongocluster/zz_operations_client_example_test.go b/packages/typespec-go/test/armmongocluster/zz_operations_client_example_test.go new file mode 100644 index 000000000..babdc40ef --- /dev/null +++ b/packages/typespec-go/test/armmongocluster/zz_operations_client_example_test.go @@ -0,0 +1,61 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armmongocluster_test + +import ( + "armmongocluster" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-01/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armmongocluster.OperationsClientListResponse{ + // OperationListResult: armmongocluster.OperationListResult{ + // Value: []*armmongocluster.Operation{ + // { + // Name: to.Ptr("Microsoft.DocumentDB/mongoClusters/read"), + // Display: &armmongocluster.OperationDisplay{ + // Provider: to.Ptr("Microsoft.DocumentDB"), + // Resource: to.Ptr("Mongo Cluster"), + // Operation: to.Ptr("Read Mongo Clusters"), + // Description: to.Ptr("Reads a Mongo Cluster or list all Mongo Clusters."), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.DocumentDB/mongoClusters/write"), + // Display: &armmongocluster.OperationDisplay{ + // Provider: to.Ptr("Microsoft.DocumentDB"), + // Resource: to.Ptr("Mongo Cluster"), + // Operation: to.Ptr("Create or Update Mongo Cluster"), + // Description: to.Ptr("Create or Update the properties or tags of the specified Mongo Cluster."), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armmongocluster/zz_privateendpointconnections_client_example_test.go b/packages/typespec-go/test/armmongocluster/zz_privateendpointconnections_client_example_test.go new file mode 100644 index 000000000..7dbb68974 --- /dev/null +++ b/packages/typespec-go/test/armmongocluster/zz_privateendpointconnections_client_example_test.go @@ -0,0 +1,201 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armmongocluster_test + +import ( + "armmongocluster" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionPut.json +func ExamplePrivateEndpointConnectionsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginCreate(ctx, "TestGroup", "myMongoCluster", "pecTest", armmongocluster.PrivateEndpointConnectionResource{ + Properties: &armmongocluster.PrivateEndpointConnectionProperties{ + PrivateLinkServiceConnectionState: &armmongocluster.PrivateLinkServiceConnectionState{ + Status: to.Ptr(armmongocluster.PrivateEndpointServiceConnectionStatusApproved), + Description: to.Ptr("Auto-Approved"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.PrivateEndpointConnectionsClientCreateResponse{ + // PrivateEndpointConnectionResource: &armmongocluster.PrivateEndpointConnectionResource{ + // Name: to.Ptr("pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/privateEndpointConnections/pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"), + // Type: to.Ptr("Microsoft.DocumentDB/mongoClusters/privateEndpointConnections"), + // SystemData: &armmongocluster.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-09T05:51:31.1386869Z"); return t}()), + // CreatedBy: to.Ptr("2df9eb86-36b5-49dc-86ae-9a63135bfa8c"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-09T05:51:31.1386869Z"); return t}()), + // LastModifiedBy: to.Ptr("2ff9eb86-36b5-49dc-86ae-9a63135bfa8c"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeApplication), + // }, + // Properties: &armmongocluster.PrivateEndpointConnectionProperties{ + // ProvisioningState: to.Ptr(armmongocluster.PrivateEndpointConnectionProvisioningStateSucceeded), + // PrivateEndpoint: &armmongocluster.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/privateEndpoints/pecTest"), + // }, + // GroupIDs: []*string{ + // to.Ptr("MongoCluster"), + // }, + // PrivateLinkServiceConnectionState: &armmongocluster.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armmongocluster.PrivateEndpointServiceConnectionStatusApproved), + // Description: to.Ptr("Approved by admin"), + // ActionsRequired: to.Ptr("None"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionDelete.json +func ExamplePrivateEndpointConnectionsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginDelete(ctx, "TestGroup", "myMongoCluster", "pecTest.5d393f64-ef64-46d0-9959-308321c44ac0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionGet.json +func ExamplePrivateEndpointConnectionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "TestGroup", "myMongoCluster", "pecTest.5d393f64-ef64-46d0-9959-308321c44ac0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armmongocluster.PrivateEndpointConnectionsClientGetResponse{ + // PrivateEndpointConnectionResource: &armmongocluster.PrivateEndpointConnectionResource{ + // Name: to.Ptr("pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/privateEndpointConnections/pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"), + // Type: to.Ptr("Microsoft.DocumentDB/mongoClusters/privateEndpointConnections"), + // SystemData: &armmongocluster.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-09T05:51:31.1386869Z"); return t}()), + // CreatedBy: to.Ptr("2df9eb86-36b5-49dc-86ae-9a63135bfa8c"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-09T05:51:31.1386869Z"); return t}()), + // LastModifiedBy: to.Ptr("2ff9eb86-36b5-49dc-86ae-9a63135bfa8c"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeApplication), + // }, + // Properties: &armmongocluster.PrivateEndpointConnectionProperties{ + // ProvisioningState: to.Ptr(armmongocluster.PrivateEndpointConnectionProvisioningStateSucceeded), + // PrivateEndpoint: &armmongocluster.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/privateEndpoints/pecTest"), + // }, + // GroupIDs: []*string{ + // to.Ptr("MongoCluster"), + // }, + // PrivateLinkServiceConnectionState: &armmongocluster.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armmongocluster.PrivateEndpointServiceConnectionStatusApproved), + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr("None"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionList.json +func ExamplePrivateEndpointConnectionsClient_NewListByMongoClusterPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListByMongoClusterPager("TestGroup", "myMongoCluster", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armmongocluster.PrivateEndpointConnectionsClientListByMongoClusterResponse{ + // PrivateEndpointConnectionResourceListResult: armmongocluster.PrivateEndpointConnectionResourceListResult{ + // Value: []*armmongocluster.PrivateEndpointConnectionResource{ + // { + // Name: to.Ptr("pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/privateEndpointConnections/pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"), + // Type: to.Ptr("Microsoft.DocumentDB/mongoClusters/privateEndpointConnections"), + // SystemData: &armmongocluster.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-09T05:51:31.1386869Z"); return t}()), + // CreatedBy: to.Ptr("2df9eb86-36b5-49dc-86ae-9a63135bfa8c"), + // CreatedByType: to.Ptr(armmongocluster.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-09T05:51:31.1386869Z"); return t}()), + // LastModifiedBy: to.Ptr("2ff9eb86-36b5-49dc-86ae-9a63135bfa8c"), + // LastModifiedByType: to.Ptr(armmongocluster.CreatedByTypeApplication), + // }, + // Properties: &armmongocluster.PrivateEndpointConnectionProperties{ + // ProvisioningState: to.Ptr(armmongocluster.PrivateEndpointConnectionProvisioningStateSucceeded), + // PrivateEndpoint: &armmongocluster.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/privateEndpoints/pecTest"), + // }, + // GroupIDs: []*string{ + // to.Ptr("MongoCluster"), + // }, + // PrivateLinkServiceConnectionState: &armmongocluster.PrivateLinkServiceConnectionState{ + // Status: to.Ptr(armmongocluster.PrivateEndpointServiceConnectionStatusApproved), + // Description: to.Ptr("Auto-approved"), + // ActionsRequired: to.Ptr("None"), + // }, + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armmongocluster/zz_privatelinks_client_example_test.go b/packages/typespec-go/test/armmongocluster/zz_privatelinks_client_example_test.go new file mode 100644 index 000000000..14983ed3e --- /dev/null +++ b/packages/typespec-go/test/armmongocluster/zz_privatelinks_client_example_test.go @@ -0,0 +1,57 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armmongocluster_test + +import ( + "armmongocluster" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-01/MongoClusters_PrivateLinkResourceList.json +func ExamplePrivateLinksClient_NewListByMongoClusterPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPrivateLinksClient().NewListByMongoClusterPager("TestGroup", "myMongoCluster", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armmongocluster.PrivateLinksClientListByMongoClusterResponse{ + // PrivateLinkResourceListResult: armmongocluster.PrivateLinkResourceListResult{ + // Value: []*armmongocluster.PrivateLinkResource{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DocumentDB/mongoClusters/myMongoCluster/privateLinkResources/MongoCluster"), + // Name: to.Ptr("MongoCluster"), + // Type: to.Ptr("Microsoft.DocumentDB/mongoClusters/privateLinkResources"), + // Properties: &armmongocluster.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("MongoCluster"), + // RequiredMembers: []*string{ + // to.Ptr("c.p7ex3v2euquypn"), + // }, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.mongocluster.cosmos.azure.com"), + // }, + // }, + // }, + // }, + // }, + // } + } +} diff --git a/packages/typespec-go/test/armmongocluster/zz_replicas_client_example_test.go b/packages/typespec-go/test/armmongocluster/zz_replicas_client_example_test.go new file mode 100644 index 000000000..2970d7c6e --- /dev/null +++ b/packages/typespec-go/test/armmongocluster/zz_replicas_client_example_test.go @@ -0,0 +1,50 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armmongocluster_test + +import ( + "armmongocluster" + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "log" +) + +// Generated from example definition: 2024-07-01/MongoClusters_ReplicaList.json +func ExampleReplicasClient_NewListByParentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongocluster.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewReplicasClient().NewListByParentPager("TestGroup", "myMongoCluster", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armmongocluster.ReplicasClientListByParentResponse{ + // ReplicaListResult: armmongocluster.ReplicaListResult{ + // Value: []*armmongocluster.Replica{ + // { + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myReplicaMongoCluster"), + // Name: to.Ptr("myReplicaMongoCluster"), + // Type: to.Ptr("/Microsoft.DocumentDB/mongoClusters"), + // Properties: &armmongocluster.Properties{ + // }, + // }, + // }, + // }, + // } + } +}