Skip to content

Commit

Permalink
MongoDB support attribute auto_renew_length
Browse files Browse the repository at this point in the history
  • Loading branch information
tamperMonkeyZQ committed May 6, 2024
1 parent 9dc34aa commit 3c9d4ef
Show file tree
Hide file tree
Showing 19 changed files with 177 additions and 84 deletions.
20 changes: 20 additions & 0 deletions baiducloud/flex/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ func SchemaReservationLength() *schema.Schema {
}
}

func SchemaAutoRenewLength() *schema.Schema {
return &schema.Schema{
Type: schema.TypeInt,
Description: "The automatic renewal time (month). Effective when `payment_timing` is `Prepaid`. " +
"Valid values: `1`~`9`, `12`, `24`, `36`. Defaults to `1`.",
Optional: true,
ForceNew: true,
ValidateFunc: ValidateReservationLength(),
}
}

func SchemaAutoRenewTimeUnit() *schema.Schema {
return &schema.Schema{
Type: schema.TypeString,
Description: "Auto renew time unit, currently only supports monthly.",
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"month"}, false),
}
}
func ValidatePaymentTiming() schema.SchemaValidateFunc {
return validation.StringInSlice([]string{PaymentTimingPostpaid, PaymentTimingPrepaid}, false)
}
Expand Down
10 changes: 6 additions & 4 deletions baiducloud/service/mongodb/instance_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ func basicResourceInstanceSchema() map[string]*schema.Schema {
},
"payment_timing": flex.SchemaPaymentTiming(),
"reservation_length": flex.SchemaReservationLength(),
"vpc_id": flex.SchemaVpcID(),
"subnets": flex.SchemaSubnets(),
"tags": flex.SchemaTagsOnlySupportCreation(),
"resource_group_id": flex.SchemaResourceGroupID(),
"auto_renew_length": flex.SchemaAutoRenewLength(),
//"auto_renew_time_unit": flex.SchemaAutoRenewTimeUnit(),
"vpc_id": flex.SchemaVpcID(),
"subnets": flex.SchemaSubnets(),
"tags": flex.SchemaTagsOnlySupportCreation(),
"resource_group_id": flex.SchemaResourceGroupID(),
"storage_engine": {
Type: schema.TypeString,
Description: "Storage engine of the instance. Valid values: `WiredTiger`.",
Expand Down
7 changes: 7 additions & 0 deletions baiducloud/service/mongodb/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ func buildCreationArgs(d *schema.ResourceData) *mongodb.CreateReplicaArgs {
ReservationTimeUnit: "month",
}
billing.Reservation = reservation
if v, ok := d.GetOk("auto_renew_length"); ok {
autoRenew := mongodb.AutoRenewModel{
AutoRenewLength: v.(int),
AutoRenewTimeUnit: "month",
}
billing.AutoRenew = autoRenew
}
}
args := &mongodb.CreateReplicaArgs{
Billing: billing,
Expand Down
7 changes: 7 additions & 0 deletions baiducloud/service/mongodb/resource_sharding_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ func buildShardingCreationArgs(d *schema.ResourceData) *mongodb.CreateShardingAr
ReservationTimeUnit: "month",
}
billing.Reservation = reservation
if v, ok := d.GetOk("auto_renew_length"); ok {
autoRenew := mongodb.AutoRenewModel{
AutoRenewLength: v.(int),
AutoRenewTimeUnit: "month",
}
billing.AutoRenew = autoRenew
}
}
args := &mongodb.CreateShardingArgs{
Billing: billing,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/terraform-providers/terraform-provider-baiducloud

require (
github.com/baidubce/bce-sdk-go v0.9.176
github.com/baidubce/bce-sdk-go v0.9.177
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/vault v0.10.4
github.com/mitchellh/go-homedir v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY
github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM=
github.com/aws/aws-sdk-go v1.37.0 h1:GzFnhOIsrGyQ69s7VgqtrG2BG8v7X7vwB3Xpbd/DBBk=
github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/baidubce/bce-sdk-go v0.9.176 h1:TOge9h5E95P1bONejSewus22aBTlKtHqgaHzD85yMIU=
github.com/baidubce/bce-sdk-go v0.9.176/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg=
github.com/baidubce/bce-sdk-go v0.9.177 h1:jtt5ZRPOlvikw6rTqGSyJtgqyOo6Ht8Dqr1giZYxwlk=
github.com/baidubce/bce-sdk-go v0.9.177/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/baidubce/bce-sdk-go/bce/config.go

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

81 changes: 44 additions & 37 deletions vendor/github.com/baidubce/bce-sdk-go/services/eip/model.go

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

10 changes: 8 additions & 2 deletions vendor/github.com/baidubce/bce-sdk-go/services/mongodb/model.go

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.

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

10 changes: 10 additions & 0 deletions vendor/github.com/baidubce/bce-sdk-go/services/resmanager/model.go

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.

20 changes: 11 additions & 9 deletions vendor/github.com/baidubce/bce-sdk-go/services/vpc/model.go

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

Loading

0 comments on commit 3c9d4ef

Please sign in to comment.