-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from sailpoint-oss/feature/pythonStarterCode
Add command to initialize python example project
- Loading branch information
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2023, SailPoint Technologies, Inc. All rights reserved. | ||
package sdk | ||
|
||
import ( | ||
"embed" | ||
|
||
"github.com/sailpoint-oss/sailpoint-cli/internal/initialize" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
//go:embed python/* | ||
var pyTemplateContents embed.FS | ||
|
||
const pyTemplateDirName = "python" | ||
|
||
func newPythonCommand() *cobra.Command { | ||
|
||
cmd := &cobra.Command{ | ||
Use: "python", | ||
Short: "Initialize a new python SDK project", | ||
Long: "\nInitialize a new typescript SDK project\n\n", | ||
Example: "sail sdk init python\nsail sdk init py example-project", | ||
Aliases: []string{"py"}, | ||
Args: cobra.MaximumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var projName string | ||
var err error | ||
|
||
if len(args) > 0 { | ||
projName = args[0] | ||
} else { | ||
projName = "python-template" | ||
} | ||
|
||
err = initialize.InitializeProject(pyTemplateContents, pyTemplateDirName, projName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sailpoint >= 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import sailpoint | ||
import sailpoint.v3 | ||
import sailpoint.beta | ||
from sailpoint.configuration import Configuration | ||
from sailpoint.paginator import Paginator | ||
from sailpoint.v3.models.search import Search | ||
from pprint import pprint | ||
|
||
configuration = Configuration() | ||
|
||
# Enter a context with an instance of the API client | ||
with sailpoint.v3.ApiClient(configuration) as api_client: | ||
# Create an instance of the API class | ||
api_instance = sailpoint.v3.TransformsApi(api_client) | ||
|
||
# List transforms | ||
try: | ||
# List transforms | ||
api_response = api_instance.list_transforms() | ||
print("The response of TransformsApi->list_transforms:\n") | ||
for transform in api_response: | ||
pprint(transform.name) | ||
except Exception as e: | ||
print("Exception when calling TransformsApi->list_transforms: %s\n" % e) | ||
|
||
# List Access Profiles | ||
api_instance = sailpoint.v3.AccessProfilesApi(api_client) | ||
|
||
try: | ||
api_response = api_instance.list_access_profiles() | ||
print("The response of AccessProfilesApi->list_access_profiles:\n") | ||
for access_profile in api_response: | ||
pprint(access_profile.name) | ||
except Exception as e: | ||
print( | ||
"Exception when calling AccessProfilesApi->list_access_profiles: %s\n" % e | ||
) | ||
|
||
# Use the paginator with search | ||
|
||
search = Search() | ||
search.indices = ['identities'] | ||
search.query = { 'query': '*' } | ||
search.sort = ['-name'] | ||
|
||
identities = Paginator.paginate_search(sailpoint.v3.SearchApi(api_client),search, 250, 1000) | ||
for identity in identities: | ||
print(identity['name']) | ||
|
||
|
||
|
||
# Use the paginator to paginate 1000 accounts 100 at a time | ||
accounts = Paginator.paginate(sailpoint.v3.AccountsApi(api_client).list_accounts, 1000, limit=100) | ||
print(len(accounts)) | ||
for account in accounts: | ||
print(account.name) | ||
|
||
|
||
with sailpoint.beta.ApiClient(configuration) as api_client: | ||
|
||
workgroups = sailpoint.beta.GovernanceGroupsApi(api_client).list_workgroups() | ||
for workgroup in workgroups: | ||
print(workgroup.name) |