diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/CHANGELOG.md b/sdk/resourcemanager/mongocluster/armmongocluster/CHANGELOG.md index a0e8ef9cc4..47629dbbcb 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/CHANGELOG.md +++ b/sdk/resourcemanager/mongocluster/armmongocluster/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.0.1 (2024-10-14) +### Other Changes +- Add examples + ## 1.0.0 (2024-09-27) ### Breaking Changes @@ -55,4 +59,4 @@ The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). -To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/constants.go b/sdk/resourcemanager/mongocluster/armmongocluster/constants.go index 3825305212..8ebb465edc 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/constants.go +++ b/sdk/resourcemanager/mongocluster/armmongocluster/constants.go @@ -6,7 +6,7 @@ package armmongocluster const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster" - moduleVersion = "v1.0.0" + moduleVersion = "v1.0.1" ) // ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/firewallrules_client_example_test.go b/sdk/resourcemanager/mongocluster/armmongocluster/firewallrules_client_example_test.go new file mode 100644 index 0000000000..46b9b0d8cb --- /dev/null +++ b/sdk/resourcemanager/mongocluster/armmongocluster/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 ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster" + "log" +) + +// Generated from example definition: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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/sdk/resourcemanager/mongocluster/armmongocluster/go.mod b/sdk/resourcemanager/mongocluster/armmongocluster/go.mod index 41ef038005..48b9c03c54 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/go.mod +++ b/sdk/resourcemanager/mongocluster/armmongocluster/go.mod @@ -4,11 +4,11 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/mongoclusters_client_example_test.go b/sdk/resourcemanager/mongocluster/armmongocluster/mongoclusters_client_example_test.go new file mode 100644 index 0000000000..5e7f6481eb --- /dev/null +++ b/sdk/resourcemanager/mongocluster/armmongocluster/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 ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster" + "log" + "time" +) + +// Generated from example definition: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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/sdk/resourcemanager/mongocluster/armmongocluster/operations_client_example_test.go b/sdk/resourcemanager/mongocluster/armmongocluster/operations_client_example_test.go new file mode 100644 index 0000000000..560fc23c09 --- /dev/null +++ b/sdk/resourcemanager/mongocluster/armmongocluster/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 ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster" + "log" +) + +// Generated from example definition: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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/sdk/resourcemanager/mongocluster/armmongocluster/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/mongocluster/armmongocluster/privateendpointconnections_client_example_test.go new file mode 100644 index 0000000000..9f27e134b3 --- /dev/null +++ b/sdk/resourcemanager/mongocluster/armmongocluster/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 ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster" + "log" +) + +// Generated from example definition: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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/sdk/resourcemanager/mongocluster/armmongocluster/privatelinks_client_example_test.go b/sdk/resourcemanager/mongocluster/armmongocluster/privatelinks_client_example_test.go new file mode 100644 index 0000000000..70399d79c0 --- /dev/null +++ b/sdk/resourcemanager/mongocluster/armmongocluster/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 ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster" + "log" +) + +// Generated from example definition: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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/sdk/resourcemanager/mongocluster/armmongocluster/replicas_client_example_test.go b/sdk/resourcemanager/mongocluster/armmongocluster/replicas_client_example_test.go new file mode 100644 index 0000000000..30c3f632e5 --- /dev/null +++ b/sdk/resourcemanager/mongocluster/armmongocluster/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 ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster" + "log" +) + +// Generated from example definition: D:/ws/azure-sdk-for-go/sdk/resourcemanager/mongocluster/armmongocluster/TempTypeSpecFiles/DocumentDB.MongoCluster.Management/examples/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{ + // }, + // }, + // }, + // }, + // } + } +} diff --git a/sdk/resourcemanager/mongocluster/armmongocluster/tsp-location.yaml b/sdk/resourcemanager/mongocluster/armmongocluster/tsp-location.yaml index 9b4592dc6d..efed7142ec 100644 --- a/sdk/resourcemanager/mongocluster/armmongocluster/tsp-location.yaml +++ b/sdk/resourcemanager/mongocluster/armmongocluster/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/mongocluster/DocumentDB.MongoCluster.Management -commit: 2a3294803a8df71659e27711e5fbfe4e97826828 +commit: 02ff8f08a132a5a68fcdd48da118e36e5ececc3d repo: Azure/azure-rest-api-specs additionalDirectories: