Skip to content

Commit

Permalink
Release v0.0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Aug 28, 2024
1 parent 43e6c93 commit 72b10cf
Show file tree
Hide file tree
Showing 10 changed files with 974 additions and 62 deletions.
82 changes: 82 additions & 0 deletions agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,47 @@ type ListAgentsRequest struct {
EnvironmentId EnvironmentId `json:"-" url:"environmentId"`
}

type AgentVersionResponse struct {
Data *AgentVersion `json:"data,omitempty" url:"data,omitempty"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
}

func (a *AgentVersionResponse) GetExtraProperties() map[string]interface{} {
return a.extraProperties
}

func (a *AgentVersionResponse) UnmarshalJSON(data []byte) error {
type unmarshaler AgentVersionResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AgentVersionResponse(value)

extraProperties, err := core.ExtractExtraProperties(data, *a)
if err != nil {
return err
}
a.extraProperties = extraProperties

a._rawJSON = json.RawMessage(data)
return nil
}

func (a *AgentVersionResponse) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}

type GetDetailedAgentLogResponse struct {
Data *DetailedAgentLog `json:"data,omitempty" url:"data,omitempty"`

Expand Down Expand Up @@ -186,3 +227,44 @@ func (g *GetExecutionsResponse) String() string {
}
return fmt.Sprintf("%#v", g)
}

type ListAgentVersionsResponse struct {
Data []*AgentVersion `json:"data,omitempty" url:"data,omitempty"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
}

func (l *ListAgentVersionsResponse) GetExtraProperties() map[string]interface{} {
return l.extraProperties
}

func (l *ListAgentVersionsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler ListAgentVersionsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = ListAgentVersionsResponse(value)

extraProperties, err := core.ExtractExtraProperties(data, *l)
if err != nil {
return err
}
l.extraProperties = extraProperties

l._rawJSON = json.RawMessage(data)
return nil
}

