Update a group's information in a directory by groupId via PATCH. You can use this API to manage group membership.
Note: Renaming groups after they've synced to your Atlassian organization isn't supported in this release of the User Provisioning API. To rename a group, create a new group with the desired name, update membership, and then delete the old group.
Get groups from a directory. Filtering is supported with a single exact match (eq) against the displayName attribute. Pagination is supported. Sorting is not supported.
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/admin"
"log"
"os"
)
func main() {
//ATLASSIAN_ADMIN_TOKEN
var scimApiKey = os.Getenv("ATLASSIAN_SCIM_API_KEY")
cloudAdmin, err := admin.New(nil)
if err != nil {
log.Fatal(err)
}
cloudAdmin.Auth.SetBearerToken(scimApiKey)
cloudAdmin.Auth.SetUserAgent("curl/7.54.0")
var directoryID = "bcdde508-ee40-4df2-89cc-d3f6292c5971"
groups, response, err := cloudAdmin.SCIM.Group.Gets(context.Background(), directoryID, "", 0, 50)
if err != nil {
if response != nil {
log.Println("Response HTTP Response", string(response.BodyAsBytes))
}
log.Fatal(err)
}
log.Println("Response HTTP Code", response.StatusCode)
log.Println("HTTP Endpoint Used", response.Endpoint)
for _, group := range groups.Resources {
log.Println(group)
}
}
Create a group
POST /scim/directory/{directoryId}/Groups
Create a group in a directory. An attempt to create a group with an existing name fails with a 409 (Conflict) error.
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/admin"
"log"
"os"
)
func main() {
//ATLASSIAN_ADMIN_TOKEN
var scimApiKey = os.Getenv("ATLASSIAN_SCIM_API_KEY")
cloudAdmin, err := admin.New(nil)
if err != nil {
log.Fatal(err)
}
cloudAdmin.Auth.SetBearerToken(scimApiKey)
cloudAdmin.Auth.SetUserAgent("curl/7.54.0")
var (
directoryID = "bcdde508-ee40-4df2-89cc-d3f6292c5971"
newGroupName = "scim-jira-users"
)
group, response, err := cloudAdmin.SCIM.Group.Create(context.Background(), directoryID, newGroupName)
if err != nil {
if response != nil {
log.Println("Response HTTP Response", string(response.BodyAsBytes))
}
log.Fatal(err)
}
log.Println("Response HTTP Code", response.StatusCode)
log.Println("HTTP Endpoint Used", response.Endpoint)
log.Printf("The group %v has been created and it contains the ID %v", group.DisplayName, group.ID)
}