-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathapi_keys.go
More file actions
68 lines (58 loc) · 2.77 KB
/
api_keys.go
File metadata and controls
68 lines (58 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Code generated by oagen. DO NOT EDIT.
package workos
import (
"context"
"fmt"
"net/url"
)
// APIKeyService handles ApiKeys operations.
type APIKeyService struct {
client *Client
}
// APIKeysListOrganizationAPIKeysParams contains the parameters for ListOrganizationAPIKeys.
type APIKeysListOrganizationAPIKeysParams struct {
PaginationParams
}
// ListOrganizationAPIKeys list API keys for an organization
// Get a list of all API keys for an organization.
func (s *APIKeyService) ListOrganizationAPIKeys(ctx context.Context, organizationID string, params *APIKeysListOrganizationAPIKeysParams, opts ...RequestOption) *Iterator[OrganizationAPIKey] {
return newIterator[OrganizationAPIKey](ctx, s.client, "GET", fmt.Sprintf("/organizations/%s/api_keys", url.PathEscape(organizationID)), params, "after", "data", opts, map[string]string{"limit": "10", "order": "desc"})
}
// APIKeysCreateOrganizationAPIKeyParams contains the parameters for CreateOrganizationAPIKey.
type APIKeysCreateOrganizationAPIKeyParams struct {
// Name is the name for the API key.
Name string `json:"name" url:"-"`
// Permissions is the permission slugs to assign to the API key.
Permissions []string `json:"permissions,omitempty" url:"-"`
}
// CreateOrganizationAPIKey create an API key for an organization
// Create a new API key for an organization.
func (s *APIKeyService) CreateOrganizationAPIKey(ctx context.Context, organizationID string, params *APIKeysCreateOrganizationAPIKeyParams, opts ...RequestOption) (*OrganizationAPIKeyWithValue, error) {
var result OrganizationAPIKeyWithValue
_, err := s.client.request(ctx, "POST", fmt.Sprintf("/organizations/%s/api_keys", url.PathEscape(organizationID)), nil, params, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// APIKeysCreateValidationParams contains the parameters for CreateValidation.
type APIKeysCreateValidationParams struct {
// Value is the value for an API key.
Value string `json:"value" url:"-"`
}
// CreateValidation validate API key
// Validate an API key value and return the API key object if valid.
func (s *APIKeyService) CreateValidation(ctx context.Context, params *APIKeysCreateValidationParams, opts ...RequestOption) (*APIKeyValidationResponse, error) {
var result APIKeyValidationResponse
_, err := s.client.request(ctx, "POST", "/api_keys/validations", nil, params, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// Delete an API key
// Permanently deletes an API key. This action cannot be undone. Once deleted, any requests using this API key will fail authentication.
func (s *APIKeyService) Delete(ctx context.Context, id string, opts ...RequestOption) error {
_, err := s.client.request(ctx, "DELETE", fmt.Sprintf("/api_keys/%s", url.PathEscape(id)), nil, nil, nil, opts)
return err
}