29 lines
604 B
Go
29 lines
604 B
Go
|
package client
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"forge.cadoles.com/Cadoles/emissary/internal/server/api"
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
func (c *Client) CreateTenant(ctx context.Context, label string, funcs ...OptionFunc) (*Tenant, error) {
|
||
|
response := withResponse[struct {
|
||
|
Tenant *Tenant `json:"tenant"`
|
||
|
}]()
|
||
|
|
||
|
payload := api.CreateTenantRequest{
|
||
|
Label: label,
|
||
|
}
|
||
|
|
||
|
if err := c.apiPost(ctx, "/api/v1/tenants", payload, &response, funcs...); err != nil {
|
||
|
return nil, errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
if response.Error != nil {
|
||
|
return nil, errors.WithStack(response.Error)
|
||
|
}
|
||
|
|
||
|
return response.Data.Tenant, nil
|
||
|
}
|