GET /wiki/rest/api/content/{id}/restriction/byOperation/{operation}/group/{group}
Returns whether the specified content restriction applies to a group.
This endpoint combines the get content restriction status by group name and group id.
If you provide the group id (UUID), the method will create the endpoint with the verb /byGroupId/{groupNameOrID}
If you provide the group name, the endpoint uses the verb /group/{groupNameOrID}.
PUT /wiki/rest/api/content/{id}/restriction/byOperation/{operation}/group/{grou[}
Adds a group to a content restriction. That is, grant read or update permission to the group for a piece of content.
DELETE /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/group/{groupName}
Removes a group from a content restriction. That is, remove read or update permission for the group for a piece of content.
GET /wiki/rest/api/content/{id}/restriction/byOperation
Returns restrictions on a piece of content by operation. This method is similar to Get restrictions except that the operations are properties of the return object, rather than items in a results array.
package main
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
expand := []string{"restrictions.user", "restrictions.group", "content"}
ctx := context.Background()
restrictions, response, err := instance.Content.Restriction.Operation.Gets(ctx, contentID, expand)
if err != nil {
if response != nil {
log.Println(response.Code)
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
fmt.Println(restrictions)
}GET /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}
Returns the restictions on a piece of content for a given operation (read or update).
var endpoint strings.Builder
endpoint.WriteString(fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/", contentID, operationKey))
// check if the group id is an uuid type
// if so, it's the group id
groupID, err := uuid.Parse(groupNameOrID)
if err == nil {
endpoint.WriteString(fmt.Sprintf("byGroupId/%v", groupID.String()))
} else {
endpoint.WriteString(fmt.Sprintf("group/%v", groupNameOrID))
}package main
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
expand := []string{"restrictions.user", "restrictions.group", "content"}
ctx := context.Background()
operationKey := "read"
restrictions, response, err := instance.Content.Restriction.Operation.Get(ctx, contentID, operationKey, expand, 0, 50)
if err != nil {
if response != nil {
log.Println(response.Code)
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
fmt.Println(restrictions)
}package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
ctx := context.Background()
operationKey := "update"
groupNameOrID := "confluence-users"
response, err := instance.Content.Restriction.Operation.Group.Get(ctx, contentID, operationKey, groupNameOrID)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
}package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
ctx := context.Background()
operationKey := "read"
groupNameOrID := "jira-users-22"
response, err := instance.Content.Restriction.Operation.Group.Add(ctx, contentID, operationKey, groupNameOrID)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
}package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
ctx := context.Background()
operationKey := "read"
groupNameOrID := "jira-users-22"
response, err := instance.Content.Restriction.Operation.Group.Remove(ctx, contentID, operationKey, groupNameOrID)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
}GET /wiki/rest/api/content/{id}/restriction
Returns the restrictions on a piece of content.
POST /wiki/rest/api/content/{id}/restriction
Adds restrictions to a piece of content. Note, this does not change any existing restrictions on the content.
PUT /wiki/rest/api/content/{id}/restriction
Updates restrictions for a piece of content. This removes the existing restrictions and replaces them with the restrictions in the request.
DELETE /wiki/rest/api/content/{id}/restriction
Removes all restrictions (read and update) on a piece of content.
package main
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"net/http"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
restrictions, response, err := instance.Content.Restriction.Gets(context.Background(), "80412692", []string{"restrictions.user", "restrictions.group"}, 0, 50)
if err != nil {
if response != nil {
if response.Code == http.StatusBadRequest {
log.Println(response.Code)
}
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
for _, restriction := range restrictions.Results {
if restriction.Restrictions.Group != nil {
for _, group := range restriction.Restrictions.Group.Results {
fmt.Println(restriction.Operation, group.Name)
}
}
if restriction.Restrictions.User != nil {
for _, user := range restriction.Restrictions.User.Results {
fmt.Println(restriction.Operation, user.Email, user.AccountID, user.AccountType)
}
}
}
}PUT /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/user
Adds a user to a content restriction. That is, grant read or update permission to the user for a piece of content.
DELETE /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/user
Removes a group from a content restriction. That is, remove read or update permission for the group for a piece of content.
package main
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/confluence"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
payload := &models.ContentRestrictionUpdatePayloadScheme{
Results: []*models.ContentRestrictionUpdateScheme{
{
Operation: "update",
Restrictions: &models.ContentRestrictionRestrictionUpdateScheme{
Group: []*models.SpaceGroupScheme{
{
Type: "group",
Name: "jira-users-22",
},
},
User: []*models.ContentUserScheme{
{
AccountID: "5e5f6acefc1fca0af44135f8",
},
},
},
},
},
}
contentID := "80412692"
expand := []string{"restrictions.user", "restrictions.group", "content"}
ctx := context.Background()
restrictions, response, err := instance.Content.Restriction.Add(ctx, contentID, payload, expand)
if err != nil {
if response != nil {
log.Println(response.Code)
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
for _, restriction := range restrictions.Results {
if restriction.Restrictions.Group != nil {
for _, group := range restriction.Restrictions.Group.Results {
fmt.Println(restriction.Operation, group.Name)
}
}
if restriction.Restrictions.User != nil {
for _, user := range restriction.Restrictions.User.Results {
fmt.Println(restriction.Operation, user.Email, user.AccountID, user.AccountType)
}
}
}
}package main
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/confluence"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
payload := &models.ContentRestrictionUpdatePayloadScheme{
Results: []*models.ContentRestrictionUpdateScheme{
{
Operation: "update",
Restrictions: &models.ContentRestrictionRestrictionUpdateScheme{
Group: []*models.SpaceGroupScheme{
{
Type: "group",
Name: "jira-users-22",
},
},
},
},
},
}
contentID := "80412692"
expand := []string{"restrictions.user", "restrictions.group", "content"}
ctx := context.Background()
restrictions, response, err := instance.Content.Restriction.Update(ctx, contentID, payload, expand)
if err != nil {
if response != nil {
log.Println(response.Code)
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
for _, restriction := range restrictions.Results {
if restriction.Restrictions.Group != nil {
for _, group := range restriction.Restrictions.Group.Results {
fmt.Println(restriction.Operation, group.Name)
}
}
if restriction.Restrictions.User != nil {
for _, user := range restriction.Restrictions.User.Results {
fmt.Println(restriction.Operation, user.Email, user.AccountID, user.AccountType)
}
}
}
}package main
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
expand := []string{"restrictions.user", "restrictions.group", "content"}
ctx := context.Background()
restrictions, response, err := instance.Content.Restriction.Delete(ctx, contentID, expand)
if err != nil {
if response != nil {
log.Println(response.Code)
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
for _, restriction := range restrictions.Results {
if restriction.Restrictions.Group != nil {
for _, group := range restriction.Restrictions.Group.Results {
fmt.Println(restriction.Operation, group.Name)
}
}
if restriction.Restrictions.User != nil {
for _, user := range restriction.Restrictions.User.Results {
fmt.Println(restriction.Operation, user.Email, user.AccountID, user.AccountType)
}
}
}
}package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
ctx := context.Background()
operationKey := "update"
accountID := "5b86be50b8e3cb5895860d6d"
response, err := instance.Content.Restriction.Operation.User.Get(ctx, contentID, operationKey, accountID)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
}package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
ctx := context.Background()
operationKey := "update"
accountID := "5e5f6a63157ed50cd2b9eaca"
response, err := instance.Content.Restriction.Operation.User.Add(ctx, contentID, operationKey, accountID)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
}package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
contentID := "80412692"
ctx := context.Background()
operationKey := "update"
accountID := "5e5f6a63157ed50cd2b9eaca"
response, err := instance.Content.Restriction.Operation.User.Remove(ctx, contentID, operationKey, accountID)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println("Endpoint:", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
}