Giter Club home page Giter Club logo

Comments (9)

gabrielsroka avatar gabrielsroka commented on August 15, 2024

an example
https://developer.okta.com/docs/reference/api/groups/#create-group-rule

steps to convert JSON to PowerShell
https://github.com/gabrielsroka/OktaAPI.psm1#converting-json-to-powershell

from oktaapi.psm1.

SCAJohnV avatar SCAJohnV commented on August 15, 2024

I've actually been trying to follow the API reference doc from Okta that you linked.
Would you mind pasting a sample of what it would look like in Powershell?
I'm having trouble figuring out where I'm messing up.

from oktaapi.psm1.

gabrielsroka avatar gabrielsroka commented on August 15, 2024

Would you share what you've done so far?

from oktaapi.psm1.

SCAJohnV avatar SCAJohnV commented on August 15, 2024

Sure.

$value = 'user.ej_location==\"00000000\"'

New-OktaGroupRule @{
type = "group_rule"
name = "TestGroup01Rule"
conditions = @{
        people = @{
            users = @{
                Exclude = ""
        }}}

        groups = @{
exclude = ""

        }

        expression = @{  
    value = $value
    type = "urn:oktaexpresssion:1.0"    
    }
actions = @{
    assignUserToGroups =@{
        groupIds = @("00g3jzw6uzmhL2ykt297")
        

}
}
}

from oktaapi.psm1.

gabrielsroka avatar gabrielsroka commented on August 15, 2024

here's a functioning (tho not useful) example

btw, you can use triple backticks in GitHub to quote your code

$newRule = ConvertFrom-Json @"
{
  "type": "group_rule",
  "name": "A PS rule",
  "conditions": {
    "expression": {
      "value": "user.login == Engineer",
      "type": "urn:okta:expression:1.0"
    }
  },
  "actions": {
    "assignUserToGroups": {
      "groupIds": [
        "00g10usgcxtVV5CYe0h8"
      ]
    }
  }
}
"@

New-OktaGroupRule $newRule

from oktaapi.psm1.

gabrielsroka avatar gabrielsroka commented on August 15, 2024

note that JSON is case-sensitive. if Okta wants exclude, then Exclude won't work

from oktaapi.psm1.

gabrielsroka avatar gabrielsroka commented on August 15, 2024

also, the type in your example is incorrrect

from oktaapi.psm1.

gabrielsroka avatar gabrielsroka commented on August 15, 2024

this example is a little more like yours (you had also misspelled expression)

i find the indentation to be very helpful

$value = 'user.login == "abc"'

New-OktaGroupRule @{
    type = "group_rule"
    name = "a ps rule"
    conditions = @{
        people = @{
            users = @{
                exclude = @()
            }
            groups = @{
                exclude = @()
            }
        }
        expression = @{  
            value = $value
            type = "urn:okta:expression:1.0"    
        }
    }
    actions = @{
        assignUserToGroups = @{
            groupIds = @("00g3jzw6uzmhL2ykt297")
        }
    }
}

from oktaapi.psm1.

SCAJohnV avatar SCAJohnV commented on August 15, 2024

Ahhh - Both of your most recent responses with code have been incredibly helpful. I thank you.

from oktaapi.psm1.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.