Skip to main content
The resourcerestrictions client methods are currently in ALPHA. The API may change without notice. A one-time warning is emitted on first use.
Restricting a resource prevents roles bound at higher hierarchy levels (space, org, account) from granting access to it. Only space admins or users with the PROJECT_RESTRICT permission can perform these actions. Currently only PROJECT resources are supported.

Restrict a Resource

Restrict marks a resource as restricted and returns the restriction record. This operation is idempotent — restricting an already-restricted resource returns the existing restriction without error. Signature:
func (c *Client) Restrict(
    ctx context.Context,
    req RestrictRequest,
) (*ResourceRestriction, error)
Usage Example:
package main

import (
    "context"
    "errors"
    "fmt"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/resourcerestrictions"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    restriction, err := client.ResourceRestrictions.Restrict(
        context.Background(),
        resourcerestrictions.RestrictRequest{
            ResourceID: "your-project-id", // global ID of the resource to restrict
        },
    )
    if err != nil {
        var forbidden *arize.ForbiddenError
        if errors.As(err, &forbidden) {
            log.Fatalf("missing PROJECT_RESTRICT permission: %v", forbidden)
        }
        log.Fatal(err)
    }

    fmt.Printf("restricted %s (type=%s) at %s\n",
        restriction.ResourceId,
        restriction.ResourceType,
        restriction.CreatedAt,
    )
}

Unrestrict a Resource

Unrestrict removes a restriction from a resource. ResourceID is the ID of the restricted resource (e.g. a project ID), not the ID of the restriction record itself — the API dereferences from the restricted resource to the restriction it holds. It returns only an error. Signature:
func (c *Client) Unrestrict(ctx context.Context, req UnrestrictRequest) error
Usage Example:
package main

import (
    "context"
    "errors"
    "log"

    "github.com/Arize-ai/client-go-v2/arize"
    "github.com/Arize-ai/client-go-v2/arize/resourcerestrictions"
)

func main() {
    client, err := arize.NewClient(arize.Config{APIKey: "your-api-key"})
    if err != nil {
        log.Fatal(err)
    }

    err = client.ResourceRestrictions.Unrestrict(
        context.Background(),
        resourcerestrictions.UnrestrictRequest{ResourceID: "your-project-id"},
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Printf("no restriction to remove: %v", notFound)
            return
        }
        log.Fatal(err)
    }
}