emissary/pkg/client/get_tenant.go

27 lines
529 B
Go
Raw Permalink Normal View History

package client
import (
"context"
"fmt"
"github.com/pkg/errors"
)
func (c *Client) GetTenant(ctx context.Context, tenantID TenantID, funcs ...OptionFunc) (*Tenant, error) {
response := withResponse[struct {
Tenant *Tenant `json:"tenant"`
}]()
path := fmt.Sprintf("/api/v1/tenants/%s", tenantID)
if err := c.apiGet(ctx, path, &response, funcs...); err != nil {
return nil, errors.WithStack(err)
}
if response.Error != nil {
return nil, errors.WithStack(response.Error)
}
return response.Data.Tenant, nil
}