Skip to content

Commit e199125

Browse files
shortcutsmillotp
andauthored
guides: add pushSetup for ingestion API (#4126)
Co-authored-by: Pierre Millot <[email protected]>
1 parent 35631ee commit e199125

File tree

34 files changed

+317
-56
lines changed

34 files changed

+317
-56
lines changed

config/generation.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export const patterns = [
2424
'!clients/algoliasearch-client-csharp/algoliasearch/Transport/**',
2525
'!clients/algoliasearch-client-csharp/algoliasearch/Models/Common/**',
2626

27+
'!docs/guides/csharp/src/program.cs',
28+
2729
'tests/output/csharp/global.json',
2830

2931
// Dart
@@ -49,6 +51,8 @@ export const patterns = [
4951
'!clients/algoliasearch-client-go/algolia/debug/*',
5052
'!clients/algoliasearch-client-go/algolia/utils/*',
5153

54+
'!docs/guides/go/src/main.go',
55+
5256
'!tests/output/go/go.*',
5357

5458
// Java

docs/guides/csharp/src/program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public class Program
2+
{
3+
public static void Main() { }
4+
}

docs/guides/go/src/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
fmt.Println("wow nice")
7+
}

generators/src/main/java/com/algolia/codegen/cts/AlgoliaCTSGenerator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.algolia.codegen.utils.*;
1010
import com.google.common.collect.ImmutableMap.Builder;
1111
import com.samskivert.mustache.Mustache.Lambda;
12+
import java.io.File;
1213
import java.util.*;
1314
import java.util.Map.Entry;
1415
import java.util.TreeMap;
@@ -159,7 +160,9 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj
159160
bundle.put("isSyncClient", false);
160161
// special lambda for dynamic templates
161162
bundle.put("dynamicTemplate", new DynamicTemplateLambda(this));
162-
bundle.put("dynamicSnippet", new DynamicSnippetLambda(this, models, operations, language, client));
163+
if (new File("tests/CTS/guides/" + client + ".json").exists()) {
164+
bundle.put("dynamicSnippet", new DynamicSnippetLambda(this, models, operations, language, client));
165+
}
163166
bundle.put("lambda", lambda);
164167

165168
String languageVersion = ctsManager.getLanguageVersion((String) additionalProperties.getOrDefault("languageVersion", ""));

generators/src/main/java/com/algolia/codegen/cts/lambda/DynamicSnippetLambda.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public DynamicSnippetLambda(
4343
this.operations = operations;
4444
this.paramsType = new ParametersWithDataType(models, language, client, true);
4545

46-
JsonNode snippetsFile = Helpers.readJsonFile("tests/CTS/guides/search.json");
46+
JsonNode snippetsFile = Helpers.readJsonFile("tests/CTS/guides/" + client + ".json");
4747
this.snippets = Json.mapper().convertValue(snippetsFile, new TypeReference<Map<String, Snippet>>() {});
4848

4949
// we can't access the default template manager, so we have to create our own

playground/csharp/Performances/Performances.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<RootNamespace>Performances</RootNamespace>

playground/csharp/Playground/Playground.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<LangVersion>12</LangVersion>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>

playground/go/ingestion.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"fmt"
5-
"time"
65

76
"github.com/algolia/algoliasearch-client-go/v4/algolia/ingestion"
87
)
@@ -14,34 +13,14 @@ func testIngestion(appID, apiKey string) int {
1413
}
1514

1615
// another example to generate payload for a request.
17-
createAuthenticationResponse, err := ingestionClient.CreateAuthentication(ingestionClient.NewApiCreateAuthenticationRequest(
18-
&ingestion.AuthenticationCreate{
19-
Type: ingestion.AUTHENTICATION_TYPE_BASIC,
20-
Name: fmt.Sprintf("my-authentication-%d", time.Now().Unix()),
21-
Input: ingestion.AuthInput{
22-
AuthBasic: &ingestion.AuthBasic{
23-
Username: "username",
24-
Password: "password",
25-
},
26-
},
27-
}))
28-
16+
_, payload, err := ingestionClient.ListTasksWithHTTPInfo(ingestionClient.NewApiListTasksRequest())
2917
if err != nil {
30-
fmt.Printf("request error with CreateAuthentication: %v\n", err)
31-
return 1
32-
}
18+
fmt.Printf("request error: %v\n", err)
3319

34-
printResponse(createAuthenticationResponse)
35-
36-
listAuthenticationsResponse, err := ingestionClient.ListAuthentications(
37-
ingestionClient.NewApiListAuthenticationsRequest().WithItemsPerPage(2),
38-
)
39-
if err != nil {
40-
fmt.Printf("request error with GetAuthentications: %v\n", err)
4120
return 1
4221
}
4322

44-
printResponse(listAuthenticationsResponse)
23+
fmt.Println(string(payload))
4524

4625
return 0
4726
}

playground/kotlin/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
kotlin("jvm") version "2.0.21"
33
kotlin("plugin.serialization") version "2.0.21"
4+
id("application")
45
}
56

67
repositories {
@@ -16,4 +17,8 @@ dependencies {
1617

1718
tasks.test {
1819
useJUnitPlatform()
19-
}
20+
}
21+
22+
application {
23+
mainClass.set("com.algolia.playground.${property("client")}Kt")
24+
}

scripts/buildLanguages.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ async function buildLanguage(language: Language, gens: Generator[], buildType: B
7070
break;
7171
case 'java':
7272
case 'kotlin':
73+
// the playground specify search but it will still build everything
7374
await run(
74-
`./gradle/gradlew -p ${cwd} ${buildType === 'client' || buildType === 'playground' ? 'assemble' : 'build'}`,
75+
`./gradle/gradlew -p ${cwd} ${buildType === 'client' || buildType === 'playground' ? 'assemble -Pclient=Search' : 'build'}`,
7576
{ language },
7677
);
7778
break;

0 commit comments

Comments
 (0)