-
Notifications
You must be signed in to change notification settings - Fork 27
guides: add pushSetup for ingestion API #4126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 26 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
af187e7
feat(guides): add pushSetup for ingestion API
shortcuts 2ec3de2
fix(generators): only add lambda if guide exists
shortcuts 716d628
feat: go
shortcuts 49aee0d
feat: python
shortcuts 65b5285
feat: java
shortcuts 63273df
feat: ruby
shortcuts b77c688
feat: php
shortcuts 55482e9
feat: kotlin
shortcuts f2dd927
feat: kotlin
shortcuts 07080d9
feat: scala
shortcuts df57942
feat: swift
shortcuts fda46db
feat: sicharpe
shortcuts 73aacf8
fix: go
shortcuts d074de8
fix: partially fixy swift nifty
shortcuts 1dfc709
fix: java and maybe swift
shortcuts aa4f964
fix kt
millotp f97e2d3
fix: scala
shortcuts c5e7bcc
kt playground
millotp 71e7e3a
fix: csharp but still doesn't work
shortcuts af6612a
fix: CSHARP YES
shortcuts d213466
fix: csproj for csharp
shortcuts ca9c2fb
fix: upgrade csharpier thanks https://github.com/belav/csharpier/issu…
shortcuts 7db1e82
fix: here too
shortcuts 2f88d00
fix: upgrade csharpier correctly
shortcuts ac72f95
swift magic
millotp 146454f
Merge branch 'main' into feat/guides-for-push
shortcuts 7efc765
chore: review
shortcuts 6b0e133
Merge branch 'main' into feat/guides-for-push
shortcuts fe786ef
chore: review
shortcuts e68a2ef
Merge branch 'main' into feat/guides-for-push
shortcuts c76b97a
Merge branch 'main' into feat/guides-for-push
shortcuts 01c2b60
Merge branch 'main' into feat/guides-for-push
shortcuts d9377a2
Merge branch 'main' into feat/guides-for-push
shortcuts 8882dc8
Update templates/csharp/guides/ingestion/pushSetup.mustache
shortcuts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| public class Program | ||
| { | ||
| public static void Main() { } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package main | ||
|
|
||
| import "fmt" | ||
|
|
||
| func main() { | ||
| fmt.Println("wow nice") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using System; | ||
| using System.Text.Json; | ||
| using System.Collections.Generic; | ||
|
|
||
| {{> snippets/import}} | ||
|
|
||
| using Action = Algolia.Search.Models.Ingestion.Action; | ||
|
|
||
| class PushSetup | ||
| { | ||
| public static async Task Main(string[] args) | ||
| { | ||
| string jsonContent = File.ReadAllText("/my-raw-records.json"); | ||
| var records = JsonSerializer.Deserialize<List<Algolia.Search.Models.Ingestion.PushTaskRecords>>(jsonContent); | ||
shortcuts marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // use the region matching your applicationID | ||
| {{> snippets/init}} | ||
|
|
||
| try | ||
| { | ||
| var run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}; | ||
| Console.WriteLine(run.RunID); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| Console.WriteLine(e.Message); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "os" | ||
| "encoding/json" | ||
| "fmt" | ||
| "net/http" | ||
| ) | ||
|
|
||
|
|
||
| {{> snippets/import}} | ||
|
|
||
| func push() { | ||
| // use the region matching your applicationID | ||
| {{> snippets/init}} | ||
|
|
||
| content, err := os.ReadFile("/my-raw-records.json") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| var records []ingestion.PushTaskRecords | ||
|
|
||
| err = json.Unmarshal(content, &records) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| run, err := {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}} | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| // use runID in the Observability debugger | ||
| fmt.Println("run", run.RunID) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or main run id soon !
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😶 shhhhh |
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import com.fasterxml.jackson.databind.*; | ||
| import java.io.File; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| {{> snippets/import}} | ||
|
|
||
| public class pushSetup { | ||
| public static void main(String[] args) throws Exception { | ||
| JsonNode content = new ObjectMapper().readTree(new File("/my-raw-records.json")); | ||
| List<PushTaskRecords> records = new ObjectMapper().readerForListOf(Map.class).readValue(content); | ||
| // use the region matching your applicationID | ||
| {{> snippets/init}} | ||
|
|
||
| RunResponse run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}; | ||
|
|
||
| // use runID in the Observability debugger | ||
| System.out.println(run); | ||
shortcuts marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| client.close(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import fs from 'node:fs'; | ||
| import type { PushTaskRecords } from 'algoliasearch'; | ||
|
|
||
| {{> snippets/import}} | ||
|
|
||
| // use the region matching your applicationID | ||
| {{> snippets/init}} | ||
|
|
||
| try { | ||
| // read local JSON file containing array of records | ||
| const records = JSON.parse(fs.readFileSync('/my-raw-records.json', 'utf8')) as PushTaskRecords[]; | ||
|
|
||
| // push records to the API | ||
| const run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}} | ||
|
|
||
| // use runID in the Observability debugger | ||
| console.log(run.runID); | ||
| } catch (err) { | ||
| console.error(err); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package org.example | ||
| {{> snippets/import}} | ||
| {{#isSearchClient}} | ||
| import com.algolia.client.extensions.* | ||
| {{/isSearchClient}} | ||
| import com.algolia.client.model.ingestion.* | ||
|
|
||
| import kotlinx.serialization.builtins.ListSerializer | ||
| import kotlinx.serialization.json.Json | ||
| import kotlinx.serialization.json.JsonObject | ||
| import java.io.File | ||
|
|
||
| suspend fun main() { | ||
| val json = File("/my-raw-records.json").readText() | ||
| val records: List<PushTaskRecords> = Json.decodeFromString(ListSerializer(PushTaskRecords.serializer()), json) | ||
|
|
||
| // use the region matching your applicationID | ||
| {{> snippets/init}} | ||
|
|
||
| try { | ||
| val run = client.{{#dynamicSnippet}}pushSetup{{/dynamicSnippet}} | ||
|
|
||
| // use runID in the Observability debugger | ||
| println(run) | ||
| } catch(e: Exception) { | ||
| println(e.message) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be done inside of the lambda directly to avoid leaking the internal logic here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since it's always called I wanted to avoid no-op as it's less explicit when looking at this file, idk what you prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this files makes it harder since now the path is in multiple files rather than just the lambda, this file should be more generic IMO