Skip to content

Commit

Permalink
Add add_pipes_org_workspace_invite_members mod (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajlearner17 authored Dec 5, 2023
1 parent 985e82d commit 18170c1
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 0 deletions.
25 changes: 25 additions & 0 deletions add_pipes_org_workspace_invite_members/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Invite members to join organization by email, create pipes workspace, add members to workspace

- Send email invitation to users to join as member in the organization.
- Create workspace in the organization and add members with role in the workspace.

## Usage

- Add following required credentials to `flowpipe.pvars`

- Pipes API token to access the services. Find more info to generate access token [here].(https://turbot.com/pipes/docs/da-settings#tokens)

- Start your Flowpipe server
- Send email invitation to users to join as member in the organization. e.g.

```
flowpipe pipeline run invite_org_members_by_email --arg org_handle="<YourOrgName>" --arg member_email='["member1@gmail.com", "member1@gmail.com"]'
```

- Create workspace in the organization and add members with role in the workspace.

```
flowpipe pipeline run add_pipes_org_workspace_and_members --arg org_handle="<YourOrgName>" --arg workspace_handle="<WorkspaceName>"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
pipeline "add_pipes_org_workspace_and_members" {
title = "Add Pipes Workspace Organization and Add Members"
description = "Add workspce to the organization and add organization members to the workspace."

param "token" {
type = string
description = "API access token."
default = var.token
}

param "org_handle" {
type = string
description = "The handle of the organization where the workspace has to be created."
}

param "workspace_handle" {
type = string
description = "The handle name of the workspace to be created."
}

param "instance_type" {
type = string
description = "The type of the instance to be created."
default = "db1.shared"
}

param "member_handles" {
type = list(string)
description = "Orgnization member handles to be invited to join workspace."
# ["rk-fbuq", "rkm2023"]
}

param "role" {
type = string
description = "The workspace role name assigned to the member. It supports reader, operator and owner as role."
default = "reader"
}

step "pipeline" "add_pipes_org_workspace" {
pipeline = pipes.pipeline.create_org_workspace
args = {
token = param.token
org_handle = param.org_handle
workspace_handle = param.workspace_handle
instance_type = param.instance_type
}
}

step "pipeline" "add_workspace_member" {
depends_on = [step.pipeline.add_pipes_org_workspace]
for_each = { for handle in param.member_handles : handle => handle }
pipeline = pipes.pipeline.add_org_workspace_member
args = {
token = param.token
org_handle = param.org_handle
workspace_handle = param.workspace_handle
role = param.role
member_handle = each.value
}
}

output "workspace" {
description = "Workspace details."
value = step.pipeline.add_pipes_org_workspace
}

output "member" {
description = "Member information."
value = step.pipeline.add_workspace_member
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
token = "tpt_tokenxxxxx"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
pipeline "invite_org_members_by_email" {
title = "Invite Members to Organization"
description = "Add members by email invite to the organization in pipe."

param "token" {
type = string
description = "API access token."
default = var.token
}

param "org_handle" {
type = string
description = "The handle of the organization where the workspace has to be created."
}

param "member_email" {
type = list(string)
description = "Email-ids of members to be invited to join organization."
# Example ["test1@gmail.com", "test2@gmail.com"]
}

param "role" {
type = string
description = "The role assigned to the member."
default = "member"
}

step "pipeline" "invite_org_members_by_email" {
for_each = { for email in param.member_email : email => email }
pipeline = pipes.pipeline.invite_org_member_by_email
args = {
token = param.token
org_handle = param.org_handle
role = param.role
email = each.value
}
}

output "invitation_details" {
description = "Invitation details."
value = step.pipeline.invite_org_members_by_email
}

}

13 changes: 13 additions & 0 deletions add_pipes_org_workspace_invite_members/mod.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mod "add_pipes_org_workspace_invite_members" {
title = "Add Pipes Organization to Invite Members"
description = "Add organization in pipe and invite members to join by email."

require {
mod "github.com/turbot/flowpipe-mod-pipes" {
version = "v0.0.1-rc.3"
args = {
token = var.token
}
}
}
}
6 changes: 6 additions & 0 deletions add_pipes_org_workspace_invite_members/variables.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
variable "token" {
type = string
description = "API access token"
# TODO: Add once supported
# sensitive = true
}

0 comments on commit 18170c1

Please sign in to comment.