You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Introduction

A number of users wish to create JS7 - Identity Services, populate accounts and to JS7 - Manage Roles and Permissions automatically from individual sources such as a database.

Building Blocks

The REST Web Service API provides the functionality to automate

Example

The following example makes use of four lines of code to connect to JS7, to store and to deploy a workflow. The remaining code is used to create the workflow.


Example for a PowerShell script to store and to deploy a workflow
#!/usr/bin/env pwsh

# Parameterization

$Url = "http://localhost:4446"
$ControllerId = "controller"

$TestCaseService = "TestCase_Service"
$TestCaseAccount = "TestCase_User"
$TestCaseRoleApplicationManager = "TestCase_Application_Manager"
$TestCaseRoleIncidentManager = "TestCase_Incident_Manager"
$TestCaseFolder = "/TestCase_Folder"
$TestCasePermissions = @(
    "sos:products:controller:view",
    "sos:products:controller:agents:view",
    "sos:products:controller:deployment:manage",
    "sos:products:controller:locks:view",
    "sos:products:controller:workflows:view",
    "sos:products:controller:orders:view",
    "sos:products:controller:deployment:deploy"
)

# Connection

Import-Module JS7
Connect-JS7 -Url $Url -Id $ControllerId | Out-Null

# ----- Create Identity Service, Role, Folders, Permissions, Accounts -----

# create Identity Service for use with password authentication
$service = Set-JS7IAMService -Service $TestCaseService -Type 'JOC' -SingleFactorPassword

# create roles
Set-JS7IAMRole -Service $TestCaseService -Role $TestCaseRoleApplicationManager
Set-JS7IAMRole -Service $TestCaseService -Role $TestCaseRoleIncidentManager

# limit role to JOC Cockpit inventory folder
Set-JS7IAMFolder -Service $TestCaseService -Role $TestCaseRoleApplicationManager -Folder $TestCaseFolder -Recursive -ControllerId $ControllerId

# add permissions to roles
Set-JS7IAMPermission -Service $TestCaseService -Role $TestCaseRoleApplicationManager -Permission $TestCasePermissions -ControllerId $ControllerId
Set-JS7IAMPermission -Service $TestCaseService -Role $TestCaseRoleIncidentManager -Permission $TestCasePermissions -ControllerId $ControllerId

# add account
Set-JS7IAMAccount -Service $TestCaseService -Account $TestCaseAccount -Role $TestCaseRoleApplicationManager,$TestCaseRoleIncidentManager

# ----- Read Identity Service, Role, Folders, Permissions, Accounts -----

$service = Get-JS7IAMService -Service $TestCaseService

$role = Get-JS7IAMRole -Service $TestCaseService -Role $TestCaseRoleApplicationManager
$folders = Get-JS7IAMFolder -Service $TestCaseService -Role $TestCaseRoleApplicationManager -ControllerId $ControllerId
$rolePermissions = Get-JS7IAMPermission -Service $TestCaseService -Role $TestCaseRoleApplicationManager -ControllerId $ControllerId

$account = Get-JS7IAMAccount -Service $TestCaseService -Account $TestCaseAccount
$accountPermissions = Get-JS7IAMAccountPermission -Service $TestCaseService -Account $TestCaseAccount

# ---- Manage Accounts -----

Invoke-JS7IAMForcePasswordChange -Service $TestCaseService -Account $TestCaseAccount
Invoke-JS7IAMResetPassword -Service $TestCaseService -Account $TestCaseAccount

Disable-JS7IAMAccount -Service $TestCaseService -Account $TestCaseAccount
Enable-JS7IAMAccount -Service $TestCaseService -Account $TestCaseAccount

Rename-JS7IAMAccount -Service $TestCaseService -Account $TestCaseAccount -NewAccount "$($TestCaseAccount)2"
Rename-JS7IAMAccount -Service $TestCaseService -Account "$($TestCaseAccount)2" -NewAccount $TestCaseAccount

# ---- Manage Identity Service, Roles, Folders -----

Rename-JS7IAMService -Service $TestCaseService -NewService "$($TestCaseService)2"
Rename-JS7IAMService -Service "$($TestCaseService)2" -NewService $TestCaseService

Rename-JS7IAMRole -Service $TestCaseService -Role $TestCaseRoleApplicationManager -NewRole "$($TestCaseRoleApplicationManager)2"
Rename-JS7IAMRole -Service $TestCaseService -Role "$($TestCaseRoleApplicationManager)2" -NewRole $TestCaseRoleApplicationManager

Rename-JS7IAMFolder -Service $TestCaseService -Role $TestCaseRoleApplicationManager -ControllerId $ControllerId -Folder $TestCaseFolder -NewFolder "$($TestCaseFolder)2"
Rename-JS7IAMFolder -Service $TestCaseService -Role $TestCaseRoleApplicationManager -ControllerId $ControllerId -Folder "$($TestCaseFolder)2" -NewFolder $TestCaseFolder

# ----- Remove Identity Service, Accounts, Roles, Folders, Permissions ---

# remove account
Remove-JS7IAMAccount -Service $TestCaseService -Account $TestCaseAccount

# remove permissions from role
Get-JS7IAMPermission -Service $TestCaseService -Role $TestCaseRoleApplicationManager -ControllerId $ControllerId | Remove-JS7IAMPermission

# remove folder from role
Remove-JS7IAMFolder -Service $TestCaseService -Role $TestCaseRoleApplicationManager -Folder $TestCaseFolder

# remove roles and any included folders and permissions
Remove-JS7IAMRole -Service $TestCaseService -Role $TestCaseRoleApplicationManager
Remove-JS7IAMRole -Service $TestCaseService -Role $TestCaseRoleIncidentManager

# remove Identity Service and any included accounts, roles, folders, permissions
Remove-JS7IAMService -Service $TestCaseService

# Connection

Disconnect-JS7
  • No labels