| 1234567891011121314151617181920212223242526272829303132333435363738 |
- param(
- [string]$token=$env:GL_TOKEN,
- [string]$server="https://gitlab.corp.wabtec.com",
- [string]$group="annax/teams/developers",
- [string]$access_level="30",
- [switch]$delete,
- [Parameter(Mandatory=$true,ValueFromPipeline = $true)]
- [string[]]$input
- )
- Add-Type -AssemblyName System.Web
- if (-not (Get-Module Powershell-Yaml)){
- Install-Module -Name Powershell-Yaml -Scope CurrentUser -Force
- }
- Import-Module Powershell-Yaml
- $groupid = [System.Web.HttpUtility]::UrlEncode($group)
- $uri = ($server + "/api/v4/groups/" + $groupid + "/invitations")
- $headers = @{ 'PRIVATE-TOKEN'=$token }
- $input | ForEach-Object {
-
- if (-not $delete){
- $mail = $_.ToLower()
- "Inviting: " + $mail
- $body = "email=$mail&access_level=$access_level"
- Invoke-RestMethod -Headers $headers -Uri $uri -Method post -Body $body |convertto-yaml
- } else {
- $mail = $_
- "Uninviting: " + $mail
- $uri_user = $uri + "/" + $mail
- Invoke-RestMethod -Headers $headers -Uri $uri_user -Method delete |convertto-yaml
- }
- }
|