emissary/pkg/client/create_tenant.go

29 lines
604 B
Go
Raw Permalink Normal View History

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
}