Skip to content

Commit

Permalink
azurerm_cosmosdb_cassandra_cluster - support for the `HoursBetweenB…
Browse files Browse the repository at this point in the history
…ackups` property (#18154)

`azurerm_cosmosdb_cassandra_cluster` - support for the `HoursBetweenBackups` property
  • Loading branch information
neil-yechenwei authored Aug 31, 2022
1 parent b1f893f commit 68072d7
Show file tree
Hide file tree
Showing 41 changed files with 2,110 additions and 86 deletions.
5 changes: 3 additions & 2 deletions internal/services/cosmos/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package client

import (
"github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb"
"github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/managedcassandras"
"github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/sqldedicatedgateway"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

type Client struct {
CassandraClient *documentdb.CassandraResourcesClient
CassandraClustersClient *documentdb.CassandraClustersClient
CassandraClustersClient *managedcassandras.ManagedCassandrasClient
CassandraDatacentersClient *documentdb.CassandraDataCentersClient
DatabaseClient *documentdb.DatabaseAccountsClient
GremlinClient *documentdb.GremlinResourcesClient
Expand All @@ -25,7 +26,7 @@ func NewClient(o *common.ClientOptions) *Client {
cassandraClient := documentdb.NewCassandraResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&cassandraClient.Client, o.ResourceManagerAuthorizer)

cassandraClustersClient := documentdb.NewCassandraClustersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
cassandraClustersClient := managedcassandras.NewManagedCassandrasClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&cassandraClustersClient.Client, o.ResourceManagerAuthorizer)

cassandraDatacentersClient := documentdb.NewCassandraDataCentersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
Expand Down
174 changes: 94 additions & 80 deletions internal/services/cosmos/cosmosdb_cassandra_cluster_resource.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/managedcassandras"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down Expand Up @@ -87,17 +87,17 @@ func testAccCassandraCluster_update(t *testing.T) {
}

func (t CassandraClusterResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.CassandraClusterID(state.ID)
id, err := managedcassandras.ParseCassandraClusterID(state.ID)
if err != nil {
return nil, err
}

resp, err := clients.Cosmos.CassandraClustersClient.Get(ctx, id.ResourceGroup, id.Name)
resp, err := clients.Cosmos.CassandraClustersClient.CassandraClustersGet(ctx, *id)
if err != nil {
return nil, fmt.Errorf("reading %q: %+v", id, err)
}

return utils.Bool(resp.ID != nil), nil
return utils.Bool(resp.Model != nil), nil
}

func (r CassandraClusterResource) basic(data acceptance.TestData) string {
Expand Down Expand Up @@ -133,6 +133,7 @@ resource "azurerm_cosmosdb_cassandra_cluster" "test" {
client_certificate_pems = [file("testdata/cert.pem")]
external_gossip_certificate_pems = [file("testdata/cert.pem")]
external_seed_node_ip_addresses = ["10.52.221.2"]
hours_between_backups = 22
identity {
type = "SystemAssigned"
Expand Down Expand Up @@ -164,6 +165,7 @@ resource "azurerm_cosmosdb_cassandra_cluster" "test" {
client_certificate_pems = [file("testdata/cert2.pem")]
external_gossip_certificate_pems = [file("testdata/cert2.pem")]
external_seed_node_ip_addresses = ["10.52.221.5"]
hours_between_backups = 0
tags = {
Env = "Test2"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 68072d7

Please sign in to comment.