Repository navigation
Expand file tree
/
Copy pathaction_gateway_users.go
More file actions
146 lines (127 loc) · 6.33 KB
/
Copy pathaction_gateway_users.go
File metadata and controls
146 lines (127 loc) · 6.33 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package godo
import (
"context"
"net/http"
)
// ActionGatewayUsersService exposes end-user summaries.
type ActionGatewayUsersService struct{ client *Client }
// ActionGatewayUserSession is a session associated with an end user.
type ActionGatewayUserSession struct {
SessionURN string `json:"session_urn"`
Name string `json:"name"`
CreatedAt *Timestamp `json:"created_at"`
UpdatedAt *Timestamp `json:"updated_at"`
}
// ActionGatewayUserConnection is a connection associated with an end user.
type ActionGatewayUserConnection struct {
ID string `json:"id"`
Provider string `json:"provider"`
ProviderDisplayName string `json:"provider_display_name"`
UserID string `json:"user_id"`
Scopes []string `json:"scopes"`
Status string `json:"status"`
GrantedAt *Timestamp `json:"granted_at"`
RevokedAt *Timestamp `json:"revoked_at"`
CreatedAt *Timestamp `json:"created_at"`
UpdatedAt *Timestamp `json:"updated_at"`
ConnectionParameters map[string]interface{} `json:"connection_parameters"`
CredentialKind string `json:"credential_kind"`
CredentialID string `json:"credential_id"`
Network *ActionGatewayConnectionNetwork `json:"network"`
OwningUserID string `json:"owning_user_id"`
OwningUserNumericID string `json:"owning_user_numeric_id"`
}
// ActionGatewayUser is a derived end-user summary.
type ActionGatewayUser struct {
UserID string `json:"user_id"`
Sessions []ActionGatewayUserSession `json:"sessions"`
Connections []ActionGatewayUserConnection `json:"connections"`
}
// ActionGatewayUsersResponse contains offset-paginated end-user IDs.
type ActionGatewayUsersResponse struct {
UserIDs []string `json:"user_ids"`
Pagination *ActionGatewayPagination `json:"pagination"`
}
// ActionGatewayUserResponse contains one end-user summary.
type ActionGatewayUserResponse struct {
User *ActionGatewayUser `json:"user"`
}
// ActionGatewayUsersListOptions filters end users.
type ActionGatewayUsersListOptions struct {
UserID string `url:"user_id,omitempty"`
Sort string `url:"sort,omitempty"`
SortDirection string `url:"sort_direction,omitempty"`
Page int `url:"page,omitempty"`
PerPage int `url:"per_page,omitempty"`
}
// List lists end-user IDs.
func (s *ActionGatewayUsersService) List(ctx context.Context, opt *ActionGatewayUsersListOptions) (*ActionGatewayUsersResponse, *Response, error) {
return actionGatewayRequest[ActionGatewayUsersResponse](ctx, s.client, http.MethodGet, actionGatewayPath+"/users", opt, nil)
}
// Get retrieves an end-user summary.
func (s *ActionGatewayUsersService) Get(ctx context.Context, userID string) (*ActionGatewayUserResponse, *Response, error) {
path, err := actionGatewayItem(actionGatewayPath+"/users", actionGatewayPathPart{"userID", userID})
if err != nil {
return nil, nil, err
}
return actionGatewayRequest[ActionGatewayUserResponse](ctx, s.client, http.MethodGet, path, nil, nil)
}
// ActionGatewayActorLimitsService manages end-user rate-limit overrides.
type ActionGatewayActorLimitsService struct{ client *Client }
// ActionGatewayLimitOverride changes one quota category.
type ActionGatewayLimitOverride struct {
Category string `json:"category"`
RequestsPerMinute string `json:"requests_per_minute"`
}
// ActionGatewayToolQuotas lists effective per-minute limits.
type ActionGatewayToolQuotas struct {
WebSearchRequestsPerMinute string `json:"web_search_requests_per_minute"`
WebFetchRequestsPerMinute string `json:"web_fetch_requests_per_minute"`
NativeToolCallsRequestsPerMinute string `json:"native_tool_calls_requests_per_minute"`
NonNativeToolCallsRequestsPerMinute string `json:"non_native_tool_calls_requests_per_minute"`
}
// ActionGatewayActorLimitsResponse contains overrides and effective quotas.
type ActionGatewayActorLimitsResponse struct {
ConfiguredLimits []ActionGatewayLimitOverride `json:"configured_limits"`
EffectiveLimits *ActionGatewayToolQuotas `json:"effective_limits"`
}
// ActionGatewaySetLimitsRequest supplies one or more overrides.
type ActionGatewaySetLimitsRequest struct {
Overrides []ActionGatewayLimitOverride `json:"overrides"`
}
// ActionGatewayClearLimitsRequest selects categories to clear.
type ActionGatewayClearLimitsRequest struct {
Categories []string `json:"categories"`
}
// Get retrieves an actor's configured and effective limits.
func (s *ActionGatewayActorLimitsService) Get(ctx context.Context, actorID string) (*ActionGatewayActorLimitsResponse, *Response, error) {
path, err := actionGatewayItem(actionGatewayPath+"/actors", actionGatewayPathPart{"actorID", actorID})
if err != nil {
return nil, nil, err
}
return actionGatewayRequest[ActionGatewayActorLimitsResponse](ctx, s.client, http.MethodGet, path+"/limits", nil, nil)
}
// Set changes selected limit categories using the public limits:set action.
func (s *ActionGatewayActorLimitsService) Set(ctx context.Context, actorID string, body *ActionGatewaySetLimitsRequest) (*Response, error) {
if body == nil {
return nil, NewArgError("body", "cannot be nil")
}
path, err := actionGatewayItem(actionGatewayPath+"/actors", actionGatewayPathPart{"actorID", actorID})
if err != nil {
return nil, err
}
_, response, err := actionGatewayRequest[struct{}](ctx, s.client, http.MethodPost, path+"/limits:set", nil, body)
return response, err
}
// Clear removes selected overrides using the public limits:clear action.
func (s *ActionGatewayActorLimitsService) Clear(ctx context.Context, actorID string, body *ActionGatewayClearLimitsRequest) (*Response, error) {
if body == nil {
return nil, NewArgError("body", "cannot be nil")
}
path, err := actionGatewayItem(actionGatewayPath+"/actors", actionGatewayPathPart{"actorID", actorID})
if err != nil {
return nil, err
}
_, response, err := actionGatewayRequest[struct{}](ctx, s.client, http.MethodPost, path+"/limits:clear", nil, body)
return response, err
}