func (l *ListAgentVersionsResponse) String() string {
if len(l._rawJSON) > 0 {
if value, err := core.StringifyJSON(l._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
129 changes: 129 additions & 0 deletions agents/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,135 @@ func (c *Client) Get(
return response, nil
}

func (c *Client) ListVersions(
ctx context.Context,
agentId flatfilego.AgentId,
opts ...option.RequestOption,
) (*flatfilego.ListAgentVersionsResponse, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://api.x.flatfile.com/v1"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := core.EncodeURL(baseURL+"/agents/%v/versions", agentId)

headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 400:
value := new(flatfilego.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 404:
value := new(flatfilego.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *flatfilego.ListAgentVersionsResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodGet,
MaxAttempts: options.MaxAttempts,
Headers: headers,
Client: options.HTTPClient,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return nil, err
}
return response, nil
}

func (c *Client) Revert(
ctx context.Context,
agentId flatfilego.AgentId,
agentVersionId flatfilego.AgentVersionId,
opts ...option.RequestOption,
) (*flatfilego.AgentVersionResponse, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://api.x.flatfile.com/v1"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := core.EncodeURL(
baseURL+"/agents/%v/versions/%v/revert",
agentId,
agentVersionId,
)

headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 400:
value := new(flatfilego.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 404:
value := new(flatfilego.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *flatfilego.AgentVersionResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodGet,
MaxAttempts: options.MaxAttempts,
Headers: headers,
Client: options.HTTPClient,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return nil, err
}
return response, nil
}

// Lists roles assigned to an agent.
func (c *Client) ListAgentRoles(
ctx context.Context,
Expand Down
2 changes: 2 additions & 0 deletions apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type AppCreate struct {
Icon *string `json:"icon,omitempty" url:"icon,omitempty"`
Metadata interface{} `json:"metadata,omitempty" url:"metadata,omitempty"`
EnvironmentFilters interface{} `json:"environmentFilters,omitempty" url:"environmentFilters,omitempty"`
Blueprint interface{} `json:"blueprint,omitempty" url:"blueprint,omitempty"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
Expand Down Expand Up @@ -67,6 +68,7 @@ type AppPatch struct {
Icon *string `json:"icon,omitempty" url:"icon,omitempty"`
Metadata interface{} `json:"metadata,omitempty" url:"metadata,omitempty"`
EnvironmentFilters interface{} `json:"environmentFilters,omitempty" url:"environmentFilters,omitempty"`
Blueprint interface{} `json:"blueprint,omitempty" url:"blueprint,omitempty"`
ActivatedAt *time.Time `json:"activatedAt,omitempty" url:"activatedAt,omitempty"`

extraProperties map[string]interface{}
Expand Down
2 changes: 1 addition & 1 deletion core/request_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *RequestOptions) cloneHeader() http.Header {
headers := r.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/FlatFilers/flatfile-go")
headers.Set("X-Fern-SDK-Version", "v0.0.15")
headers.Set("X-Fern-SDK-Version", "v0.0.16")
return headers
}

Expand Down
2 changes: 2 additions & 0 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Action struct {
InputForm *InputForm `json:"inputForm,omitempty" url:"inputForm,omitempty"`
// A limitation or restriction on the action.
Constraints []*ActionConstraint `json:"constraints,omitempty" url:"constraints,omitempty"`
Guide *Guide `json:"guide,omitempty" url:"guide,omitempty"`
Guardrail *Guardrail `json:"guardrail,omitempty" url:"guardrail,omitempty"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
Expand Down
2 changes: 2 additions & 0 deletions jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ type JobConfig struct {
ParentId *JobId `json:"parentId,omitempty" url:"parentId,omitempty"`
// The ids of the jobs that must complete before this job can start
PredecessorIds []JobId `json:"predecessorIds,omitempty" url:"predecessorIds,omitempty"`
// Additional metadata for the job
Metadata map[string]interface{} `json:"metadata,omitempty" url:"metadata,omitempty"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
Expand Down
31 changes: 24 additions & 7 deletions records.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ type GetRecordsRequest struct {
}

type CellValueUnion struct {
String string
Integer int
Long int64
Double float64
Boolean bool
Date time.Time
DateTime time.Time
String string
Integer int
Long int64
Double float64
Boolean bool
Date time.Time
DateTime time.Time
StringList []string
}

func NewCellValueUnionFromString(value string) *CellValueUnion {
Expand Down Expand Up @@ -106,6 +107,10 @@ func NewCellValueUnionFromDateTime(value time.Time) *CellValueUnion {
return &CellValueUnion{DateTime: value}
}

func NewCellValueUnionFromStringList(value []string) *CellValueUnion {
return &CellValueUnion{StringList: value}
}

func (c *CellValueUnion) UnmarshalJSON(data []byte) error {
var valueString string
if err := json.Unmarshal(data, &valueString); err == nil {
Expand Down Expand Up @@ -142,6 +147,11 @@ func (c *CellValueUnion) UnmarshalJSON(data []byte) error {
c.DateTime = valueDateTime.Time()
return nil
}
var valueStringList []string
if err := json.Unmarshal(data, &valueStringList); err == nil {
c.StringList = valueStringList
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, c)
}

Expand All @@ -167,6 +177,9 @@ func (c CellValueUnion) MarshalJSON() ([]byte, error) {
if !c.DateTime.IsZero() {
return json.Marshal(core.NewDateTime(c.DateTime))
}
if c.StringList != nil {
return json.Marshal(c.StringList)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", c)
}

Expand All @@ -178,6 +191,7 @@ type CellValueUnionVisitor interface {
VisitBoolean(bool) error
VisitDate(time.Time) error
VisitDateTime(time.Time) error
VisitStringList([]string) error
}

func (c *CellValueUnion) Accept(visitor CellValueUnionVisitor) error {
Expand All @@ -202,6 +216,9 @@ func (c *CellValueUnion) Accept(visitor CellValueUnionVisitor) error {
if !c.DateTime.IsZero() {
return visitor.VisitDateTime(c.DateTime)
}
if c.StringList != nil {
return visitor.VisitStringList(c.StringList)
}
return fmt.Errorf("type %T does not include a non-empty union type", c)
}

Expand Down
Loading

0 comments on commit 72b10cf

Please sign in to comment.