Skip to content

Commit 1454202

Browse files
committed
Move Enterprise ID from org request to computed attribute
1 parent bc101ad commit 1454202

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

docs/resources/enterprise_org.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ resource "astra_enterprise_org" "entorg" {
2929

3030
- `admin_user_id` (String) UUID of the Astra user that will be the admin of the organization
3131
- `email` (String) Organization email address
32-
- `enterprise_id` (String) UUID of the Enterprise under which the organization should be created
3332
- `name` (String) Organization name
3433

3534
### Read-Only
3635

3736
- `created_at` (String) The timestamp when the organization was created.
37+
- `enterprise_id` (String) UUID of the Enterprise under which the organization is created
3838
- `id` (String) The ID of this resource.
3939
- `last_modified` (String) The timestamp when the organization was last modified.
4040
- `organization_group_id` (String) The group ID (UUID) of the organization.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.21
55
toolchain go1.22.0
66

77
require (
8-
github.com/datastax/astra-client-go/v2 v2.2.56
8+
github.com/datastax/astra-client-go/v2 v2.2.57
99
github.com/datastax/pulsar-admin-client-go v0.0.0-20230707040954-1a4745e07587
1010
github.com/google/uuid v1.6.0
1111
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
101101
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
102102
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
103103
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
104-
github.com/datastax/astra-client-go/v2 v2.2.56 h1:pB93zYVWDTobjpqRnER0R3LdhAhoPdSKTeYc7/2X2Uw=
105-
github.com/datastax/astra-client-go/v2 v2.2.56/go.mod h1:zxXWuqDkYia7PzFIL3T7RmjChc9LN81UnfI2yB4kE7M=
104+
github.com/datastax/astra-client-go/v2 v2.2.57 h1:B2AvCRqWOVBs536r42TpWht1Jt1k2OLsBABLAfN0iVw=
105+
github.com/datastax/astra-client-go/v2 v2.2.57/go.mod h1:zxXWuqDkYia7PzFIL3T7RmjChc9LN81UnfI2yB4kE7M=
106106
github.com/datastax/pulsar-admin-client-go v0.0.0-20230707040954-1a4745e07587 h1:3jv+O0hWcz3oj3sZ9/Ov9/m1Vaqx8Ql8jp5ZeA13O5A=
107107
github.com/datastax/pulsar-admin-client-go v0.0.0-20230707040954-1a4745e07587/go.mod h1:guL8YZ5gJINN+h5Kmja1AnuzhxLU3sHQL8o/8HYLtqk=
108108
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

internal/provider/resource_enterprise_org.go

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,36 @@ func resourceEnterpriseOrg() *schema.Resource {
4040
Required: true,
4141
ForceNew: true,
4242
},
43+
// Computed
4344
"enterprise_id": {
44-
Description: "UUID of the Enterprise under which the organization should be created",
45+
Description: "UUID of the Enterprise under which the organization is created",
4546
Type: schema.TypeString,
46-
Required: true,
47-
ForceNew: true,
47+
Computed: true,
4848
},
49-
// Computed
5049
"organization_id": {
51-
Description: "The Astra organization ID (UUID) for the created Enterprise organization.",
52-
Type: schema.TypeString,
53-
Computed: true,
50+
Description: "The Astra organization ID (UUID) for the created Enterprise organization.",
51+
Type: schema.TypeString,
52+
Computed: true,
5453
},
5554
"organization_type": {
56-
Description: "The type of the organization.",
57-
Type: schema.TypeString,
58-
Computed: true,
55+
Description: "The type of the organization.",
56+
Type: schema.TypeString,
57+
Computed: true,
5958
},
6059
"organization_group_id": {
61-
Description: "The group ID (UUID) of the organization.",
62-
Type: schema.TypeString,
63-
Computed: true,
60+
Description: "The group ID (UUID) of the organization.",
61+
Type: schema.TypeString,
62+
Computed: true,
6463
},
6564
"created_at": {
66-
Description: "The timestamp when the organization was created.",
67-
Type: schema.TypeString,
68-
Computed: true,
65+
Description: "The timestamp when the organization was created.",
66+
Type: schema.TypeString,
67+
Computed: true,
6968
},
7069
"last_modified": {
71-
Description: "The timestamp when the organization was last modified.",
72-
Type: schema.TypeString,
73-
Computed: true,
70+
Description: "The timestamp when the organization was last modified.",
71+
Type: schema.TypeString,
72+
Computed: true,
7473
},
7574
// TODO: Add MarketPlaceData
7675
},
@@ -83,13 +82,11 @@ func resourceEnterpriseOrgCreate(ctx context.Context, d *schema.ResourceData, me
8382
orgName := d.Get("name").(string)
8483
orgEmail := d.Get("email").(string)
8584
adminUid := d.Get("admin_user_id").(string)
86-
enterpriseId := d.Get("enterprise_id").(string)
8785

8886
orgReq := astra.CreateOrganizationInEnterpriseJSONRequestBody{
8987
Name: orgName,
9088
Email: orgEmail,
9189
AdminUserID: adminUid,
92-
EnterpriseID: enterpriseId,
9390
}
9491

9592
resp, err := client.CreateOrganizationInEnterpriseWithResponse(ctx, orgReq)
@@ -132,7 +129,7 @@ func setEnterpriseOrgData(d *schema.ResourceData, org *astra.CreateOrgInEnterpri
132129
if org == nil {
133130
return errors.New("organization is nil")
134131
}
135-
132+
d.Set("enterprise_id", *org.EnterpriseId)
136133
d.Set("organization_id", *org.OrganizationID)
137134
d.Set("organization_type", *org.OrgType)
138135
d.Set("organization_group_id", *org.OrganizationGroupId)

0 commit comments

Comments
 (0)