Skip to main content
The rolebindings client methods are currently in ALPHA. The API may change without notice. A one-time warning is emitted on first use.
A role binding assigns a role to a user on a specific resource. Only SPACE and PROJECT resource types are supported for single-binding CRUD, and ResourceID must encode the same resource type. Only one binding per user per resource is allowed. All ID fields on role-binding requests are strict IDs — name resolution is not performed.

List Role Bindings

List returns a paginated list of role bindings for the authenticated user’s account, filtered by resource type. Defaults to a page size of 50. ResourceType is required — the zero value is rejected by the server. UserID, when non-empty, filters bindings to a specific user. Signature:
func (c *Client) List(ctx context.Context, req ListRequest) (*RoleBindingList, 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/rolebindings"
)

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

    resp, err := client.RoleBindings.List(context.Background(), rolebindings.ListRequest{
        ResourceType: rolebindings.RoleBindingResourceTypePROJECT,
        Limit:        25,
    })
    if err != nil {
        var unauthorized *arize.UnauthorizedError
        if errors.As(err, &unauthorized) {
            log.Fatalf("unauthorized: %v", unauthorized)
        }
        log.Fatal(err)
    }

    for _, binding := range resp.RoleBindings {
        fmt.Printf("%s: user=%s role=%s resource=%s\n",
            binding.Id,
            binding.UserId,
            binding.RoleId,
            binding.ResourceId,
        )
    }
}

Get a Role Binding

Get returns a single role binding by ID. Signature:
func (c *Client) Get(ctx context.Context, req GetRequest) (*RoleBinding, 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/rolebindings"
)

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

    binding, err := client.RoleBindings.Get(
        context.Background(),
        rolebindings.GetRequest{RoleBindingID: "your-binding-id"},
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Fatalf("role binding not found: %v", notFound)
        }
        log.Fatal(err)
    }

    fmt.Printf("binding %s: user=%s role=%s resource=%s (%s)\n",
        binding.Id,
        binding.UserId,
        binding.RoleId,
        binding.ResourceId,
        binding.ResourceType,
    )
}

Create a Role Binding

Create issues a POST to create a new role binding and returns the created binding. Signature:
func (c *Client) Create(
    ctx context.Context,
    req CreateRequest,
) (*RoleBinding, 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/rolebindings"
)

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

    binding, err := client.RoleBindings.Create(
        context.Background(),
        rolebindings.CreateRequest{
            UserID:       "your-user-id",
            RoleID:       "your-role-id",
            ResourceType: rolebindings.RoleBindingResourceTypePROJECT, // or RoleBindingResourceTypeSPACE
            ResourceID:   "your-project-id",
        },
    )
    if err != nil {
        var conflict *arize.ConflictError
        if errors.As(err, &conflict) {
            log.Fatalf("binding already exists for this user/resource: %v", conflict)
        }
        log.Fatal(err)
    }

    fmt.Printf("created binding %s\n", binding.Id)
}

Update a Role Binding

Update changes the role assigned by an existing binding and returns the updated binding. Signature:
func (c *Client) Update(
    ctx context.Context,
    req UpdateRequest,
) (*RoleBinding, 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/rolebindings"
)

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

    binding, err := client.RoleBindings.Update(
        context.Background(),
        rolebindings.UpdateRequest{
            RoleBindingID: "your-binding-id",
            RoleID:        "new-role-id",
        },
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Fatalf("role binding not found: %v", notFound)
        }
        log.Fatal(err)
    }

    fmt.Printf("updated binding %s now bound to role %s\n", binding.Id, binding.RoleId)
}

Delete a Role Binding

Delete removes a role binding by ID. It returns only an error. Signature:
func (c *Client) Delete(ctx context.Context, req DeleteRequest) 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/rolebindings"
)

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

    err = client.RoleBindings.Delete(
        context.Background(),
        rolebindings.DeleteRequest{RoleBindingID: "your-binding-id"},
    )
    if err != nil {
        var notFound *arize.NotFoundError
        if errors.As(err, &notFound) {
            log.Printf("no binding to remove: %v", notFound)
            return
        }
        log.Fatal(err)
    }
}