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
- Variables
- func JoinURL(base, url string) string
- type Client
- func (c *Client) CheckHealth(ctx context.Context) error
- func (c *Client) CreateUser(ctx context.Context, user *User, client apiclient.HttpRunner) error
- func (c *Client) DeleteUser(ctx context.Context, tenantId, userId string, client apiclient.HttpRunner) error
- func (c *Client) GetTenant(ctx context.Context, username string, client apiclient.HttpRunner) (*Tenant, error)
- func (c *Client) UpdateUser(ctx context.Context, tenantId, userId string, u *UserUpdate, ...) error
- type ClientRunner
- type Config
- type Tenant
- type User
- type UserUpdate
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 ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an opaque implementation of tenantadm api client. Implements ClientRunner interface
func (*Client) CreateUser ¶
func (*Client) DeleteUser ¶
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
Click to show internal directories.
Click to hide internal directories.