Skip to content

Commit

Permalink
add idp group mappings to tf
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-riddle-opal committed Feb 21, 2025
1 parent 4a03349 commit cffe64d
Show file tree
Hide file tree
Showing 53 changed files with 1,063 additions and 705 deletions.
40 changes: 22 additions & 18 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
speakeasyVersion: 1.487.0
speakeasyVersion: 1.498.1
sources:
opal-terraform-provider:
sourceNamespace: opal-terraform-provider
sourceRevisionDigest: sha256:42ba6fc418274bc7f15f9eb922c7fdedaa6eea1c0dfed4cb784651f70880ed3c
sourceBlobDigest: sha256:755b3b8c7ad3c38e5ef40d6b6bc4ed3a627966e0f5092c25c80b068ca2633369
sourceRevisionDigest: sha256:df08a6efad107dc8ab1335cbcbfe3ebb3ebab71aee4e21d86f62a3050d786eaa
sourceBlobDigest: sha256:651d7ad66c89c2004cfc63c160e3d103996dfcdd1931cd001a95ff7410f4a74b
tags:
- latest
- "1.0"
targets:
terraform:
source: opal-terraform-provider
sourceNamespace: opal-terraform-provider
sourceRevisionDigest: sha256:42ba6fc418274bc7f15f9eb922c7fdedaa6eea1c0dfed4cb784651f70880ed3c
sourceBlobDigest: sha256:755b3b8c7ad3c38e5ef40d6b6bc4ed3a627966e0f5092c25c80b068ca2633369
sourceRevisionDigest: sha256:df08a6efad107dc8ab1335cbcbfe3ebb3ebab71aee4e21d86f62a3050d786eaa
sourceBlobDigest: sha256:651d7ad66c89c2004cfc63c160e3d103996dfcdd1931cd001a95ff7410f4a74b
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ terraform {
required_providers {
opal = {
source = "opalsecurity/opal"
version = "0.30.10"
version = "0.31.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
required_providers {
opal = {
source = "opalsecurity/opal"
version = "0.30.10"
version = "0.31.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
opal = {
source = "opalsecurity/opal"
version = "0.30.10"
version = "0.31.0"
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ generation:
usageSnippets:
optionalPropertyRendering: withExample
fixes:
nameResolutionDec2023: false
nameResolutionFeb2025: false
parameterOrderingFeb2024: false
requestResponseComponentNamesFeb2024: false
securityFeb2025: false
auth:
oAuth2ClientCredentialsEnabled: false
oAuth2PasswordEnabled: false
flattenGlobalSecurity: true
terraform:
version: 0.30.10
version: 0.31.0
additionalDataSources: []
additionalDependencies: {}
additionalProviderAttributes:
Expand Down
56 changes: 56 additions & 0 deletions internal/planmodifiers/float32planmodifier/suppress_diff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package float32planmodifier

import (
"context"
"github.com/opalsecurity/terraform-provider-opal/internal/planmodifiers/utils"

"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)

const (
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)

// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff(strategy int) planmodifier.Float32 {
return suppressDiff{
strategy: strategy,
}
}

// suppressDiff implements the plan modifier.
type suppressDiff struct {
strategy int
}

// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
return "Once set, the value of this attribute in state will not change."
}

// MarkdownDescription returns a markdown description of the plan modifier.
func (m suppressDiff) MarkdownDescription(_ context.Context) string {
return "Once set, the value of this attribute in state will not change."
}

// PlanModifyFloat32 implements the plan modification logic.
func (m suppressDiff) PlanModifyFloat32(ctx context.Context, req planmodifier.Float32Request, resp *planmodifier.Float32Response) {
// Do nothing if there is a known planned value.
if !req.PlanValue.IsUnknown() {
return
}

// Do nothing if there is an unknown configuration value
if req.ConfigValue.IsUnknown() {
return
}

if utils.IsAllStateUnknown(ctx, req.State) {
return
}

resp.PlanValue = req.StateValue
}
56 changes: 56 additions & 0 deletions internal/planmodifiers/int32planmodifier/suppress_diff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package int32planmodifier

import (
"context"
"github.com/opalsecurity/terraform-provider-opal/internal/planmodifiers/utils"

"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)

const (
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)

// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff(strategy int) planmodifier.Int32 {
return suppressDiff{
strategy: strategy,
}
}

// suppressDiff implements the plan modifier.
type suppressDiff struct {
strategy int
}

// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
return "Once set, the value of this attribute in state will not change."
}

// MarkdownDescription returns a markdown description of the plan modifier.
func (m suppressDiff) MarkdownDescription(_ context.Context) string {
return "Once set, the value of this attribute in state will not change."
}

// PlanModifyInt32 implements the plan modification logic.
func (m suppressDiff) PlanModifyInt32(ctx context.Context, req planmodifier.Int32Request, resp *planmodifier.Int32Response) {
// Do nothing if there is a known planned value.
if !req.PlanValue.IsUnknown() {
return
}

// Do nothing if there is an unknown configuration value
if req.ConfigValue.IsUnknown() {
return
}

if utils.IsAllStateUnknown(ctx, req.State) {
return
}

resp.PlanValue = req.StateValue
}
4 changes: 2 additions & 2 deletions internal/provider/apps_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type AppsDataSource struct {

// AppsDataSourceModel describes the data model.
type AppsDataSourceModel struct {
AppTypeFilter []types.String `tfsdk:"app_type_filter"`
AppTypeFilter []types.String `queryParam:"style=form,explode=false,name=app_type_filter" tfsdk:"app_type_filter"`
Apps []tfTypes.App `tfsdk:"apps"`
OwnerFilter types.String `tfsdk:"owner_filter"`
OwnerFilter types.String `queryParam:"style=form,explode=true,name=owner_filter" tfsdk:"owner_filter"`
}

// Metadata returns the data source type name.
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/configurationtemplate_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (r *ConfigurationTemplateResource) Schema(ctx context.Context, req resource
"operator": schema.StringAttribute{
Computed: true,
Optional: true,
Default: stringdefault.StaticString("AND"),
Default: stringdefault.StaticString(`AND`),
Description: `The operator of the reviewer stage. Admin and manager approval are also treated as reviewers. Default: "AND"; must be one of ["AND", "OR"]`,
Validators: []validator.String{
stringvalidator.OneOf(
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/events_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ type EventsDataSource struct {

// EventsDataSourceModel describes the data model.
type EventsDataSourceModel struct {
ActorFilter types.String `tfsdk:"actor_filter"`
APITokenFilter types.String `tfsdk:"api_token_filter"`
Cursor types.String `tfsdk:"cursor"`
EndDateFilter types.String `tfsdk:"end_date_filter"`
EventTypeFilter types.String `tfsdk:"event_type_filter"`
ActorFilter types.String `queryParam:"style=form,explode=true,name=actor_filter" tfsdk:"actor_filter"`
APITokenFilter types.String `queryParam:"style=form,explode=true,name=api_token_filter" tfsdk:"api_token_filter"`
Cursor types.String `queryParam:"style=form,explode=true,name=cursor" tfsdk:"cursor"`
EndDateFilter types.String `queryParam:"style=form,explode=true,name=end_date_filter" tfsdk:"end_date_filter"`
EventTypeFilter types.String `queryParam:"style=form,explode=true,name=event_type_filter" tfsdk:"event_type_filter"`
Next types.String `tfsdk:"next"`
ObjectFilter types.String `tfsdk:"object_filter"`
PageSize types.Int64 `tfsdk:"page_size"`
ObjectFilter types.String `queryParam:"style=form,explode=true,name=object_filter" tfsdk:"object_filter"`
PageSize types.Int64 `queryParam:"style=form,explode=true,name=page_size" tfsdk:"page_size"`
Previous types.String `tfsdk:"previous"`
Results []tfTypes.Event `tfsdk:"results"`
StartDateFilter types.String `tfsdk:"start_date_filter"`
StartDateFilter types.String `queryParam:"style=form,explode=true,name=start_date_filter" tfsdk:"start_date_filter"`
}

// Metadata returns the data source type name.
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/group_list_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ type GroupListDataSource struct {

// GroupListDataSourceModel describes the data model.
type GroupListDataSourceModel struct {
GroupIds []types.String `tfsdk:"group_ids"`
GroupName types.String `tfsdk:"group_name"`
GroupTypeFilter types.String `tfsdk:"group_type_filter"`
PageSize types.Int64 `tfsdk:"page_size"`
GroupIds []types.String `queryParam:"style=form,explode=false,name=group_ids" tfsdk:"group_ids"`
GroupName types.String `queryParam:"style=form,explode=true,name=group_name" tfsdk:"group_name"`
GroupTypeFilter types.String `queryParam:"style=form,explode=true,name=group_type_filter" tfsdk:"group_type_filter"`
PageSize types.Int64 `queryParam:"style=form,explode=true,name=page_size" tfsdk:"page_size"`
Results []tfTypes.Group `tfsdk:"results"`
}

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ func (r *GroupResource) Schema(ctx context.Context, req resource.SchemaRequest,
"operator": schema.StringAttribute{
Computed: true,
Optional: true,
Default: stringdefault.StaticString("AND"),
Default: stringdefault.StaticString(`AND`),
PlanModifiers: []planmodifier.String{
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
},
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/owners_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ type OwnersDataSource struct {

// OwnersDataSourceModel describes the data model.
type OwnersDataSourceModel struct {
Cursor types.String `tfsdk:"cursor"`
Name types.String `tfsdk:"name"`
Cursor types.String `queryParam:"style=form,explode=true,name=cursor" tfsdk:"cursor"`
Name types.String `queryParam:"style=form,explode=true,name=name" tfsdk:"name"`
Next types.String `tfsdk:"next"`
PageSize types.Int64 `tfsdk:"page_size"`
PageSize types.Int64 `queryParam:"style=form,explode=true,name=page_size" tfsdk:"page_size"`
Previous types.String `tfsdk:"previous"`
Results []tfTypes.Owner `tfsdk:"results"`
}
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/requests_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ type RequestsDataSource struct {

// RequestsDataSourceModel describes the data model.
type RequestsDataSourceModel struct {
Cursor types.String `tfsdk:"cursor"`
PageSize types.Int64 `tfsdk:"page_size"`
Cursor types.String `queryParam:"style=form,explode=true,name=cursor" tfsdk:"cursor"`
PageSize types.Int64 `queryParam:"style=form,explode=true,name=page_size" tfsdk:"page_size"`
Requests []tfTypes.Request `tfsdk:"requests"`
ShowPendingOnly types.Bool `tfsdk:"show_pending_only"`
ShowPendingOnly types.Bool `queryParam:"style=form,explode=true,name=show_pending_only" tfsdk:"show_pending_only"`
}

// Metadata returns the data source type name.
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ func (r *ResourceResource) Schema(ctx context.Context, req resource.SchemaReques
"operator": schema.StringAttribute{
Computed: true,
Optional: true,
Default: stringdefault.StaticString("AND"),
Default: stringdefault.StaticString(`AND`),
PlanModifiers: []planmodifier.String{
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
},
Expand Down
12 changes: 6 additions & 6 deletions internal/provider/resources_list_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ type ResourcesListDataSource struct {

// ResourcesListDataSourceModel describes the data model.
type ResourcesListDataSourceModel struct {
Cursor types.String `tfsdk:"cursor"`
Cursor types.String `queryParam:"style=form,explode=true,name=cursor" tfsdk:"cursor"`
Next types.String `tfsdk:"next"`
PageSize types.Int64 `tfsdk:"page_size"`
ParentResourceID types.String `tfsdk:"parent_resource_id"`
PageSize types.Int64 `queryParam:"style=form,explode=true,name=page_size" tfsdk:"page_size"`
ParentResourceID types.String `queryParam:"style=form,explode=false,name=parent_resource_id" tfsdk:"parent_resource_id"`
Previous types.String `tfsdk:"previous"`
ResourceIds []types.String `tfsdk:"resource_ids"`
ResourceName types.String `tfsdk:"resource_name"`
ResourceTypeFilter types.String `tfsdk:"resource_type_filter"`
ResourceIds []types.String `queryParam:"style=form,explode=false,name=resource_ids" tfsdk:"resource_ids"`
ResourceName types.String `queryParam:"style=form,explode=true,name=resource_name" tfsdk:"resource_name"`
ResourceTypeFilter types.String `queryParam:"style=form,explode=true,name=resource_type_filter" tfsdk:"resource_type_filter"`
Results []tfTypes.Resource `tfsdk:"results"`
}

Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resourcesaccessstatus_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ type ResourcesAccessStatusDataSource struct {
// ResourcesAccessStatusDataSourceModel describes the data model.
type ResourcesAccessStatusDataSourceModel struct {
AccessLevel *tfTypes.ResourceAccessLevel `tfsdk:"access_level"`
AccessLevelRemoteID types.String `tfsdk:"access_level_remote_id"`
Cursor types.String `tfsdk:"cursor"`
AccessLevelRemoteID types.String `queryParam:"style=form,explode=true,name=access_level_remote_id" tfsdk:"access_level_remote_id"`
Cursor types.String `queryParam:"style=form,explode=true,name=cursor" tfsdk:"cursor"`
ExpirationDate types.String `tfsdk:"expiration_date"`
PageSize types.Int64 `tfsdk:"page_size"`
PageSize types.Int64 `queryParam:"style=form,explode=true,name=page_size" tfsdk:"page_size"`
ResourceID types.String `tfsdk:"resource_id"`
Status types.String `tfsdk:"status"`
UserID types.String `tfsdk:"user_id"`
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resourcesusers_list_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ResourcesUsersListDataSource struct {

// ResourcesUsersListDataSourceModel describes the data model.
type ResourcesUsersListDataSourceModel struct {
Limit types.Int64 `tfsdk:"limit"`
Limit types.Int64 `queryParam:"style=form,explode=true,name=limit" tfsdk:"limit"`
ResourceID types.String `tfsdk:"resource_id"`
Results []tfTypes.ResourceAccessUser `tfsdk:"results"`
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func (r *ResourcesUsersListDataSource) Schema(ctx context.Context, req datasourc
Computed: true,
Description: `The user has direct access to this resources (vs. indirectly, like through a group).`,
},
"num_access_paths": schema.Int64Attribute{
"num_access_paths": schema.Int32Attribute{
Computed: true,
Description: `The number of ways in which the user has access through this resource (directly and indirectly).`,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resourcesusers_list_data_source_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (r *ResourcesUsersListDataSourceModel) RefreshFromSharedResourceAccessUserL
}
results1.FullName = types.StringValue(resultsItem.FullName)
results1.HasDirectAccess = types.BoolValue(resultsItem.HasDirectAccess)
results1.NumAccessPaths = types.Int64Value(int64(resultsItem.NumAccessPaths))
results1.NumAccessPaths = types.Int32Value(int32(resultsItem.NumAccessPaths))
if resultsItem.PropagationStatus == nil {
results1.PropagationStatus = nil
} else {
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/sessions_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ type SessionsDataSource struct {
type SessionsDataSourceModel struct {
Next types.String `tfsdk:"next"`
Previous types.String `tfsdk:"previous"`
ResourceID types.String `tfsdk:"resource_id"`
ResourceID types.String `queryParam:"style=form,explode=true,name=resource_id" tfsdk:"resource_id"`
Results []tfTypes.Session `tfsdk:"results"`
UserID types.String `tfsdk:"user_id"`
UserID types.String `queryParam:"style=form,explode=true,name=user_id" tfsdk:"user_id"`
}

// Metadata returns the data source type name.
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/tags_list_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type TagsListDataSource struct {

// TagsListDataSourceModel describes the data model.
type TagsListDataSourceModel struct {
Cursor types.String `tfsdk:"cursor"`
Cursor types.String `queryParam:"style=form,explode=true,name=cursor" tfsdk:"cursor"`
Next types.String `tfsdk:"next"`
PageSize types.Int64 `tfsdk:"page_size"`
PageSize types.Int64 `queryParam:"style=form,explode=true,name=page_size" tfsdk:"page_size"`
Previous types.String `tfsdk:"previous"`
Results []tfTypes.Tag `tfsdk:"results"`
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/types/field_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ package types
import "github.com/hashicorp/terraform-plugin-framework/types"

type FieldValue struct {
Str types.String `tfsdk:"str" tfPlanOnly:"true"`
Boolean types.Bool `tfsdk:"boolean" tfPlanOnly:"true"`
Str types.String `queryParam:"inline" tfsdk:"str" tfPlanOnly:"true"`
Boolean types.Bool `queryParam:"inline" tfsdk:"boolean" tfPlanOnly:"true"`
}
2 changes: 1 addition & 1 deletion internal/provider/types/resource_access_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ResourceAccessUser struct {
ExpirationDate types.String `tfsdk:"expiration_date"`
FullName types.String `tfsdk:"full_name"`
HasDirectAccess types.Bool `tfsdk:"has_direct_access"`
NumAccessPaths types.Int64 `tfsdk:"num_access_paths"`
NumAccessPaths types.Int32 `tfsdk:"num_access_paths"`
PropagationStatus *PropagationStatus `tfsdk:"propagation_status"`
ResourceID types.String `tfsdk:"resource_id"`
UserID types.String `tfsdk:"user_id"`
Expand Down
Loading

0 comments on commit cffe64d

Please sign in to comment.