CreateProvisionerKey creates a new provisioner key for an organization.
(ctx context.Context, organizationID uuid.UUID, req CreateProvisionerKeyRequest)
| 422 | |
| 423 | // CreateProvisionerKey creates a new provisioner key for an organization. |
| 424 | func (c *Client) CreateProvisionerKey(ctx context.Context, organizationID uuid.UUID, req CreateProvisionerKeyRequest) (CreateProvisionerKeyResponse, error) { |
| 425 | res, err := c.Request(ctx, http.MethodPost, |
| 426 | fmt.Sprintf("/api/v2/organizations/%s/provisionerkeys", organizationID.String()), |
| 427 | req, |
| 428 | ) |
| 429 | if err != nil { |
| 430 | return CreateProvisionerKeyResponse{}, xerrors.Errorf("make request: %w", err) |
| 431 | } |
| 432 | defer res.Body.Close() |
| 433 | |
| 434 | if res.StatusCode != http.StatusCreated { |
| 435 | return CreateProvisionerKeyResponse{}, ReadBodyAsError(res) |
| 436 | } |
| 437 | var resp CreateProvisionerKeyResponse |
| 438 | return resp, json.NewDecoder(res.Body).Decode(&resp) |
| 439 | } |
| 440 | |
| 441 | // ListProvisionerKeys lists all provisioner keys for an organization. |
| 442 | func (c *Client) ListProvisionerKeys(ctx context.Context, organizationID uuid.UUID) ([]ProvisionerKey, error) { |