Skip to content

Commit 72769f1

Browse files
algolia-botmillotp
andcommitted
chore(ci): always run all clients (#4563) (generated) [skip ci]
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
1 parent b154bda commit 72769f1

File tree

10 files changed

+305
-0
lines changed

10 files changed

+305
-0
lines changed

docs/guides/csharp/src/pushSetup.cs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
namespace Algolia;
2+
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text.Json;
6+
using Algolia.Search.Clients;
7+
using Algolia.Search.Http;
8+
using Algolia.Search.Models.Ingestion;
9+
using Action = Algolia.Search.Models.Ingestion.Action;
10+
11+
class PushSetup
12+
{
13+
async Task Main(string[] args)
14+
{
15+
try
16+
{
17+
var jsonContent = await File.ReadAllTextAsync("records.json");
18+
19+
var records = JsonSerializer.Deserialize<List<PushTaskRecords>>(jsonContent);
20+
21+
// use the region matching your applicationID
22+
var client = new IngestionClient(
23+
new IngestionConfig(
24+
"ALGOLIA_APPLICATION_ID",
25+
"ALGOLIA_API_KEY",
26+
"ALGOLIA_APPLICATION_REGION"
27+
)
28+
);
29+
30+
// setting `watch` to `true` will make the call synchronous
31+
var resp = await client.PushTaskAsync(
32+
"YOUR_TASK_ID",
33+
new PushTaskPayload { Action = Enum.Parse<Action>("AddObject"), Records = records },
34+
true
35+
);
36+
37+
Console.WriteLine(resp);
38+
}
39+
catch (Exception e)
40+
{
41+
Console.WriteLine(e.Message);
42+
}
43+
}
44+
}

docs/guides/go/src/pushSetup.go

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"os"
7+
8+
"github.com/algolia/algoliasearch-client-go/v4/algolia/ingestion"
9+
)
10+
11+
func push() {
12+
// use the region matching your applicationID
13+
client, err := ingestion.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", ingestion.US)
14+
if err != nil {
15+
// The client can fail to initialize if you pass an invalid parameter.
16+
panic(err)
17+
}
18+
19+
content, err := os.ReadFile("records.json")
20+
if err != nil {
21+
panic(err)
22+
}
23+
24+
var records []ingestion.PushTaskRecords
25+
26+
err = json.Unmarshal(content, &records)
27+
if err != nil {
28+
panic(err)
29+
}
30+
31+
// setting `watch` to `true` will make the call synchronous
32+
resp, err := client.PushTask(client.NewApiPushTaskRequest(
33+
"YOUR_TASK_ID",
34+
ingestion.NewEmptyPushTaskPayload().SetAction(ingestion.Action("addObject")).SetRecords(records)).WithWatch(true))
35+
if err != nil {
36+
panic(err)
37+
}
38+
39+
fmt.Printf("%#v\n", resp)
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.algolia;
2+
3+
import com.algolia.api.IngestionClient;
4+
import com.algolia.config.*;
5+
import com.algolia.model.ingestion.*;
6+
import com.fasterxml.jackson.databind.*;
7+
import java.io.File;
8+
import java.util.List;
9+
import java.util.Map;
10+
11+
public class pushSetup {
12+
13+
public static void main(String[] args) throws Exception {
14+
JsonNode content = new ObjectMapper().readTree(new File("records.json"));
15+
List<PushTaskRecords> records = new ObjectMapper().readerForListOf(Map.class).readValue(content);
16+
17+
// use the region matching your applicationID
18+
IngestionClient client = new IngestionClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
19+
20+
// setting `watch` to `true` will make the call synchronous
21+
WatchResponse resp = client.pushTask("YOUR_TASK_ID", new PushTaskPayload().setAction(Action.ADD_OBJECT).setRecords(records), true);
22+
23+
System.out.println(resp);
24+
25+
client.close();
26+
}
27+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { PushTaskRecords } from 'algoliasearch';
2+
import fs from 'node:fs';
3+
4+
import { algoliasearch } from 'algoliasearch';
5+
6+
// use the region matching your applicationID
7+
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initIngestion({ region: 'us' });
8+
9+
try {
10+
// read local JSON file containing array of records
11+
const records = JSON.parse(fs.readFileSync('records.json', 'utf8')) as PushTaskRecords[];
12+
13+
// setting `watch` to `true` will make the call synchronous
14+
const resp = await client.pushTask({
15+
taskID: 'YOUR_TASK_ID',
16+
pushTaskPayload: { action: 'addObject', records: records },
17+
watch: true,
18+
});
19+
20+
console.log(resp);
21+
} catch (err) {
22+
console.error(err);
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.example
2+
import com.algolia.client.api.IngestionClient
3+
import com.algolia.client.configuration.*
4+
import com.algolia.client.transport.*
5+
6+
import com.algolia.client.model.ingestion.*
7+
8+
import kotlinx.serialization.builtins.ListSerializer
9+
import kotlinx.serialization.json.Json
10+
import java.io.File
11+
12+
suspend fun main() {
13+
val json = File("records.json").readText()
14+
val records: List<PushTaskRecords> = Json.decodeFromString(ListSerializer(PushTaskRecords.serializer()), json)
15+
16+
// use the region matching your applicationID
17+
val client = IngestionClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY", region = "ALGOLIA_APPLICATION_REGION")
18+
19+
try {
20+
// setting `watch` to `true` will make the call synchronous
21+
val resp = client.pushTask(
22+
taskID = "YOUR_TASK_ID",
23+
pushTaskPayload = PushTaskPayload(
24+
action = Action.entries.first { it.value == "addObject" },
25+
records = records,
26+
),
27+
watch = true,
28+
)
29+
30+
println(resp)
31+
} catch (e: Exception) {
32+
println(e.message)
33+
}
34+
}

docs/guides/php/src/pushSetup.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
require __DIR__.'/../vendor/autoload.php';
4+
use Algolia\AlgoliaSearch\Api\IngestionClient;
5+
6+
$records = json_decode(file_get_contents('records.json') ?: '[]', true);
7+
8+
// use the region matching your applicationID
9+
$client = IngestionClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');
10+
11+
// setting `watch` to `true` will make the call synchronous
12+
$resp = $client->pushTask(
13+
'YOUR_TASK_ID',
14+
['action' => 'addObject',
15+
'records' => $records,
16+
],
17+
true,
18+
);
19+
20+
echo $resp;

docs/guides/python/pushSetup.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import json
2+
from algoliasearch.ingestion.client import IngestionClientSync
3+
4+
5+
# use the region matching your applicationID
6+
_client = IngestionClientSync(
7+
"ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
8+
)
9+
10+
with open("records.json") as f:
11+
records = json.load(f)
12+
13+
# setting `watch` to `true` will make the call synchronous
14+
resp = _client.push_task(
15+
task_id="YOUR_TASK_ID",
16+
push_task_payload={
17+
"action": "addObject",
18+
"records": records,
19+
},
20+
watch=True,
21+
)
22+
23+
print(resp)

docs/guides/ruby/pushSetup.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require "json"
2+
require "algolia"
3+
4+
records = JSON.parse(File.read("records.json"))
5+
6+
# use the region matching your applicationID
7+
client = Algolia::IngestionClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
8+
9+
# setting `watch` to `true` will make the call synchronous
10+
resp = client.push_task(
11+
"YOUR_TASK_ID",
12+
Algolia::Ingestion::PushTaskPayload.new(action: "addObject", records: records),
13+
true
14+
)
15+
16+
puts(resp)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import scala.io.Source
2+
import scala.concurrent.duration.Duration
3+
import scala.concurrent.{Await, ExecutionContextExecutor}
4+
5+
import algoliasearch.api.IngestionClient
6+
import algoliasearch.config.*
7+
8+
import algoliasearch.config.*
9+
import algoliasearch.ingestion.*
10+
11+
import org.json4s.native.JsonMethods
12+
import org.json4s.jvalue2extractable
13+
14+
object PushSetup {
15+
def main(args: Array[String]): Unit = {
16+
implicit val ec: ExecutionContextExecutor = scala.concurrent.ExecutionContext.global
17+
implicit val formats: org.json4s.Formats = JsonSupport.format
18+
19+
val result = Source.fromFile("records.json").getLines().mkString
20+
val records = JsonMethods.parse(result).extract[Seq[algoliasearch.ingestion.PushTaskRecords]]
21+
22+
// use the region matching your applicationID
23+
val client = IngestionClient(
24+
appId = "ALGOLIA_APPLICATION_ID",
25+
apiKey = "ALGOLIA_API_KEY",
26+
region = "ALGOLIA_APPLICATION_REGION"
27+
)
28+
29+
try {
30+
// setting `watch` to `true` will make the call synchronous
31+
val resp = Await.result(
32+
client.pushTask(
33+
taskID = "YOUR_TASK_ID",
34+
pushTaskPayload = PushTaskPayload(
35+
action = Action.withName("addObject"),
36+
records = records
37+
),
38+
watch = Some(true)
39+
),
40+
Duration(100, "sec")
41+
)
42+
43+
println(resp)
44+
} catch {
45+
case e: Exception => println(e)
46+
}
47+
}
48+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Foundation
2+
#if os(Linux) // For linux interop
3+
import FoundationNetworking
4+
#endif
5+
6+
import Core
7+
import Ingestion
8+
9+
func pushSetup() async throws {
10+
do {
11+
let path = URL(string: #file)!.deletingLastPathComponent()
12+
.appendingPathComponent("records.json")
13+
let data = try Data(contentsOf: URL(fileURLWithPath: path.absoluteString))
14+
let records = try JSONDecoder().decode([PushTaskRecords].self, from: data)
15+
16+
// use the region matching your applicationID
17+
let client = try IngestionClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
18+
19+
// setting `watch` to `true` will make the call synchronous
20+
let resp = try await client.pushTask(
21+
taskID: "YOUR_TASK_ID",
22+
pushTaskPayload: PushTaskPayload(action: IngestionAction.addObject, records: records),
23+
watch: true
24+
)
25+
26+
dump(resp)
27+
} catch {
28+
print(error)
29+
}
30+
}

0 commit comments

Comments
 (0)