Skip to content

Commit a832086

Browse files
Sync monorepo state at "Adding is_autogenerated to access policy model and using it to hide autogenerated policies for accessors and mutators" (#72)
Syncing from userclouds/userclouds@b7088ec50c0a729b9cd5b2787b6014161a019253
1 parent 4a49df6 commit a832086

File tree

3 files changed

+47
-18
lines changed

3 files changed

+47
-18
lines changed

docs/resources/access_policy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Manages a Tokenizer access policy. For more details, refer to the [access policy
2424

2525
- `components` (Attributes List) (see [below for nested schema](#nestedatt--components))
2626
- `description` (String)
27+
- `is_autogenerated` (Boolean) Whether this policy is autogenerated from an accessor or mutator.
2728
- `tag_ids` (List of String)
2829

2930
### Read-Only

internal/provider/tokenizer/schemas_generated.go

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,26 @@ func PaginationCursorJSONClientModelToTF(in *PaginationCursorJSONClientModel) (P
5959

6060
// PolicyAccessPolicyTFModel is a Terraform model struct for the PolicyAccessPolicyAttributes schema.
6161
type PolicyAccessPolicyTFModel struct {
62-
Components types.List `tfsdk:"components"`
63-
Description types.String `tfsdk:"description"`
64-
ID types.String `tfsdk:"id"`
65-
Name types.String `tfsdk:"name"`
66-
PolicyType types.String `tfsdk:"policy_type"`
67-
TagIds types.List `tfsdk:"tag_ids"`
68-
Version types.Int64 `tfsdk:"version"`
62+
Components types.List `tfsdk:"components"`
63+
Description types.String `tfsdk:"description"`
64+
ID types.String `tfsdk:"id"`
65+
IsAutogenerated types.Bool `tfsdk:"is_autogenerated"`
66+
Name types.String `tfsdk:"name"`
67+
PolicyType types.String `tfsdk:"policy_type"`
68+
TagIds types.List `tfsdk:"tag_ids"`
69+
Version types.Int64 `tfsdk:"version"`
6970
}
7071

7172
// PolicyAccessPolicyJSONClientModel stores data for use with jsonclient for making API requests.
7273
type PolicyAccessPolicyJSONClientModel struct {
73-
Components *[]PolicyAccessPolicyComponentJSONClientModel `json:"components,omitempty"`
74-
Description *string `json:"description,omitempty"`
75-
ID *uuid.UUID `json:"id,omitempty"`
76-
Name *string `json:"name,omitempty"`
77-
PolicyType *string `json:"policy_type,omitempty"`
78-
TagIds *[]uuid.UUID `json:"tag_ids,omitempty"`
79-
Version *int64 `json:"version,omitempty"`
74+
Components *[]PolicyAccessPolicyComponentJSONClientModel `json:"components,omitempty"`
75+
Description *string `json:"description,omitempty"`
76+
ID *uuid.UUID `json:"id,omitempty"`
77+
IsAutogenerated *bool `json:"is_autogenerated,omitempty"`
78+
Name *string `json:"name,omitempty"`
79+
PolicyType *string `json:"policy_type,omitempty"`
80+
TagIds *[]uuid.UUID `json:"tag_ids,omitempty"`
81+
Version *int64 `json:"version,omitempty"`
8082
}
8183

8284
// PolicyAccessPolicyAttrTypes defines the attribute types for the PolicyAccessPolicyAttributes schema.
@@ -86,10 +88,11 @@ var PolicyAccessPolicyAttrTypes = map[string]attr.Type{
8688
AttrTypes: PolicyAccessPolicyComponentAttrTypes,
8789
},
8890
},
89-
"description": types.StringType,
90-
"id": types.StringType,
91-
"name": types.StringType,
92-
"policy_type": types.StringType,
91+
"description": types.StringType,
92+
"id": types.StringType,
93+
"is_autogenerated": types.BoolType,
94+
"name": types.StringType,
95+
"policy_type": types.StringType,
9396
"tag_ids": types.ListType{
9497
ElemType: types.StringType,
9598
},
@@ -128,6 +131,12 @@ var PolicyAccessPolicyAttributes = map[string]schema.Attribute{
128131
stringplanmodifier.UseStateForUnknown(),
129132
},
130133
},
134+
"is_autogenerated": schema.BoolAttribute{
135+
Computed: true,
136+
Description: "Whether this policy is autogenerated from an accessor or mutator.",
137+
MarkdownDescription: "Whether this policy is autogenerated from an accessor or mutator.",
138+
Optional: true,
139+
},
131140
"name": schema.StringAttribute{
132141
Description: "",
133142
MarkdownDescription: "",
@@ -223,6 +232,16 @@ func PolicyAccessPolicyTFModelToJSONClient(in *PolicyAccessPolicyTFModel) (*Poli
223232
if err != nil {
224233
return nil, ucerr.Errorf("failed to convert \"id\" field: %+v", err)
225234
}
235+
out.IsAutogenerated, err = func(val *types.Bool) (*bool, error) {
236+
if val.IsNull() || val.IsUnknown() {
237+
return nil, nil
238+
}
239+
converted := val.ValueBool()
240+
return &converted, nil
241+
}(&in.IsAutogenerated)
242+
if err != nil {
243+
return nil, ucerr.Errorf("failed to convert \"is_autogenerated\" field: %+v", err)
244+
}
226245
out.Name, err = func(val *types.String) (*string, error) {
227246
if val.IsNull() || val.IsUnknown() {
228247
return nil, nil
@@ -349,6 +368,12 @@ func PolicyAccessPolicyJSONClientModelToTF(in *PolicyAccessPolicyJSONClientModel
349368
if err != nil {
350369
return PolicyAccessPolicyTFModel{}, ucerr.Errorf("failed to convert \"id\" field: %+v", err)
351370
}
371+
out.IsAutogenerated, err = func(val *bool) (types.Bool, error) {
372+
return types.BoolPointerValue(val), nil
373+
}(in.IsAutogenerated)
374+
if err != nil {
375+
return PolicyAccessPolicyTFModel{}, ucerr.Errorf("failed to convert \"is_autogenerated\" field: %+v", err)
376+
}
352377
out.Name, err = func(val *string) (types.String, error) {
353378
return types.StringPointerValue(val), nil
354379
}(in.Name)

openapi/tokenizer.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,9 @@ components:
784784
type: string
785785
id:
786786
$ref: '#/components/schemas/UuidUUID'
787+
is_autogenerated:
788+
description: Whether this policy is autogenerated from an accessor or mutator.
789+
type: boolean
787790
is_system:
788791
description: Whether this policy is a system policy. System policies cannot
789792
be deleted or modified. This property cannot be changed.

0 commit comments

Comments
 (0)