tenant

package
v0.0.0-...-68463a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright 2022 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

View Source
const (
	// devices endpoint
	UriBase         = "/api/internal/v1/tenantadm"
	GetTenantsUri   = UriBase + "/tenants"
	UsersUri        = UriBase + "/users"
	TenantsUsersUri = UriBase + "/tenants/#tid/users/#uid"
	URIHealth       = UriBase + "/health"
)

Variables

View Source
var (
	ErrDuplicateUser = errors.New("user with the same name already exists")
	ErrUserNotFound  = errors.New("user not found")
)

Functions

func JoinURL

func JoinURL(base, url string) string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an opaque implementation of tenantadm api client. Implements ClientRunner interface

func NewClient

func NewClient(conf Config) *Client

func (*Client) CheckHealth

func (c *Client) CheckHealth(ctx context.Context) error

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, user *User, client apiclient.HttpRunner) error

func (*Client) DeleteUser

func (c *Client) DeleteUser(
	ctx context.Context,
	tenantId,
	userId string,
	client apiclient.HttpRunner,
) error

func (*Client) GetTenant

func (c *Client) GetTenant(
	ctx context.Context,
	username string,
	client apiclient.HttpRunner,
) (*Tenant, error)

func (*Client) UpdateUser

func (c *Client) UpdateUser(
	ctx context.Context,
	tenantId,
	userId string,
	u *UserUpdate,
	client apiclient.HttpRunner,
) error

type ClientRunner

type ClientRunner interface {
	CheckHealth(ctx context.Context) error
	GetTenant(ctx context.Context, username string, client apiclient.HttpRunner) (*Tenant, error)
	CreateUser(ctx context.Context, user *User, client apiclient.HttpRunner) error
	UpdateUser(
		ctx context.Context,
		tenantId,
		userId string,
		u *UserUpdate,
		client apiclient.HttpRunner,
	) error
	DeleteUser(ctx context.Context, tenantId, clientId string, client apiclient.HttpRunner) error
}

ClientRunner is an interface of tenantadm api client

type Config

type Config struct {
	// tenantadm  service address
	TenantAdmAddr string
	// request timeout
	Timeout time.Duration
}

ClientConfig conveys client configuration

type Tenant

type Tenant struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
}

Tenant is the tenantadm's api struct

type User

type User struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	TenantID string `json:"tenant_id"`
}

User is the tenantadm's api struct

type UserUpdate

type UserUpdate struct {
	Name string `json:"name"`
}

UserUpdate is the tenantadm's api struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL