Skip to content

Commit

Permalink
Implementing create_user flow + Refactoring to use http_graph_action
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Panuska committed May 7, 2020
1 parent fab5330 commit 523465d
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
########################################################################################################################
namespace: ''
properties:
- tenant: ''
- tenant: rpamf.onmicrosoft.com
- client_id: ''
- client_secret:
value: ''
Expand All @@ -14,7 +14,7 @@ properties:
value: ''
sensitive: false
- proxy_host: ''
- proxy_port: ''
- proxy_port: '8080'
- proxy_username: ''
- proxy_password:
value: ''
Expand Down
60 changes: 60 additions & 0 deletions office365/Content/Library/office365/_tools/http_graph_action.sl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace: office365._tools
flow:
name: http_graph_action
inputs:
- url
- token
- method
- body:
required: false
workflow:
- http_client_action:
do:
io.cloudslang.base.http.http_client_action:
- url: "${'https://graph.microsoft.com/v1.0%s' % url}"
- auth_type: anonymous
- proxy_host: "${get_sp('proxy_host')}"
- proxy_port: "${get_sp('proxy_port')}"
- proxy_username: "${get_sp('proxy_username')}"
- proxy_password:
value: "${get_sp('proxy_password')}"
sensitive: true
- trust_all_roots: 'false'
- x_509_hostname_verifier: strict
- headers: "${'Authorization: Bearer ' + token}"
- body: '${body}'
- content_type: application/json
- method: '${method}'
publish:
- return_result
- error_message
- status_code
- return_code
- response_headers
navigate:
- SUCCESS: SUCCESS
- FAILURE: on_failure
outputs:
- return_result: '${return_result}'
- response_headers: '${response_headers}'
- error_message: '${error_message}'
- status_code: '${status_code}'
- return_code: '${return_code}'
results:
- FAILURE
- SUCCESS
extensions:
graph:
steps:
http_client_action:
x: 85
'y': 96
navigate:
157930d8-a607-4c4d-9e14-cf9639670613:
targetId: 4e80e608-6286-2b58-a16a-2847a30b06d5
port: SUCCESS
results:
SUCCESS:
4e80e608-6286-2b58-a16a-2847a30b06d5:
x: 253
'y': 91
6 changes: 6 additions & 0 deletions office365/Content/Library/office365/auth/authenticate.sl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ flow:
do:
io.cloudslang.base.http.http_client_post:
- url: "${'https://login.microsoftonline.com/%s/oauth2/v2.0/token' % tenant_q}"
- proxy_host: "${get_sp('proxy_host')}"
- proxy_port: "${get_sp('proxy_port')}"
- proxy_username: "${get_sp('proxy_username')}"
- proxy_password:
value: "${get_sp('proxy_password')}"
sensitive: true
- body: "${'client_id=%s&client_secret=%s&scope=https%%3A%%2F%%2Fgraph.microsoft.com%%2F.default&grant_type=client_credentials' % (client_id_q, client_secret_q)}"
- content_type: application/x-www-form-urlencoded
publish:
Expand Down
21 changes: 10 additions & 11 deletions office365/Content/Library/office365/mail/list_mail_folders.sl
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ flow:
- token
navigate:
- FAILURE: on_failure
- SUCCESS: http_client_get
- http_client_get:
- SUCCESS: http_graph_action
- http_graph_action:
do:
io.cloudslang.base.http.http_client_get:
- url: "${'https://graph.microsoft.com/v1.0/users/%s/mailFolders' % user_principal_name}"
- auth_type: anonymous
- headers: "${'Authorization: Bearer ' + token}"
- content_type: application/json
office365._tools.http_graph_action:
- url: "${'/users/%s/mailFolders' % user_principal_name}"
- token: '${token}'
- method: GET
publish:
- json: '${return_result}'
navigate:
- SUCCESS: SUCCESS
- FAILURE: on_failure
- SUCCESS: SUCCESS
outputs:
- json: '${json}'
results:
Expand All @@ -35,11 +34,11 @@ extensions:
authenticate:
x: 110
'y': 102
http_client_get:
http_graph_action:
x: 300
'y': 102
'y': 95
navigate:
73cf73b4-7c40-cee9-6357-15280d6d1fba:
f5cb9d45-73b8-a8b4-b98f-1f77a2fba12a:
targetId: 0de24e87-f841-d198-f608-1f8d4812b488
port: SUCCESS
results:
Expand Down
23 changes: 11 additions & 12 deletions office365/Content/Library/office365/mail/list_messages.sl
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ flow:
- token
navigate:
- FAILURE: on_failure
- SUCCESS: http_client_get
- http_client_get:
- SUCCESS: http_graph_action
- http_graph_action:
do:
io.cloudslang.base.http.http_client_get:
- url: "${'https://graph.microsoft.com/v1.0/users/%s%s/messages%s' % (user_principal_name, '' if not folder_name else '/mailFolders'+folder_name, \"\" if not top else '?$top='+top)}"
- auth_type: anonymous
- headers: "${'Authorization: Bearer ' + token}"
- content_type: application/json
office365._tools.http_graph_action:
- url: "${'/users/%s%s/messages%s' % (user_principal_name, '' if not folder_name else '/mailFolders'+folder_name, \"\" if not top else '?$top='+top)}"
- token: '${token}'
- method: GET
publish:
- json: '${return_result}'
navigate:
- SUCCESS: SUCCESS
- FAILURE: on_failure
- SUCCESS: SUCCESS
outputs:
- json: '${json}'
results:
Expand All @@ -38,11 +37,11 @@ extensions:
authenticate:
x: 110
'y': 102
http_client_get:
x: 300
'y': 102
http_graph_action:
x: 289
'y': 96
navigate:
73cf73b4-7c40-cee9-6357-15280d6d1fba:
936d4249-beaf-485b-c21e-8916df2ba740:
targetId: 0de24e87-f841-d198-f608-1f8d4812b488
port: SUCCESS
results:
Expand Down
72 changes: 72 additions & 0 deletions office365/Content/Library/office365/user/create_user.sl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
########################################################################################################################
#!!
#! @input user_principal_name: Unique identifier of the user
#! @input force_change_password: Force the user to change his/her password first time he/she signs in
#!!#
########################################################################################################################
namespace: office365.user
flow:
name: create_user
inputs:
- display_name: Test
- mail_nick_name: test
- user_principal_name: test@rpamf.onmicrosoft.com
- password:
sensitive: true
- force_change_password: 'false'
workflow:
- authenticate:
do:
office365.auth.authenticate: []
publish:
- token
navigate:
- FAILURE: on_failure
- SUCCESS: http_graph_action
- http_graph_action:
do:
office365._tools.http_graph_action:
- url: /users
- token: '${token}'
- method: POST
- body: |-
${'''
{
"accountEnabled": true,
"displayName": "%s",
"mailNickname": "%s",
"userPrincipalName": "%s",
"passwordProfile" : {
"forceChangePasswordNextSignIn": %s,
"password": "%s"
}
}
''' % (display_name, mail_nick_name, user_principal_name, force_change_password, password)}
publish:
- json: '${return_result}'
navigate:
- FAILURE: on_failure
- SUCCESS: SUCCESS
outputs:
- json: '${json}'
results:
- FAILURE
- SUCCESS
extensions:
graph:
steps:
http_graph_action:
x: 229
'y': 83
navigate:
297032fa-a883-67fe-0ef2-c59f849f7d77:
targetId: f9ca98c4-3b22-08dc-b07e-53dfa4d7d54f
port: SUCCESS
authenticate:
x: 55
'y': 88
results:
SUCCESS:
f9ca98c4-3b22-08dc-b07e-53dfa4d7d54f:
x: 393
'y': 81
23 changes: 11 additions & 12 deletions office365/Content/Library/office365/user/list_users.sl
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ flow:
- token
navigate:
- FAILURE: on_failure
- SUCCESS: http_client_get
- http_client_get:
- SUCCESS: http_graph_action
- http_graph_action:
do:
io.cloudslang.base.http.http_client_get:
- url: 'https://graph.microsoft.com/v1.0/users'
- auth_type: anonymous
- headers: "${'Authorization: Bearer ' + token}"
- content_type: application/json
office365._tools.http_graph_action:
- url: /users
- token: '${token}'
- method: GET
publish:
- json: '${return_result}'
navigate:
- SUCCESS: SUCCESS
- FAILURE: on_failure
- SUCCESS: SUCCESS
outputs:
- json: '${json}'
results:
Expand All @@ -32,12 +31,12 @@ extensions:
steps:
authenticate:
x: 110
'y': 102
http_client_get:
'y': 101
http_graph_action:
x: 300
'y': 102
'y': 119
navigate:
73cf73b4-7c40-cee9-6357-15280d6d1fba:
0d6410c8-cf40-3261-e842-8dd338ed2d10:
targetId: 0de24e87-f841-d198-f608-1f8d4812b488
port: SUCCESS
results:
Expand Down

0 comments on commit 523465d

Please sign in to comment.