Skip to content

Commit

Permalink
fix(specs): enable watcher for push [skip-bc] (#4229)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Dec 11, 2024
1 parent fd58f03 commit cd59f44
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 57 deletions.
22 changes: 22 additions & 0 deletions specs/ingestion/common/schemas/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,25 @@ Window:
required:
- startDate
- endDate

WatchResponse:
type: object
additionalProperties: false
properties:
runID:
$ref: './common.yml#/runID'
data:
type: array
description: when used with discovering or validating sources, the sampled data of your source is returned.
items:
type: object
events:
description: in case of error, observability events will be added to the response, if any.
type: array
items:
$ref: '../../common/schemas/event.yml#/Event'
message:
description: a message describing the outcome of a validate run.
type: string
required:
- message
22 changes: 0 additions & 22 deletions specs/ingestion/common/schemas/source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -476,28 +476,6 @@ sourceShopifyBase:
x-discriminator-fields:
- shopURL

SourceWatchResponse:
type: object
additionalProperties: false
properties:
runID:
$ref: './common.yml#/runID'
data:
type: array
description: depending on the source type, the validation returns sampling data of your source (JSON, CSV, BigQuery).
items:
type: object
events:
description: in case of error, observability events will be added to the response, if any.
type: array
items:
$ref: '../../common/schemas/event.yml#/Event'
message:
description: a message describing the outcome of a validate run.
type: string
required:
- message

RunSourcePayload:
type: object
additionalProperties: false
Expand Down
2 changes: 1 addition & 1 deletion specs/ingestion/paths/sources/discover.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ post:
content:
application/json:
schema:
$ref: '../../common/schemas/source.yml#/SourceWatchResponse'
$ref: '../../common/schemas/common.yml#/WatchResponse'
'400':
$ref: '../../../common/responses/BadRequest.yml'
2 changes: 1 addition & 1 deletion specs/ingestion/paths/sources/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ post:
content:
application/json:
schema:
$ref: '../../common/schemas/source.yml#/SourceWatchResponse'
$ref: '../../common/schemas/common.yml#/WatchResponse'
'400':
$ref: '../../../common/responses/BadRequest.yml'
2 changes: 1 addition & 1 deletion specs/ingestion/paths/sources/validateID.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ post:
content:
application/json:
schema:
$ref: '../../common/schemas/source.yml#/SourceWatchResponse'
$ref: '../../common/schemas/common.yml#/WatchResponse'
'400':
$ref: '../../../common/responses/BadRequest.yml'
2 changes: 1 addition & 1 deletion specs/ingestion/paths/tasks/v2/pushTask.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ post:
content:
application/json:
schema:
$ref: '../../../common/schemas/run.yml#/RunResponse'
$ref: '../../../common/schemas/common.yml#/WatchResponse'
'400':
$ref: '../../../../common/responses/BadRequest.yml'
6 changes: 4 additions & 2 deletions templates/csharp/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ class PushSetup

try
{
var run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}};
Console.WriteLine(run.RunID);
// setting `watch` to `true` will make the call synchronous
var resp = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}};

Console.WriteLine(resp);
}
catch (Exception e)
{
Expand Down
6 changes: 3 additions & 3 deletions templates/go/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ func push() {
panic(err)
}

run, err := {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
// setting `watch` to `true` will make the call synchronous
resp, err := {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
if err != nil {
panic(err)
}

// use runID in the Observability debugger
fmt.Println("run", run.RunID)
fmt.Printf("%#v\n", resp)
}
6 changes: 3 additions & 3 deletions templates/java/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public class pushSetup {
// use the region matching your applicationID
{{> snippets/init}}

RunResponse run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}};
// setting `watch` to `true` will make the call synchronous
WatchResponse resp = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}};

// use runID in the Observability debugger
System.out.println(run.getRunID());
System.out.println(resp);

client.close();
}
Expand Down
7 changes: 3 additions & 4 deletions templates/javascript/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ try {
// read local JSON file containing array of records
const records = JSON.parse(fs.readFileSync('records.json', 'utf8')) as PushTaskRecords[];
// push records to the API
const run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
// setting `watch` to `true` will make the call synchronous
const resp = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}

// use runID in the Observability debugger
console.log(run.runID);
console.log(resp);
} catch (err) {
console.error(err);
}
6 changes: 3 additions & 3 deletions templates/kotlin/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ suspend fun main() {
{{> snippets/init}}

try {
val run = client.{{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
// setting `watch` to `true` will make the call synchronous
val resp = client.{{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}

// use runID in the Observability debugger
println(run)
println(resp)
} catch(e: Exception) {
println(e.message)
}
Expand Down
6 changes: 3 additions & 3 deletions templates/php/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $records = json_decode(file_get_contents("records.json"), true);
// use the region matching your applicationID
{{> snippets/init}}

$run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}};
// setting `watch` to `true` will make the call synchronous
$resp = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}};

// use runID in the Observability debugger
print($run);
print($resp);
6 changes: 3 additions & 3 deletions templates/python/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ async def main():
with open("records.json") as f:
records = json.load(f)

run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
# setting `watch` to `true` will make the call synchronous
resp = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}

# use runID in the Observability debugger
print(run.run_id)
print(resp)

asyncio.run(main())
6 changes: 3 additions & 3 deletions templates/ruby/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ records = JSON.parse(File.read('records.json'))
# use the region matching your applicationID
{{> snippets/init}}

run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
# setting `watch` to `true` will make the call synchronous
resp = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}

# use runID in the Observability debugger
puts run.run_id
puts resp
6 changes: 3 additions & 3 deletions templates/scala/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ object PushSetup {
{{> snippets/init}}

try {
val run = Await.result(
// setting `watch` to `true` will make the call synchronous
val resp = Await.result(
{{#dynamicSnippet}}pushSetup{{/dynamicSnippet}},
Duration(100, "sec")
)

// use runID in the Observability debugger
println(run.runID)
println(resp)
} catch {
case e: Exception => println(e)
}
Expand Down
6 changes: 3 additions & 3 deletions templates/swift/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func pushSetup() async throws {
// use the region matching your applicationID
{{> snippets/init}}

let run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
// setting `watch` to `true` will make the call synchronous
let resp = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}

// use runID in the Observability debugger
dump(run)
dump(resp)
} catch {
print(error)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/CTS/guides/ingestion.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"pushTaskPayload": {
"action": "addObject",
"records": "$var: records"
}
},
"watch": true
}
}
}

0 comments on commit cd59f44

Please sign in to comment.