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

Update data_source_okta_policy.go #1445

Merged
merged 2 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions okta/data_source_okta_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package okta

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/okta/terraform-provider-okta/sdk"
)

func dataSourcePolicy() *schema.Resource {
Expand All @@ -19,16 +17,8 @@ func dataSourcePolicy() *schema.Resource {
Required: true,
},
"type": {
Type: schema.TypeString,
ValidateDiagFunc: elemInSlice([]string{
sdk.SignOnPolicyType,
sdk.PasswordPolicyType,
sdk.MfaPolicyType,
sdk.IdpDiscoveryType,
sdk.AccessPolicyType,
sdk.ProfileEnrollmentPolicyType,
}),
Description: fmt.Sprintf("Policy type: %s, %s, %s, or %s", sdk.SignOnPolicyType, sdk.PasswordPolicyType, sdk.MfaPolicyType, sdk.IdpDiscoveryType),
Type: schema.TypeString,
Description: "Policy type, see https://developer.okta.com/docs/reference/api/policy/#policy-object",
Required: true,
},
"status": {
Expand All @@ -40,10 +30,6 @@ func dataSourcePolicy() *schema.Resource {
}

func dataSourcePolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if isClassicOrg(m) {
return resourceOIEOnlyFeatureError(appSignOnPolicy)
}

policy, err := findPolicyByNameAndType(ctx, m, d.Get("name").(string), d.Get("type").(string))
if err != nil {
return diag.FromErr(err)
Expand Down
12 changes: 10 additions & 2 deletions website/docs/d/policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ data "okta_policy" "example" {

- `name` - (Required) Name of policy to retrieve.

- `type` - (Required) Type of policy to retrieve. Valid values: `"OKTA_SIGN_ON"`, `"PASSWORD"`, `"MFA_ENROLL"`,
`"IDP_DISCOVERY"`, `"ACCESS_POLICY"` (**only available as a part of the Identity Engine**), `"PROFILE_ENROLLMENT"` (**only available as a part of the Identity Engine**)
- `type` - (Required) Type of policy to retrieve. See https://developer.okta.com/docs/reference/api/policy/#policy-object for valid values. Currently:
- All:
- `OKTA_SIGN_ON`
- `PASSWORD`
- `MFA_ENROLL`
- `OAUTH_AUTHORIZATION_POLICY`
- `IDP_DISCOVERY`
- OIE Only:
- `ACCESS_POLICY`
- `PROFILE_ENROLLMENT`

## Attributes Reference

Expand Down