-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandboxjob.go
97 lines (82 loc) · 3.23 KB
/
sandboxjob.go
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package finchgo
import (
"context"
"net/http"
"github.com/Finch-API/finch-api-go/internal/apijson"
"github.com/Finch-API/finch-api-go/internal/param"
"github.com/Finch-API/finch-api-go/internal/requestconfig"
"github.com/Finch-API/finch-api-go/option"
)
// SandboxJobService contains methods and other services that help with interacting
// with the Finch 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 [NewSandboxJobService] method instead.
type SandboxJobService struct {
Options []option.RequestOption
Configuration *SandboxJobConfigurationService
}
// NewSandboxJobService 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 NewSandboxJobService(opts ...option.RequestOption) (r *SandboxJobService) {
r = &SandboxJobService{}
r.Options = opts
r.Configuration = NewSandboxJobConfigurationService(opts...)
return
}
// Enqueue a new sandbox job
func (r *SandboxJobService) New(ctx context.Context, body SandboxJobNewParams, opts ...option.RequestOption) (res *SandboxJobNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "sandbox/jobs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type SandboxJobNewResponse struct {
// The number of allowed refreshes per hour (per hour, fixed window)
AllowedRefreshes int64 `json:"allowed_refreshes,required"`
// The id of the job that has been created.
JobID string `json:"job_id,required" format:"uuid"`
// The url that can be used to retrieve the job status
JobURL string `json:"job_url,required"`
// The number of remaining refreshes available (per hour, fixed window)
RemainingRefreshes int64 `json:"remaining_refreshes,required"`
JSON sandboxJobNewResponseJSON `json:"-"`
}
// sandboxJobNewResponseJSON contains the JSON metadata for the struct
// [SandboxJobNewResponse]
type sandboxJobNewResponseJSON struct {
AllowedRefreshes apijson.Field
JobID apijson.Field
JobURL apijson.Field
RemainingRefreshes apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *SandboxJobNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r sandboxJobNewResponseJSON) RawJSON() string {
return r.raw
}
type SandboxJobNewParams struct {
// The type of job to start. Currently the only supported type is `data_sync_all`
Type param.Field[SandboxJobNewParamsType] `json:"type,required"`
}
func (r SandboxJobNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The type of job to start. Currently the only supported type is `data_sync_all`
type SandboxJobNewParamsType string
const (
SandboxJobNewParamsTypeDataSyncAll SandboxJobNewParamsType = "data_sync_all"
)
func (r SandboxJobNewParamsType) IsKnown() bool {
switch r {
case SandboxJobNewParamsTypeDataSyncAll:
return true
}
return false
}