Documentation
¶
Index ¶
- Constants
- type Elements
- type Environments
- func (e *Environments) Create(ctx context.Context, environmentCreate models.EnvironmentCreate) (*models.EnvironmentRead, error)
- func (e *Environments) Delete(ctx context.Context, environmentKey string) error
- func (e *Environments) Get(ctx context.Context, environmentKey string) (*models.EnvironmentRead, error)
- func (e *Environments) GetById(ctx context.Context, environmentId uuid.UUID) (*models.EnvironmentRead, error)
- func (e *Environments) GetByKey(ctx context.Context, environmentKey string) (*models.EnvironmentRead, error)
- func (e *Environments) List(ctx context.Context, page int, perPage int) ([]models.EnvironmentRead, error)
- func (e *Environments) Update(ctx context.Context, environmentKey string, ...) (*models.EnvironmentRead, error)
- type IPermitBaseApi
- type PermitApiClient
- type Projects
- func (p *Projects) Create(ctx context.Context, projectCreate models.ProjectCreate) (*models.ProjectRead, error)
- func (p *Projects) Delete(ctx context.Context, projectKey string) error
- func (p *Projects) Get(ctx context.Context, projectKey string) (*models.ProjectRead, error)
- func (p *Projects) GetById(ctx context.Context, projectId uuid.UUID) (*models.ProjectRead, error)
- func (p *Projects) GetByKey(ctx context.Context, projectKey string) (*models.ProjectRead, error)
- func (p *Projects) List(ctx context.Context, page int, perPage int) ([]models.ProjectRead, error)
- func (p *Projects) Update(ctx context.Context, projectKey string, projectUpdate models.ProjectUpdate) (*models.ProjectRead, error)
- type ResourceActions
- func (a *ResourceActions) Create(ctx context.Context, resourceKey string, ...) (*models.ResourceActionRead, error)
- func (a *ResourceActions) Delete(ctx context.Context, resourceKey string, actionKey string) error
- func (a *ResourceActions) Get(ctx context.Context, resourceKey string, actionKey string) (*models.ResourceActionRead, error)
- func (a *ResourceActions) GetById(ctx context.Context, resourceKey uuid.UUID, actionKey uuid.UUID) (*models.ResourceActionRead, error)
- func (a *ResourceActions) GetByKey(ctx context.Context, resourceKey string, actionKey string) (*models.ResourceActionRead, error)
- func (a *ResourceActions) List(ctx context.Context, resourceKey string, page int, perPage int) ([]models.ResourceActionRead, error)
- func (a *ResourceActions) Update(ctx context.Context, resourceKey string, actionKey string, ...) (*models.ResourceActionRead, error)
- type ResourceAttributes
- func (a *ResourceAttributes) Create(ctx context.Context, resourceKey string, ...) (*models.ResourceAttributeRead, error)
- func (a *ResourceAttributes) Delete(ctx context.Context, resourceKey string, attributeKey string) error
- func (a *ResourceAttributes) Get(ctx context.Context, resourceKey string, attributeKey string) (*models.ResourceAttributeRead, error)
- func (a *ResourceAttributes) GetById(ctx context.Context, resourceKey uuid.UUID, attributeKey uuid.UUID) (*models.ResourceAttributeRead, error)
- func (a *ResourceAttributes) GetByKey(ctx context.Context, resourceKey string, attributeKey string) (*models.ResourceAttributeRead, error)
- func (a *ResourceAttributes) List(ctx context.Context, resourceKey string, page int, perPage int) ([]models.ResourceAttributeRead, error)
- func (a *ResourceAttributes) Update(ctx context.Context, resourceKey string, attributeKey string, ...) (*models.ResourceAttributeRead, error)
- type Resources
- func (r *Resources) Create(ctx context.Context, resourceCreate models.ResourceCreate) (*models.ResourceRead, error)
- func (r *Resources) Delete(ctx context.Context, resourceKey string) error
- func (r *Resources) Get(ctx context.Context, resourceKey string) (*models.ResourceRead, error)
- func (r *Resources) GetById(ctx context.Context, resourceId uuid.UUID) (*models.ResourceRead, error)
- func (r *Resources) GetByKey(ctx context.Context, resourceKey string) (*models.ResourceRead, error)
- func (r *Resources) List(ctx context.Context, page int, perPage int) ([]models.ResourceRead, error)
- func (r *Resources) Update(ctx context.Context, resourceKey string, resourceUpdate models.ResourceUpdate) (*models.ResourceRead, error)
- type RoleRead
- type Roles
- func (r *Roles) AddParentRole(ctx context.Context, roleKey string, parentRoleKey string) error
- func (r *Roles) AssignPermissions(ctx context.Context, roleKey string, permissions []string) error
- func (r *Roles) Create(ctx context.Context, roleCreate models.RoleCreate) (*models.RoleRead, error)
- func (r *Roles) Delete(ctx context.Context, roleKey string) error
- func (r *Roles) Get(ctx context.Context, roleKey string) (*models.RoleRead, error)
- func (r *Roles) GetById(ctx context.Context, roleKey uuid.UUID) (*models.RoleRead, error)
- func (r *Roles) GetByKey(ctx context.Context, roleKey string) (*models.RoleRead, error)
- func (r *Roles) List(ctx context.Context, page int, perPage int) ([]models.RoleRead, error)
- func (r *Roles) ListByAttributes(ctx context.Context, page int, perPage int, ...) ([]models.RoleRead, error)
- func (r *Roles) RemoveParentRole(ctx context.Context, roleKey string, parentRoleKey string) error
- func (r *Roles) RemovePermissions(ctx context.Context, roleKey string, permissions []string) error
- func (r *Roles) Update(ctx context.Context, roleKey string, roleUpdate models.RoleUpdate) (*models.RoleRead, error)
- type Tenants
- func (t *Tenants) Create(ctx context.Context, tenantCreate models.TenantCreate) (*models.TenantRead, error)
- func (t *Tenants) Delete(ctx context.Context, tenantKey string) error
- func (t *Tenants) Get(ctx context.Context, tenantKey string) (*models.TenantRead, error)
- func (t *Tenants) GetById(ctx context.Context, tenantId uuid.UUID) (*models.TenantRead, error)
- func (t *Tenants) GetByKey(ctx context.Context, tenantKey string) (*models.TenantRead, error)
- func (t *Tenants) List(ctx context.Context, page int, perPage int) ([]models.TenantRead, error)
- func (t *Tenants) ListByAttributes(ctx context.Context, attributes map[string]interface{}, page int, perPage int) ([]models.TenantRead, error)
- func (t *Tenants) Update(ctx context.Context, tenantKey string, tenantUpdate models.TenantUpdate) (*models.TenantRead, error)
- type Users
- func (u *Users) AssignRole(ctx context.Context, userKey string, roleKey string, tenantKey string) (*models.RoleAssignmentRead, error)
- func (u *Users) Create(ctx context.Context, userCreate models.UserCreate) (*models.UserRead, error)
- func (u *Users) Delete(ctx context.Context, userKey string) error
- func (u *Users) Get(ctx context.Context, userKey string) (*models.UserRead, error)
- func (u *Users) GetAssignedRoles(ctx context.Context, userKey string, tenantKey string, page int, perPage int) ([]models.RoleAssignmentRead, error)
- func (u *Users) GetById(ctx context.Context, userId uuid.UUID) (*models.UserRead, error)
- func (u *Users) GetByKey(ctx context.Context, userKey string) (*models.UserRead, error)
- func (u *Users) List(ctx context.Context, page int, perPage int) ([]models.UserRead, error)
- func (u *Users) SyncUser(ctx context.Context, user models.UserCreate) (*models.UserRead, error)
- func (u *Users) UnassignRole(ctx context.Context, userKey string, roleKey string, tenantKey string) (*models.UserRead, error)
- func (u *Users) Update(ctx context.Context, userKey string, userUpdate models.UserUpdate) (*models.UserRead, error)
Constants ¶
const DefaultPerPageLimit = 100
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Elements ¶
type Elements struct {
// contains filtered or unexported fields
}
func NewElementsApi ¶
func NewElementsApi(client *openapi.APIClient, config *config.PermitConfig) *Elements
func (*Elements) LoginAs ¶
func (e *Elements) LoginAs(ctx context.Context, userLogin models.UserLoginRequestInput) (*models.EmbeddedLoginRequestOutput, error)
LoginAs login as a given user. Usage Example: ``` userLogin := models.NewUserLoginRequestInput("user-id", "tenant-id") embeddedLoginRequestOutput, err := PermitClient.Api.Elements.LoginAs(ctx, userLogin) ```
type Environments ¶
type Environments struct {
// contains filtered or unexported fields
}
func NewEnvironmentsApi ¶
func NewEnvironmentsApi(client *openapi.APIClient, config *config.PermitConfig) *Environments
func (*Environments) Create ¶
func (e *Environments) Create(ctx context.Context, environmentCreate models.EnvironmentCreate) (*models.EnvironmentRead, error)
Create an environment in the project of your context. Usage Example:
```
environmentCreate := models.NewEnvironmentCreate("production", "Production")
environment, err := PermitClient.Api.Environments.Create(ctx, *environmentCreate)
```
func (*Environments) Delete ¶
func (e *Environments) Delete(ctx context.Context, environmentKey string) error
Delete an environment in the project of your context. Usage Example:
`err := PermitClient.Api.Environments.Delete(ctx, "production")`
func (*Environments) Get ¶
func (e *Environments) Get(ctx context.Context, environmentKey string) (*models.EnvironmentRead, error)
Get an environment by key. Usage Example:
`environment, err := PermitClient.Api.Environments.Get(ctx, "production")`
func (*Environments) GetById ¶
func (e *Environments) GetById(ctx context.Context, environmentId uuid.UUID) (*models.EnvironmentRead, error)
GetById get an environment by id. Usage Example:
`environment, err := PermitClient.Api.Environments.GetById(ctx, uuid.New())`
func (*Environments) GetByKey ¶
func (e *Environments) GetByKey(ctx context.Context, environmentKey string) (*models.EnvironmentRead, error)
GetByKey get an environment by key. Usage Example:
`environment, err := PermitClient.Api.Environments.GetByKey(ctx, "production")`
func (*Environments) List ¶
func (e *Environments) List(ctx context.Context, page int, perPage int) ([]models.EnvironmentRead, error)
List the environments in the project of your context Usage Example:
`environments, err := PermitClient.Api.Environments.List(ctx, 1, 10)`
func (*Environments) Update ¶
func (e *Environments) Update(ctx context.Context, environmentKey string, environmentUpdate models.EnvironmentUpdate) (*models.EnvironmentRead, error)
type IPermitBaseApi ¶
type IPermitBaseApi interface {
// contains filtered or unexported methods
}
type PermitApiClient ¶
type PermitApiClient struct {
Tenants *Tenants
Environments *Environments
Projects *Projects
ResourceActions *ResourceActions
ResourceAttributes *ResourceAttributes
Resources *Resources
Roles *Roles
Users *Users
Elements *Elements
// contains filtered or unexported fields
}
func NewPermitApiClient ¶
func NewPermitApiClient(ctx context.Context, config *config.PermitConfig) *PermitApiClient
func (*PermitApiClient) SetContext ¶
func (p *PermitApiClient) SetContext(ctx context.Context, project string, environment string)
type Projects ¶
type Projects struct {
// contains filtered or unexported fields
}
func NewProjectsApi ¶
func NewProjectsApi(client *openapi.APIClient, config *config.PermitConfig) *Projects
func (*Projects) Create ¶
func (p *Projects) Create(ctx context.Context, projectCreate models.ProjectCreate) (*models.ProjectRead, error)
Create a new project, requires Project level API key, or higher. Usage Example: ``` projectCreate := models.NewProjectCreate("project-key", "project-name") project, err := PermitClient.Api.Projects.Create(ctx, projectCreate) ```
func (*Projects) Delete ¶
Delete a project, requires Project level API key, or higher. Usage Example: `err := PermitClient.Api.Projects.Delete(ctx, "project-key")`
func (*Projects) Get ¶
Get a project by key, requires Project level API key, or higher. Usage Example: `project, err := PermitClient.Api.Projects.Get(ctx, "project-key")`
func (*Projects) GetById ¶
GetById get a project by id, requires Project level API key, or higher. Usage Example: `project, err := PermitClient.Api.Projects.GetById(ctx, uuid.New())`
func (*Projects) GetByKey ¶
GetByKey get a project by key, requires Project level API key, or higher. Usage Example: `project, err := PermitClient.Api.Projects.GetByKey(ctx, "project-key")`
func (*Projects) List ¶
List all projects in the organization, requires Project level API key, or higher. Usage Example: `projects, err := PermitClient.Api.Projects.List(ctx, 1, 10)`
func (*Projects) Update ¶
func (p *Projects) Update(ctx context.Context, projectKey string, projectUpdate models.ProjectUpdate) (*models.ProjectRead, error)
Update a project, requires Project level API key, or higher. Usage Example: ``` projectUpdate := models.NewProjectUpdate() projectUpdate.SetName("new-project-name") project, err := PermitClient.Api.Projects.Update(ctx, "project-key", projectUpdate) ```
type ResourceActions ¶
type ResourceActions struct {
// contains filtered or unexported fields
}
func NewResourceActionsApi ¶
func NewResourceActionsApi(client *openapi.APIClient, config *config.PermitConfig) *ResourceActions
func (*ResourceActions) Create ¶
func (a *ResourceActions) Create(ctx context.Context, resourceKey string, resourceActionCreate models.ResourceActionCreate) (*models.ResourceActionRead, error)
Create a resource action by resource key. Usage Example: ```
resourceActionCreate := models.NewResourceActionCreate("action-key", "action-name")
resourceAction, err := PermitClient.Api.ResourceActions.Create(ctx, "resource-key", resourceActionCreate)
```
func (*ResourceActions) Delete ¶
Delete a resource action by resource key and action key. Usage Example:
`err := PermitClient.Api.ResourceActions.Delete(ctx, "resource-key", "action-key")`
func (*ResourceActions) Get ¶
func (a *ResourceActions) Get(ctx context.Context, resourceKey string, actionKey string) (*models.ResourceActionRead, error)
Get a resource action by resource key and action key. Usage Example:
`resourceAction, err := PermitClient.Api.ResourceActions.Get(ctx, "resource-key", "action-key")`
func (*ResourceActions) GetById ¶
func (a *ResourceActions) GetById(ctx context.Context, resourceKey uuid.UUID, actionKey uuid.UUID) (*models.ResourceActionRead, error)
GetById gets a resource action by resource ID and action ID. Usage Example:
`resourceAction, err := PermitClient.Api.ResourceActions.GetById(ctx, uuid.New(), uuid.New())`
func (*ResourceActions) GetByKey ¶
func (a *ResourceActions) GetByKey(ctx context.Context, resourceKey string, actionKey string) (*models.ResourceActionRead, error)
GetByKey gets a resource action by resource key and action key. Usage Example:
`resourceAction, err := PermitClient.Api.ResourceActions.GetByKey(ctx, "resource-key", "action-key")`
func (*ResourceActions) List ¶
func (a *ResourceActions) List(ctx context.Context, resourceKey string, page int, perPage int) ([]models.ResourceActionRead, error)
List all resource actions of a resource by resource key. Usage Example:
`resourceActions, err := PermitClient.Api.ResourceActions.List(ctx, "resource-key", 1, 10)`
func (*ResourceActions) Update ¶
func (a *ResourceActions) Update(ctx context.Context, resourceKey string, actionKey string, resourceActionUpdate models.ResourceActionUpdate) (*models.ResourceActionRead, error)
Update a resource action by resource key and action key. Usage Example: ```
resourceActionUpdate := models.NewResourceActionUpdate()
resourceActionUpdate.SetName("new-action-name")
resourceAction, err := PermitClient.Api.ResourceActions.Update(ctx, "resource-key", "action-key", resourceActionUpdate)
```
type ResourceAttributes ¶
type ResourceAttributes struct {
// contains filtered or unexported fields
}
func NewResourceAttributesApi ¶
func NewResourceAttributesApi(client *openapi.APIClient, config *config.PermitConfig) *ResourceAttributes
func (*ResourceAttributes) Create ¶
func (a *ResourceAttributes) Create(ctx context.Context, resourceKey string, resourceAttributeCreate models.ResourceAttributeCreate) (*models.ResourceAttributeRead, error)
Create a resource attribute by resource key. Usage Example: ```
resourceAttributeCreate := models.NewResourceAttributeCreate("attribute-key", models.AttributeType("string"))
resourceAttribute, err := PermitClient.Api.ResourceAttributes.Create(ctx, "resource-key", resourceAttributeCreate)
```
func (*ResourceAttributes) Delete ¶
func (a *ResourceAttributes) Delete(ctx context.Context, resourceKey string, attributeKey string) error
Delete a resource attribute by resource key and attribute key. Usage Example:
`err := PermitClient.Api.ResourceAttributes.Delete(ctx, "resource-key", "attribute-key")`
func (*ResourceAttributes) Get ¶
func (a *ResourceAttributes) Get(ctx context.Context, resourceKey string, attributeKey string) (*models.ResourceAttributeRead, error)
Get a resource attribute by resource key and attribute key. Usage Example:
`resourceAttribute, err := PermitClient.Api.ResourceAttributes.Get(ctx, "resource-key", "attribute-key")`
func (*ResourceAttributes) GetById ¶
func (a *ResourceAttributes) GetById(ctx context.Context, resourceKey uuid.UUID, attributeKey uuid.UUID) (*models.ResourceAttributeRead, error)
GetById gets a resource attribute by resource ID and attribute ID. Usage Example:
`resourceAttribute, err := PermitClient.Api.ResourceAttributes.GetById(ctx, uuid.New(), uuid.New())`
func (*ResourceAttributes) GetByKey ¶
func (a *ResourceAttributes) GetByKey(ctx context.Context, resourceKey string, attributeKey string) (*models.ResourceAttributeRead, error)
GetByKey gets a resource attribute by resource key and attribute key. Usage Example:
`resourceAttribute, err := PermitClient.Api.ResourceAttributes.GetByKey(ctx, "resource-key", "attribute-key")`
func (*ResourceAttributes) List ¶
func (a *ResourceAttributes) List(ctx context.Context, resourceKey string, page int, perPage int) ([]models.ResourceAttributeRead, error)
List all resource attributes of a resource, by resource key. Usage Example:
`resourceAttributes, err := PermitClient.Api.ResourceAttributes.List(ctx, "resource-key", 1, 10)`
func (*ResourceAttributes) Update ¶
func (a *ResourceAttributes) Update(ctx context.Context, resourceKey string, attributeKey string, resourceAttributeUpdate models.ResourceAttributeUpdate) (*models.ResourceAttributeRead, error)
Update a resource attribute by resource key and attribute key. Usage Example: ```
resourceAttributeUpdate := models.NewResourceAttributeUpdate()
resourceAttributeUpdate.SetType("bool")
resourceAttribute, err := PermitClient.Api.ResourceAttributes.Update(ctx, "resource-key", "attribute-key", resourceAttributeUpdate)
```
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
func NewResourcesApi ¶
func NewResourcesApi(client *openapi.APIClient, config *config.PermitConfig) *Resources
func (*Resources) Create ¶
func (r *Resources) Create(ctx context.Context, resourceCreate models.ResourceCreate) (*models.ResourceRead, error)
Create a new resource. Usage Example: ```
resourceCreate := models.NewResourceCreate("document", "Document", map[string]models.ActionBlockEditable{"read": {}, "write": {}}
resource, err := PermitClient.Api.Resources.Create(ctx, resourceCreate)
```
func (*Resources) Delete ¶
Delete a resource. Usage Example:
`err := PermitClient.Api.Resources.Delete(ctx, "my-resource")`
func (*Resources) Get ¶
Get a resource by its key. Usage Example:
`resource, err := PermitClient.Api.Resources.Get(ctx, "my-resource")`
func (*Resources) GetById ¶
func (r *Resources) GetById(ctx context.Context, resourceId uuid.UUID) (*models.ResourceRead, error)
GetById gets a resource by its ID. Usage Example:
`resource, err := PermitClient.Api.Resources.GetById(ctx, uuid.New())`
func (*Resources) GetByKey ¶
GetByKey gets a resource by its key. Usage Example:
`resource, err := PermitClient.Api.Resources.GetByKey(ctx, "my-resource")`
func (*Resources) List ¶
List all the resources in the current environment. Usage Example:
`resources, err := PermitClient.Api.Resources.List(ctx, 1, 10)`
func (*Resources) Update ¶
func (r *Resources) Update(ctx context.Context, resourceKey string, resourceUpdate models.ResourceUpdate) (*models.ResourceRead, error)
Update a resource. Usage Example: ```
resourceUpdate := models.NewResourceUpdate()
resourceUpdate.SetActions(map[string]models.ActionBlockEditable{"read": {}, "write": {}}
resource, err := PermitClient.Api.Resources.Update(ctx, "my-resource", resourceUpdate)
```
type Roles ¶
type Roles struct {
// contains filtered or unexported fields
}
func NewRolesApi ¶
func NewRolesApi(client *openapi.APIClient, config *config.PermitConfig) *Roles
func (*Roles) AddParentRole ¶
AddParentRole add a parent role to a role, by role key and parent role key. Makes a role extend the parent role. In other words, a role will automatically be assigned any permissions that are granted to the parent role. We can say the role extends the parent role or inherits from the parent role. Usage Example: `err := PermitClient.Api.Roles.AddParentRole(ctx, "role-key", "parent-role-key")`
func (*Roles) AssignPermissions ¶
AssignPermissions assign permissions to a role, by role key and list of permission keys. If a permission is already granted to the role it is skipped. Each permission can be either a resource-action key, or {resource_key}:{action_key}, i.e: the "document:read". Usage Example: `err := PermitClient.Api.Roles.AssignPermissions(ctx, "role-key", []string{"document:read", "document:write"})`
func (*Roles) Create ¶
Create a new role. Usage Example: ``` roleCreate := models.NewRoleCreate("role-key", "role-name") role, err := PermitClient.Api.Roles.Create(ctx, roleCreate) ```
func (*Roles) Delete ¶
Delete a role. Usage Example: `err := PermitClient.Api.Roles.Delete(ctx, "role-key")`
func (*Roles) Get ¶
Get a role by key. Usage Example: `role, err := PermitClient.Api.Roles.Get(ctx, "role-key")`
func (*Roles) GetById ¶
GetById get a role by id. Usage Example: `role, err := PermitClient.Api.Roles.GetById(ctx, uuid.New())`
func (*Roles) GetByKey ¶
GetByKey get a role by key. Usage Example: `role, err := PermitClient.Api.Roles.GetByKey(ctx, "role-key")`
func (*Roles) List ¶
List all roles in the current environment. Usage Example: `roles, err := PermitClient.Api.Roles.List(ctx,1, 10)`
func (*Roles) ListByAttributes ¶ added in v0.0.9
func (r *Roles) ListByAttributes(ctx context.Context, page int, perPage int, attributesFilter map[string]interface{}) ([]models.RoleRead, error)
List all roles in the current environment by attributes filter Usage Example: `roles, err := PermitClient.Api.Roles.List(ctx,1, 10, map[string]string{"attribute": "xyz"})`
func (*Roles) RemoveParentRole ¶
RemoveParentRole remove a parent role from a role, by role key and parent role key. Usage Example: `err := PermitClient.Api.Roles.RemoveParentRole(ctx, "role-key", "parent-role-key")`
func (*Roles) RemovePermissions ¶
RemovePermissions remove permissions from a role, by role key and list of permission keys. If a permission is not found it is skipped. Each permission can be either a resource-action key, or {resource_key}:{action_key}, i.e: the "document:read". Usage Example: `err := PermitClient.Api.Roles.RemovePermissions(ctx, "role-key", []string{"document:read", "document:write"})`
func (*Roles) Update ¶
func (r *Roles) Update(ctx context.Context, roleKey string, roleUpdate models.RoleUpdate) (*models.RoleRead, error)
Update a role. Usage Example: ``` roleUpdate := models.NewRoleUpdate() roleUpdate.SetName("new-role-name") role, err := PermitClient.Api.Roles.Update(ctx, "role-key", roleUpdate) ```
type Tenants ¶
type Tenants struct {
// contains filtered or unexported fields
}
func NewTenantsApi ¶
func NewTenantsApi(client *openapi.APIClient, config *config.PermitConfig) *Tenants
func (*Tenants) Create ¶
func (t *Tenants) Create(ctx context.Context, tenantCreate models.TenantCreate) (*models.TenantRead, error)
Create a new tenant under the context's environment. Usage Example: ``` tenantCreate := models.NewTenantCreate("tenant-key", "tenant-name") tenant, err := PermitClient.Api.Tenants.Create(ctx, tenantCreate) ```
func (*Tenants) Delete ¶
Delete a tenant under the context's environment. Usage Example: `err := PermitClient.Api.Tenants.Delete(ctx, "tenant-key")`
func (*Tenants) Get ¶
Get a tenant under the context's environment - by a given tenant key. Usage Example: `tenant, err := PermitClient.Api.Tenants.Get(ctx, "tenant-key")`
func (*Tenants) GetById ¶
GetById gets a tenant under the context's environment - by a given tenant id. Usage Example: `tenant, err := PermitClient.Api.Tenants.GetById(ctx, uuid.New())`
func (*Tenants) GetByKey ¶
GetByKey gets a tenant under the context's environment - by a given tenant key. Usage Example: `tenant, err := PermitClient.Api.Tenants.GetByKey(ctx, "tenant-key")`
func (*Tenants) List ¶
List all tenants under the context's environment. Usage Example: `tenants, err := PermitClient.Api.Tenants.List(ctx, 1, 10)`
func (*Tenants) ListByAttributes ¶ added in v0.0.9
func (t *Tenants) ListByAttributes(ctx context.Context, attributes map[string]interface{}, page int, perPage int) ([]models.TenantRead, error)
ListTenantsByAttributes gets tenants under the context's environment - by a given attributes. Usage Example: `tenants, err := PermitClient.Api.Tenants.ListTenantsByAttributes(ctx, map[string]string{"key": "value"})`
func (*Tenants) Update ¶
func (t *Tenants) Update(ctx context.Context, tenantKey string, tenantUpdate models.TenantUpdate) (*models.TenantRead, error)
Update a tenant under the context's environment. Usage Example: ``` tenantUpdate := models.NewTenantUpdate() tenantUpdate.SetName("new-tenant-name") tenant, err := PermitClient.Api.Tenants.Update(ctx, "tenant-key", tenantUpdate) ```
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
func NewUsersApi ¶
func NewUsersApi(client *openapi.APIClient, config *config.PermitConfig) *Users
func (*Users) AssignRole ¶
func (u *Users) AssignRole(ctx context.Context, userKey string, roleKey string, tenantKey string) (*models.RoleAssignmentRead, error)
AssignRole assigns a role to a user in your context's environment, by user key, role key and tenant key. Usage Example: `roleAssignment, err := PermitClient.Api.Users.AssignRole(ctx, "user-key", "role-key", "default")`
func (*Users) Create ¶
Create a user in your context's environment. Usage Example: ```
userCreate := models.NewUserCreate("user-key")
userCreate.SetEmail("user-email@mail.com")
userCreate.SetFirstName("user-first-name")
userCreate.SetLastName("user-last-name")
user, err := PermitClient.Api.Users.Create(ctx, userCreate)
```
func (*Users) Delete ¶
Delete a user from your context's environment. Usage Example:
`err := PermitClient.Api.Users.Delete(ctx, "user-key")`
func (*Users) Get ¶
Get a user from your context's environment. Usage Example:
`user, err := PermitClient.Api.Users.Get(ctx, "user-key")`
func (*Users) GetAssignedRoles ¶
func (u *Users) GetAssignedRoles(ctx context.Context, userKey string, tenantKey string, page int, perPage int) ([]models.RoleAssignmentRead, error)
GetAssignedRoles lists all roles assigned to a user in your context's environment, by user key, tenant key and pagination options. Usage Example: ```
`roleAssignmentList, err := PermitClient.Api.Users.GetAssignedRoles(ctx, "user-key", "default", 1, 10)`
func (*Users) GetById ¶
GetById gets a user by id from your context's environment. Usage Example:
`user, err := PermitClient.Api.Users.GetById(ctx, uuid.New())`
func (*Users) GetByKey ¶
GetByKey gets a user by key from your context's environment. Usage Example:
`user, err := PermitClient.Api.Users.GetByKey(ctx, "user-key")`
func (*Users) List ¶
List the users from your context's environment. Usage Example:
`users, err := PermitClient.Api.Users.List(ctx, 1, 10)`
func (*Users) SyncUser ¶
SyncUser syncs a user in your context's environment, by user. Usage Example: ``` userCreate := *models.NewUserCreate("user-key") userCreate.SetEmail("user-email") userCreate.SetFirstName("user-first-name") userCreate.SetLastName("user-last-name") user, err := PermitClient.Api.Users.SyncUser(ctx, userCreate) ```
func (*Users) UnassignRole ¶
func (u *Users) UnassignRole(ctx context.Context, userKey string, roleKey string, tenantKey string) (*models.UserRead, error)
UnassignRole unassigns a role from a user in your context's environment, by user key, role key and tenant key. Usage Example: `err := PermitClient.Api.Users.UnassignRole(ctx, "user-key", "role-key", "default")`
func (*Users) Update ¶
func (u *Users) Update(ctx context.Context, userKey string, userUpdate models.UserUpdate) (*models.UserRead, error)
Update a user in your context's environment. Usage Example: ```
userUpdate := models.NewUserUpdate()
userUpdate.SetEmail("new@email.com")
userUpdate.SetFirstName("new-first-name")
userUpdate.SetLastName("new-last-name")
user, err := PermitClient.Api.Users.Update(ctx, "user-key", userUpdate)
```