Skip to content

Commit

Permalink
Release v1.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
polytomic-sdk-bot committed Aug 26, 2024
1 parent 3abe234 commit e1000f1
Show file tree
Hide file tree
Showing 12 changed files with 460 additions and 8 deletions.
4 changes: 4 additions & 0 deletions bulk_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type BulkSyncGetSourceRequest struct {
IncludeFields *bool `json:"-" url:"include_fields,omitempty"`
}

type BulkSyncListRequest struct {
Active *bool `json:"-" url:"active,omitempty"`
}

type BulkSyncRemoveRequest struct {
RefreshSchemas *bool `json:"-" url:"refresh_schemas,omitempty"`
}
Expand Down
9 changes: 9 additions & 0 deletions bulksync/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func NewClient(opts ...option.RequestOption) *Client {

func (c *Client) List(
ctx context.Context,
request *polytomicgo.BulkSyncListRequest,
opts ...option.RequestOption,
) (*polytomicgo.BulkSyncListEnvelope, error) {
options := core.NewRequestOptions(opts...)
Expand All @@ -57,6 +58,14 @@ func (c *Client) List(
}
endpointURL := baseURL + "/" + "api/bulk/syncs"

queryParams, err := core.QueryValues(request)
if err != nil {
return nil, err
}
if len(queryParams) > 0 {
endpointURL += "?" + queryParams.Encode()
}

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

errorDecoder := func(statusCode int, body io.Reader) error {
Expand Down
5 changes: 5 additions & 0 deletions bulksync/executions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

package bulksync

type ExecutionsExportLogsRequest struct {
// Send a notification to the user when the logs are ready for download.
Notify *bool `json:"-" url:"notify,omitempty"`
}

type ExecutionsListStatusRequest struct {
// Return the execution status of all syncs in the organization
All *bool `json:"-" url:"all,omitempty"`
Expand Down
149 changes: 149 additions & 0 deletions bulksync/executions/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,152 @@ func (c *Client) Get(
}
return response, nil
}

func (c *Client) GetLogs(
ctx context.Context,
syncId string,
executionId string,
opts ...option.RequestOption,
) (*polytomicgo.V4BulkSyncExecutionLogsEnvelope, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://app.polytomic.com"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"api/bulk/syncs/%v/executions/%v/logs", syncId, executionId)

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 401:
value := new(polytomicgo.UnauthorizedError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 404:
value := new(polytomicgo.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *polytomicgo.V4BulkSyncExecutionLogsEnvelope
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) ExportLogs(
ctx context.Context,
syncId string,
executionId string,
request *bulksync.ExecutionsExportLogsRequest,
opts ...option.RequestOption,
) (*polytomicgo.V4ExportSyncLogsEnvelope, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://app.polytomic.com"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"api/bulk/syncs/%v/executions/%v/logs/export", syncId, executionId)

queryParams, err := core.QueryValues(request)
if err != nil {
return nil, err
}
if len(queryParams) > 0 {
endpointURL += "?" + queryParams.Encode()
}

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(polytomicgo.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 401:
value := new(polytomicgo.UnauthorizedError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 404:
value := new(polytomicgo.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 500:
value := new(polytomicgo.InternalServerError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *polytomicgo.V4ExportSyncLogsEnvelope
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodPost,
MaxAttempts: options.MaxAttempts,
Headers: headers,
Client: options.HTTPClient,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return nil, err
}
return response, nil
}
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type Client struct {
BulkSync *bulksyncclient.Client
Connections *connections.Client
QueryRunner *queryrunner.Client
Models *models.Client
ModelSync *modelsyncclient.Client
Schemas *schemas.Client
Models *models.Client
Events *events.Client
Jobs *jobs.Client
Identity *identity.Client
Expand All @@ -55,9 +55,9 @@ func NewClient(opts ...option.RequestOption) *Client {
BulkSync: bulksyncclient.NewClient(opts...),
Connections: connections.NewClient(opts...),
QueryRunner: queryrunner.NewClient(opts...),
Models: models.NewClient(opts...),
ModelSync: modelsyncclient.NewClient(opts...),
Schemas: schemas.NewClient(opts...),
Models: models.NewClient(opts...),
Events: events.NewClient(opts...),
Jobs: jobs.NewClient(opts...),
Identity: identity.NewClient(opts...),
Expand Down
2 changes: 1 addition & 1 deletion core/request_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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/polytomic/polytomic-go")
headers.Set("X-Fern-SDK-Version", "v1.9.0")
headers.Set("X-Fern-SDK-Version", "v1.9.1")
return headers
}

Expand Down
6 changes: 6 additions & 0 deletions model_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ type ModelSyncGetTargetFieldsRequest struct {
Refresh *bool `json:"-" url:"refresh,omitempty"`
}

type ModelSyncListRequest struct {
Active *bool `json:"-" url:"active,omitempty"`
Mode *SyncMode `json:"-" url:"mode,omitempty"`
TargetConnectionId *string `json:"-" url:"target_connection_id,omitempty"`
}

type StartModelSyncRequest struct {
Identities []string `json:"identities,omitempty" url:"identities,omitempty"`
Resync *bool `json:"resync,omitempty" url:"resync,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type ModelsGetRequest struct {
Async *bool `json:"-" url:"async,omitempty"`
}

type ModelsGetEnrichmentSourceRequest struct {
Params map[string][]string `json:"-" url:"params,omitempty"`
}

type GetEnrichmentInputFieldsRequest struct {
Configuration *V2EnricherConfiguration `json:"configuration,omitempty" url:"configuration,omitempty"`
}
Expand Down
92 changes: 92 additions & 0 deletions models/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,98 @@ func NewClient(opts ...option.RequestOption) *Client {
}
}

func (c *Client) GetEnrichmentSource(
ctx context.Context,
id string,
request *polytomicgo.ModelsGetEnrichmentSourceRequest,
opts ...option.RequestOption,
) (*polytomicgo.GetModelSyncSourceMetaEnvelope, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://app.polytomic.com"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"api/connections/%v/modelsync/enrichment-source", id)

queryParams, err := core.QueryValues(request)
if err != nil {
return nil, err
}
if len(queryParams) > 0 {
endpointURL += "?" + queryParams.Encode()
}

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(polytomicgo.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 401:
value := new(polytomicgo.UnauthorizedError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 403:
value := new(polytomicgo.ForbiddenError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 404:
value := new(polytomicgo.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 500:
value := new(polytomicgo.InternalServerError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *polytomicgo.GetModelSyncSourceMetaEnvelope
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
}

// For a given connection and enrichment configuration, provides the valid sets of input fields.
func (c *Client) Post(
ctx context.Context,
Expand Down
16 changes: 16 additions & 0 deletions modelsync/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ func (c *Client) GetTargetObjects(

func (c *Client) List(
ctx context.Context,
request *polytomicgo.ModelSyncListRequest,
opts ...option.RequestOption,
) (*polytomicgo.ListModelSyncResponseEnvelope, error) {
options := core.NewRequestOptions(opts...)
Expand All @@ -489,6 +490,14 @@ func (c *Client) List(
}
endpointURL := baseURL + "/" + "api/syncs"

queryParams, err := core.QueryValues(request)
if err != nil {
return nil, err
}
if len(queryParams) > 0 {
endpointURL += "?" + queryParams.Encode()
}

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

errorDecoder := func(statusCode int, body io.Reader) error {
Expand All @@ -499,6 +508,13 @@ func (c *Client) List(
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 400:
value := new(polytomicgo.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 401:
value := new(polytomicgo.UnauthorizedError)
value.APIError = apiError
Expand Down
Loading

0 comments on commit e1000f1

Please sign in to comment.