-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathadminuserconnection.go
More file actions
157 lines (139 loc) · 5.64 KB
/
Copy pathadminuserconnection.go
File metadata and controls
157 lines (139 loc) · 5.64 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
147
148
149
150
151
152
153
154
155
156
157
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package arcadego
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"github.com/ArcadeAI/arcade-go/internal/apijson"
"github.com/ArcadeAI/arcade-go/internal/apiquery"
"github.com/ArcadeAI/arcade-go/internal/param"
"github.com/ArcadeAI/arcade-go/internal/requestconfig"
"github.com/ArcadeAI/arcade-go/option"
"github.com/ArcadeAI/arcade-go/packages/pagination"
)
// AdminUserConnectionService contains methods and other services that help with
// interacting with the Arcade API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewAdminUserConnectionService] method instead.
type AdminUserConnectionService struct {
Options []option.RequestOption
}
// NewAdminUserConnectionService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewAdminUserConnectionService(opts ...option.RequestOption) (r *AdminUserConnectionService) {
r = &AdminUserConnectionService{}
r.Options = opts
return
}
// List all auth connections
func (r *AdminUserConnectionService) List(ctx context.Context, query AdminUserConnectionListParams, opts ...option.RequestOption) (res *pagination.OffsetPage[UserConnectionResponse], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "v1/admin/user_connections"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// List all auth connections
func (r *AdminUserConnectionService) ListAutoPaging(ctx context.Context, query AdminUserConnectionListParams, opts ...option.RequestOption) *pagination.OffsetPageAutoPager[UserConnectionResponse] {
return pagination.NewOffsetPageAutoPager(r.List(ctx, query, opts...))
}
// Delete a user/auth provider connection
func (r *AdminUserConnectionService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("v1/admin/user_connections/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return
}
type UserConnectionResponse struct {
ID string `json:"id"`
ConnectionID string `json:"connection_id"`
ConnectionStatus string `json:"connection_status"`
ProviderDescription string `json:"provider_description"`
ProviderID string `json:"provider_id"`
ProviderType string `json:"provider_type"`
ProviderUserInfo interface{} `json:"provider_user_info"`
Scopes []string `json:"scopes"`
UserID string `json:"user_id"`
JSON userConnectionResponseJSON `json:"-"`
}
// userConnectionResponseJSON contains the JSON metadata for the struct
// [UserConnectionResponse]
type userConnectionResponseJSON struct {
ID apijson.Field
ConnectionID apijson.Field
ConnectionStatus apijson.Field
ProviderDescription apijson.Field
ProviderID apijson.Field
ProviderType apijson.Field
ProviderUserInfo apijson.Field
Scopes apijson.Field
UserID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *UserConnectionResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r userConnectionResponseJSON) RawJSON() string {
return r.raw
}
type AdminUserConnectionListParams struct {
// Page size
Limit param.Field[int64] `query:"limit"`
// Page offset
Offset param.Field[int64] `query:"offset"`
Provider param.Field[AdminUserConnectionListParamsProvider] `query:"provider"`
User param.Field[AdminUserConnectionListParamsUser] `query:"user"`
}
// URLQuery serializes [AdminUserConnectionListParams]'s query parameters as
// `url.Values`.
func (r AdminUserConnectionListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type AdminUserConnectionListParamsProvider struct {
// Provider ID
ID param.Field[string] `query:"id"`
}
// URLQuery serializes [AdminUserConnectionListParamsProvider]'s query parameters
// as `url.Values`.
func (r AdminUserConnectionListParamsProvider) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type AdminUserConnectionListParamsUser struct {
// User ID
ID param.Field[string] `query:"id"`
}
// URLQuery serializes [AdminUserConnectionListParamsUser]'s query parameters as
// `url.Values`.
func (r AdminUserConnectionListParamsUser) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}