Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the visible attribute on action properties #89

Merged
merged 9 commits into from
Nov 15, 2023
20 changes: 8 additions & 12 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
---

# generated by https://github.com/hashicorp/terraform-plugin-docs

page_title: "port-labs Provider"
subcategory: ""
description: |-
Interact with Port-labs
Interact with Port-labs
---

# port-labs Provider

[getport.io](https://getport.io)

Interact with Port-labs

<!-- schema generated by tfplugindocs -->

## Schema

### Required

- `client_id` (String) Client ID for Port-labs (environment: `PORT_CLIENT_ID`)
- `secret` (String, Sensitive) Client Secret for Port-labs (environment: `PORT_CLIENT_SECRET`)
<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `base_url` (String) Base URL for Port-labs (environment: `PORT_BASE_URL`)
- `base_url` (String)
- `client_id` (String) Client ID for Port-labs
- `secret` (String, Sensitive) Client Secret for Port-labs
- `token` (String, Sensitive) Token for Port-labs
10 changes: 10 additions & 0 deletions docs/resources/port_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Optional:
- `required` (Boolean) Whether the property is required
- `string_items` (Attributes) The items of the array property (see [below for nested schema](#nestedatt--user_properties--array_props--string_items))
- `title` (String) The title of the property
- `visible` (Boolean) The visibility of the array property
- `visible_jq_query` (String) The visibility condition jq query of the array property

<a id="nestedatt--user_properties--array_props--boolean_items"></a>
### Nested Schema for `user_properties.array_props.boolean_items`
Expand Down Expand Up @@ -217,6 +219,8 @@ Optional:
- `icon` (String) The icon of the property
- `required` (Boolean) Whether the property is required
- `title` (String) The title of the property
- `visible` (Boolean) The visibility of the boolean property
- `visible_jq_query` (String) The visibility condition jq query of the boolean property

<a id="nestedatt--user_properties--boolean_props--dataset"></a>
### Nested Schema for `user_properties.boolean_props.dataset`
Expand Down Expand Up @@ -267,6 +271,8 @@ Optional:
- `minimum` (Number) The max of the number property
- `required` (Boolean) Whether the property is required
- `title` (String) The title of the property
- `visible` (Boolean) The visibility of the number property
- `visible_jq_query` (String) The visibility condition jq query of the number property

<a id="nestedatt--user_properties--number_props--dataset"></a>
### Nested Schema for `user_properties.number_props.dataset`
Expand Down Expand Up @@ -314,6 +320,8 @@ Optional:
- `icon` (String) The icon of the property
- `required` (Boolean) Whether the property is required
- `title` (String) The title of the property
- `visible` (Boolean) The visibility of the object property
- `visible_jq_query` (String) The visibility condition jq query of the object property

<a id="nestedatt--user_properties--object_props--dataset"></a>
### Nested Schema for `user_properties.object_props.dataset`
Expand Down Expand Up @@ -368,6 +376,8 @@ Optional:
- `pattern` (String) The pattern of the string property
- `required` (Boolean) Whether the property is required
- `title` (String) The title of the property
- `visible` (Boolean) The visibility of the string property
- `visible_jq_query` (String) The visibility condition jq query of the string property

<a id="nestedatt--user_properties--string_props--dataset"></a>
### Nested Schema for `user_properties.string_props.dataset`
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/port_team.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Team resource
### Optional

- `description` (String) The description of the team
- `users` (List of String) The users of the team
- `users` (Set of String) The users of the team

### Read-Only

Expand Down
23 changes: 12 additions & 11 deletions internal/cli/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ type (
}
Entity struct {
Meta
Identifier string `json:"identifier,omitempty"`
Title string `json:"title"`
Blueprint string `json:"blueprint"`
Team []string `json:"team,omitempty"`
Properties map[string]interface{} `json:"properties"`
Relations map[string]interface{} `json:"relations"`
Identifier string `json:"identifier,omitempty"`
Title string `json:"title"`
Blueprint string `json:"blueprint"`
Team []string `json:"team,omitempty"`
Properties map[string]any `json:"properties"`
Relations map[string]any `json:"relations"`
// TODO: add the rest of the fields.
}

Expand All @@ -35,7 +35,7 @@ type (
Title *string `json:"title,omitempty"`
Identifier string `json:"identifier,omitempty"`
Items map[string]any `json:"items,omitempty"`
Default interface{} `json:"default,omitempty"`
Default any `json:"default,omitempty"`
Icon *string `json:"icon,omitempty"`
Format *string `json:"format,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
Expand All @@ -47,7 +47,7 @@ type (
Description *string `json:"description,omitempty"`
Blueprint *string `json:"blueprint,omitempty"`
Pattern *string `json:"pattern,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Enum []any `json:"enum,omitempty"`
Spec *string `json:"spec,omitempty"`
SpecAuthentication *SpecAuthentication `json:"specAuthentication,omitempty"`
EnumColors map[string]string `json:"enumColors,omitempty"`
Expand All @@ -58,7 +58,7 @@ type (
Title *string `json:"title,omitempty"`
Identifier string `json:"identifier,omitempty"`
Items map[string]any `json:"items,omitempty"`
Default interface{} `json:"default,omitempty"`
Default any `json:"default,omitempty"`
Icon *string `json:"icon,omitempty"`
Format *string `json:"format,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
Expand All @@ -70,13 +70,14 @@ type (
Description *string `json:"description,omitempty"`
Blueprint *string `json:"blueprint,omitempty"`
Pattern *string `json:"pattern,omitempty"`
Enum interface{} `json:"enum,omitempty"`
Enum any `json:"enum,omitempty"`
Spec *string `json:"spec,omitempty"`
SpecAuthentication *SpecAuthentication `json:"specAuthentication,omitempty"`
EnumColors map[string]string `json:"enumColors,omitempty"`
DependsOn []string `json:"dependsOn,omitempty"`
Dataset *Dataset `json:"dataset,omitempty"`
Encryption *string `json:"encryption,omitempty"`
Visible any `json:"visible,omitempty"`
}

SpecAuthentication struct {
Expand Down Expand Up @@ -104,7 +105,7 @@ type (
Title *string `json:"title,omitempty"`
Identifier string `json:"identifier,omitempty"`
Calculation string `json:"calculation,omitempty"`
Default interface{} `json:"default,omitempty"`
Default any `json:"default,omitempty"`
Icon *string `json:"icon,omitempty"`
Format *string `json:"format,omitempty"`
Description *string `json:"description,omitempty"`
Expand Down
11 changes: 11 additions & 0 deletions port/action/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ func arrayPropResourceToBody(ctx context.Context, d *ActionModel, props map[stri
return err
}

if !prop.Visible.IsNull() {
property.Visible = prop.Visible.ValueBoolPointer()
}

if !prop.VisibleJqQuery.IsNull() {
VisibleJqQueryMap := map[string]string{
"jqQuery": prop.VisibleJqQuery.ValueString(),
}
property.Visible = VisibleJqQueryMap
}

props[propIdentifier] = property
}

Expand Down
11 changes: 11 additions & 0 deletions port/action/boolean.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ func booleanPropResourceToBody(ctx context.Context, d *ActionModel, props map[st
property.Dataset = actionDataSetToPortBody(prop.Dataset)
}

if !prop.Visible.IsNull() {
property.Visible = prop.Visible.ValueBoolPointer()
}

if !prop.VisibleJqQuery.IsNull() {
VisibleJqQueryMap := map[string]string{
"jqQuery": prop.VisibleJqQuery.ValueString(),
}
property.Visible = VisibleJqQueryMap
}

props[propIdentifier] = property
}
if prop.Required.ValueBool() {
Expand Down
61 changes: 38 additions & 23 deletions port/action/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,74 +51,89 @@ type GitlabMethodModel struct {
type StringPropModel struct {
Title types.String `tfsdk:"title"`
Icon types.String `tfsdk:"icon"`
Blueprint types.String `tfsdk:"blueprint"`
Description types.String `tfsdk:"description"`
Default types.String `tfsdk:"default"`
Required types.Bool `tfsdk:"required"`
Format types.String `tfsdk:"format"`
MaxLength types.Int64 `tfsdk:"max_length"`
MinLength types.Int64 `tfsdk:"min_length"`
Pattern types.String `tfsdk:"pattern"`
Enum types.List `tfsdk:"enum"`
DependsOn types.List `tfsdk:"depends_on"`
Dataset *DatasetModel `tfsdk:"dataset"`
DefaultJqQuery types.String `tfsdk:"default_jq_query"`
EnumJqQuery types.String `tfsdk:"enum_jq_query"`
Encryption types.String `tfsdk:"encryption"`
Visible types.Bool `tfsdk:"visible"`
VisibleJqQuery types.String `tfsdk:"visible_jq_query"`

Default types.String `tfsdk:"default"`
Blueprint types.String `tfsdk:"blueprint"`
Format types.String `tfsdk:"format"`
MaxLength types.Int64 `tfsdk:"max_length"`
MinLength types.Int64 `tfsdk:"min_length"`
Pattern types.String `tfsdk:"pattern"`
Enum types.List `tfsdk:"enum"`
EnumJqQuery types.String `tfsdk:"enum_jq_query"`
Encryption types.String `tfsdk:"encryption"`
}

type NumberPropModel struct {
Title types.String `tfsdk:"title"`
Icon types.String `tfsdk:"icon"`
Description types.String `tfsdk:"description"`
Default types.Float64 `tfsdk:"default"`
Required types.Bool `tfsdk:"required"`
Maximum types.Float64 `tfsdk:"maximum"`
Minimum types.Float64 `tfsdk:"minimum"`
Enum types.List `tfsdk:"enum"`
DependsOn types.List `tfsdk:"depends_on"`
Dataset *DatasetModel `tfsdk:"dataset"`
DefaultJqQuery types.String `tfsdk:"default_jq_query"`
EnumJqQuery types.String `tfsdk:"enum_jq_query"`
Visible types.Bool `tfsdk:"visible"`
VisibleJqQuery types.String `tfsdk:"visible_jq_query"`

Default types.Float64 `tfsdk:"default"`
Maximum types.Float64 `tfsdk:"maximum"`
Minimum types.Float64 `tfsdk:"minimum"`
Enum types.List `tfsdk:"enum"`
EnumJqQuery types.String `tfsdk:"enum_jq_query"`
}

type BooleanPropModel struct {
Title types.String `tfsdk:"title"`
Icon types.String `tfsdk:"icon"`
Description types.String `tfsdk:"description"`
Default types.Bool `tfsdk:"default"`
Required types.Bool `tfsdk:"required"`
DependsOn types.List `tfsdk:"depends_on"`
Dataset *DatasetModel `tfsdk:"dataset"`
DefaultJqQuery types.String `tfsdk:"default_jq_query"`
Visible types.Bool `tfsdk:"visible"`
VisibleJqQuery types.String `tfsdk:"visible_jq_query"`

Default types.Bool `tfsdk:"default"`
}

type ArrayPropModel struct {
Title types.String `tfsdk:"title"`
Icon types.String `tfsdk:"icon"`
Description types.String `tfsdk:"description"`
MaxItems types.Int64 `tfsdk:"max_items"`
MinItems types.Int64 `tfsdk:"min_items"`
Required types.Bool `tfsdk:"required"`
StringItems *StringItems `tfsdk:"string_items"`
NumberItems *NumberItems `tfsdk:"number_items"`
BooleanItems *BooleanItems `tfsdk:"boolean_items"`
ObjectItems *ObjectItems `tfsdk:"object_items"`
DependsOn types.List `tfsdk:"depends_on"`
Dataset *DatasetModel `tfsdk:"dataset"`
DefaultJqQuery types.String `tfsdk:"default_jq_query"`
Visible types.Bool `tfsdk:"visible"`
VisibleJqQuery types.String `tfsdk:"visible_jq_query"`

MaxItems types.Int64 `tfsdk:"max_items"`
MinItems types.Int64 `tfsdk:"min_items"`
StringItems *StringItems `tfsdk:"string_items"`
NumberItems *NumberItems `tfsdk:"number_items"`
BooleanItems *BooleanItems `tfsdk:"boolean_items"`
ObjectItems *ObjectItems `tfsdk:"object_items"`
}

type ObjectPropModel struct {
Title types.String `tfsdk:"title"`
Icon types.String `tfsdk:"icon"`
Description types.String `tfsdk:"description"`
Required types.Bool `tfsdk:"required"`
Default types.String `tfsdk:"default"`
DependsOn types.List `tfsdk:"depends_on"`
Dataset *DatasetModel `tfsdk:"dataset"`
DefaultJqQuery types.String `tfsdk:"default_jq_query"`
Encryption types.String `tfsdk:"encryption"`
Visible types.Bool `tfsdk:"visible"`
VisibleJqQuery types.String `tfsdk:"visible_jq_query"`

Default types.String `tfsdk:"default"`
Encryption types.String `tfsdk:"encryption"`
}

type StringItems struct {
Expand Down
11 changes: 11 additions & 0 deletions port/action/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ func numberPropResourceToBody(ctx context.Context, state *ActionModel, props map
property.Dataset = actionDataSetToPortBody(prop.Dataset)
}

if !prop.Visible.IsNull() {
property.Visible = prop.Visible.ValueBoolPointer()
}

if !prop.VisibleJqQuery.IsNull() {
VisibleJqQueryMap := map[string]string{
"jqQuery": prop.VisibleJqQuery.ValueString(),
}
property.Visible = VisibleJqQueryMap
}

props[propIdentifier] = property
}
if prop.Required.ValueBool() {
Expand Down
11 changes: 11 additions & 0 deletions port/action/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ func objectPropResourceToBody(ctx context.Context, d *ActionModel, props map[str
property.Dataset = actionDataSetToPortBody(prop.Dataset)
}

if !prop.Visible.IsNull() {
property.Visible = prop.Visible.ValueBoolPointer()
}

if !prop.VisibleJqQuery.IsNull() {
VisibleJqQueryMap := map[string]string{
"jqQuery": prop.VisibleJqQuery.ValueString(),
}
property.Visible = VisibleJqQueryMap
}

props[propIdentifier] = property
}

Expand Down
Loading
Loading