emissary/pkg/client/delete_tenant.go

27 lines
554 B
Go

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