Skip to content

Commit

Permalink
Merge pull request #1445 from okta/monde-patch-3
Browse files Browse the repository at this point in the history
Update data_source_okta_policy.go
  • Loading branch information
monde authored Feb 8, 2023
2 parents fa8d041 + 30c4911 commit b9b043d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
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

0 comments on commit b9b043d

Please sign in to comment.