Skip to content

Commit 6b617f9

Browse files
committed
Refactor function parameters and update JSON struct tags
- Changed function parameters from `<foo>ID` to just `id` for consistency across client methods. - Updated JSON struct tags in `CreateWorkflowRequest` and `UpdateWorkflowRequest` for better clarity and optional field handling. - Renamed local variable in update methods to use the name `wrapper` instead of `shadow` for clarity. - Improved error handling and consistency in job and source-related functions.
1 parent ccde280 commit 6b617f9

20 files changed

+80
-80
lines changed

destination_update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ func (c *Client) UpdateDestination(ctx context.Context, in UpdateDestinationRequ
2222
return nil, fmt.Errorf("failed to marshal config: %w", err)
2323
}
2424

25-
shadow := struct {
25+
wrapper := struct {
2626
Config json.RawMessage `json:"config"`
2727
}{
2828
Config: json.RawMessage(config),
2929
}
3030

31-
body, err := json.Marshal(shadow)
31+
body, err := json.Marshal(wrapper)
3232
if err != nil {
3333
return nil, fmt.Errorf("failed to marshal update request: %w", err)
3434
}

job.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package unstructured
22

3-
import (
4-
"time"
5-
)
3+
import "time"
64

75
// Job represents a job, which is an execution of a workflow in Unstructured.io.
86
type Job struct {

job_cancel.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
)
88

99
// CancelJob cancels a running job by its ID
10-
func (c *Client) CancelJob(ctx context.Context, jobID string) error {
10+
func (c *Client) CancelJob(ctx context.Context, id string) error {
1111
req, err := http.NewRequestWithContext(ctx,
1212
http.MethodPost,
13-
c.endpoint.JoinPath("/jobs", jobID, "cancel").String(),
13+
c.endpoint.JoinPath("/jobs", id, "cancel").String(),
1414
nil,
1515
)
1616
if err != nil {

job_details.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88

99
// GetJobDetails retrieves detailed processing information for a specific job by its ID.
1010
// It returns a JobDetails struct with node stats and processing status.
11-
func (c *Client) GetJobDetails(ctx context.Context, jobID string) (*JobDetails, error) {
11+
func (c *Client) GetJobDetails(ctx context.Context, id string) (*JobDetails, error) {
1212
req, err := http.NewRequestWithContext(ctx,
1313
http.MethodGet,
14-
c.endpoint.JoinPath("/jobs", jobID, "details").String(),
14+
c.endpoint.JoinPath("/jobs", id, "details").String(),
1515
nil,
1616
)
1717
if err != nil {

job_download.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
)
99

1010
// DownloadJob downloads the output files from a completed job
11-
func (c *Client) DownloadJob(ctx context.Context, jobID string) (io.ReadCloser, error) {
11+
func (c *Client) DownloadJob(ctx context.Context, id string) (io.ReadCloser, error) {
1212
req, err := http.NewRequestWithContext(ctx,
1313
http.MethodGet,
14-
c.endpoint.JoinPath("/jobs", jobID, "download").String(),
14+
c.endpoint.JoinPath("/jobs", id, "download").String(),
1515
nil,
1616
)
1717
if err != nil {

job_failed_files.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ import (
88

99
// GetJobFailedFiles retrieves the list of failed files for a specific job by its ID.
1010
// It returns a JobFailedFiles struct containing the failed files and error messages.
11-
func (c *Client) GetJobFailedFiles(ctx context.Context, jobID string) (*JobFailedFiles, error) {
11+
func (c *Client) GetJobFailedFiles(ctx context.Context, id string) (*JobFailedFiles, error) {
1212
req, err := http.NewRequestWithContext(ctx,
1313
http.MethodGet,
14-
c.endpoint.JoinPath("/jobs", jobID, "failed-files").String(),
14+
c.endpoint.JoinPath("/jobs", id, "failed-files").String(),
1515
nil,
1616
)
1717
if err != nil {
1818
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
1919
}
2020

21-
var failedFiles JobFailedFiles
22-
if err := c.do(req, &failedFiles); err != nil {
21+
var failed JobFailedFiles
22+
if err := c.do(req, &failed); err != nil {
2323
return nil, fmt.Errorf("failed to get job failed files: %w", err)
2424
}
2525

26-
return &failedFiles, nil
26+
return &failed, nil
2727
}

job_get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
)
88

99
// GetJob retrieves detailed information for a specific job by its ID
10-
func (c *Client) GetJob(ctx context.Context, jobID string) (*Job, error) {
10+
func (c *Client) GetJob(ctx context.Context, id string) (*Job, error) {
1111
req, err := http.NewRequestWithContext(ctx,
1212
http.MethodGet,
13-
c.endpoint.JoinPath("/jobs", jobID).String(),
13+
c.endpoint.JoinPath("/jobs", id).String(),
1414
nil,
1515
)
1616
if err != nil {

source.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ import (
99
// sourceConfigFactories maps source type strings to factory functions
1010
// that create new instances of the appropriate concrete source config type.
1111
var sourceConfigFactories = map[string]func() SourceConfig{
12-
ConnectorTypeAzure: func() SourceConfig { return &AzureSourceConnectorConfig{} },
13-
ConnectorTypeBox: func() SourceConfig { return &BoxSourceConnectorConfig{} },
14-
ConnectorTypeConfluence: func() SourceConfig { return &ConfluenceSourceConnectorConfig{} },
15-
ConnectorTypeCouchbase: func() SourceConfig { return &CouchbaseSourceConnectorConfig{} },
16-
ConnectorTypeDatabricksVolumes: func() SourceConfig { return &DatabricksVolumesConnectorConfig{} },
17-
ConnectorTypeDropbox: func() SourceConfig { return &DropboxSourceConnectorConfig{} },
18-
ConnectorTypeElasticsearch: func() SourceConfig { return &ElasticsearchConnectorConfig{} },
19-
ConnectorTypeGCS: func() SourceConfig { return &GCSSourceConnectorConfig{} },
20-
ConnectorTypeGoogleDrive: func() SourceConfig { return &GoogleDriveSourceConnectorConfig{} },
21-
ConnectorTypeJira: func() SourceConfig { return &JiraSourceConnectorConfig{} },
22-
ConnectorTypeKafkaCloud: func() SourceConfig { return &KafkaCloudSourceConnectorConfig{} },
23-
ConnectorTypeMongoDB: func() SourceConfig { return &MongoDBConnectorConfig{} },
24-
ConnectorTypeOneDrive: func() SourceConfig { return &OneDriveSourceConnectorConfig{} },
25-
ConnectorTypeOutlook: func() SourceConfig { return &OutlookSourceConnectorConfig{} },
26-
ConnectorTypePostgres: func() SourceConfig { return &PostgresSourceConnectorConfig{} },
27-
ConnectorTypeS3: func() SourceConfig { return &S3SourceConnectorConfig{} },
28-
ConnectorTypeSalesforce: func() SourceConfig { return &SalesforceSourceConnectorConfig{} },
29-
ConnectorTypeSharePoint: func() SourceConfig { return &SharePointSourceConnectorConfig{} },
30-
ConnectorTypeSlack: func() SourceConfig { return &SlackSourceConnectorConfig{} },
31-
ConnectorTypeSnowflake: func() SourceConfig { return &SnowflakeSourceConnectorConfig{} },
32-
ConnectorTypeZendesk: func() SourceConfig { return &ZendeskSourceConnectorConfig{} },
12+
ConnectorTypeAzure: func() SourceConfig { return new(AzureSourceConnectorConfig) },
13+
ConnectorTypeBox: func() SourceConfig { return new(BoxSourceConnectorConfig) },
14+
ConnectorTypeConfluence: func() SourceConfig { return new(ConfluenceSourceConnectorConfig) },
15+
ConnectorTypeCouchbase: func() SourceConfig { return new(CouchbaseSourceConnectorConfig) },
16+
ConnectorTypeDatabricksVolumes: func() SourceConfig { return new(DatabricksVolumesConnectorConfig) },
17+
ConnectorTypeDropbox: func() SourceConfig { return new(DropboxSourceConnectorConfig) },
18+
ConnectorTypeElasticsearch: func() SourceConfig { return new(ElasticsearchConnectorConfig) },
19+
ConnectorTypeGCS: func() SourceConfig { return new(GCSSourceConnectorConfig) },
20+
ConnectorTypeGoogleDrive: func() SourceConfig { return new(GoogleDriveSourceConnectorConfig) },
21+
ConnectorTypeJira: func() SourceConfig { return new(JiraSourceConnectorConfig) },
22+
ConnectorTypeKafkaCloud: func() SourceConfig { return new(KafkaCloudSourceConnectorConfig) },
23+
ConnectorTypeMongoDB: func() SourceConfig { return new(MongoDBConnectorConfig) },
24+
ConnectorTypeOneDrive: func() SourceConfig { return new(OneDriveSourceConnectorConfig) },
25+
ConnectorTypeOutlook: func() SourceConfig { return new(OutlookSourceConnectorConfig) },
26+
ConnectorTypePostgres: func() SourceConfig { return new(PostgresSourceConnectorConfig) },
27+
ConnectorTypeS3: func() SourceConfig { return new(S3SourceConnectorConfig) },
28+
ConnectorTypeSalesforce: func() SourceConfig { return new(SalesforceSourceConnectorConfig) },
29+
ConnectorTypeSharePoint: func() SourceConfig { return new(SharePointSourceConnectorConfig) },
30+
ConnectorTypeSlack: func() SourceConfig { return new(SlackSourceConnectorConfig) },
31+
ConnectorTypeSnowflake: func() SourceConfig { return new(SnowflakeSourceConnectorConfig) },
32+
ConnectorTypeZendesk: func() SourceConfig { return new(ZendeskSourceConnectorConfig) },
3333
}
3434

3535
// Source represents a source connector that ingests files or data from various locations.

source_connection_check.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88

99
// CreateSourceConnectionCheck initiates a connection check for a source connector by its ID.
1010
// It returns a DagNodeConnectionCheck with the status of the check.
11-
func (c *Client) CreateSourceConnectionCheck(ctx context.Context, sourceID string) (*DagNodeConnectionCheck, error) {
11+
func (c *Client) CreateSourceConnectionCheck(ctx context.Context, id string) (*DagNodeConnectionCheck, error) {
1212
req, err := http.NewRequestWithContext(ctx,
1313
http.MethodPost,
14-
c.endpoint.JoinPath("/sources", sourceID, "connection-check").String(),
14+
c.endpoint.JoinPath("/sources", id, "connection-check").String(),
1515
nil,
1616
)
1717
if err != nil {
@@ -28,10 +28,10 @@ func (c *Client) CreateSourceConnectionCheck(ctx context.Context, sourceID strin
2828

2929
// GetSourceConnectionCheck retrieves the status of a connection check for a source connector by its ID.
3030
// It returns a DagNodeConnectionCheck with the current status and reason if any.
31-
func (c *Client) GetSourceConnectionCheck(ctx context.Context, sourceID string) (*DagNodeConnectionCheck, error) {
31+
func (c *Client) GetSourceConnectionCheck(ctx context.Context, id string) (*DagNodeConnectionCheck, error) {
3232
req, err := http.NewRequestWithContext(ctx,
3333
http.MethodGet,
34-
c.endpoint.JoinPath("/sources", sourceID, "connection-check").String(),
34+
c.endpoint.JoinPath("/sources", id, "connection-check").String(),
3535
nil,
3636
)
3737
if err != nil {

source_delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
)
88

99
// DeleteSource deletes a specific source connector identified by its ID
10-
func (c *Client) DeleteSource(ctx context.Context, sourceID string) error {
10+
func (c *Client) DeleteSource(ctx context.Context, id string) error {
1111
req, err := http.NewRequestWithContext(ctx,
1212
http.MethodDelete,
13-
c.endpoint.JoinPath("/sources", sourceID).String(),
13+
c.endpoint.JoinPath("/sources", id).String(),
1414
nil,
1515
)
1616
if err != nil {

0 commit comments

Comments
 (0)