Skip to content

Commit 40aa102

Browse files
committed
fix playground
1 parent 24d37fe commit 40aa102

File tree

11 files changed

+58
-44
lines changed

11 files changed

+58
-44
lines changed

playground/go/analytics.go

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

99
func testAnalytics(appID, apiKey string) int {
1010
indexName := getEnvWithDefault("ANALYTICS_INDEX", "test_index")
11-
analyticsClient := analytics.NewClient(appID, apiKey, analytics.US)
11+
analyticsClient, err := analytics.NewClient(appID, apiKey, analytics.US)
12+
if err != nil {
13+
panic(err)
14+
}
1215

1316
getTopFilterForAttributeResponse, err := analyticsClient.GetTopFilterForAttribute(
1417
analyticsClient.NewApiGetTopFilterForAttributeRequest("myAttribute1,myAttribute2", indexName),

playground/go/go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ require (
1010
)
1111

1212
require (
13-
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
13+
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
1414
github.com/go-playground/locales v0.14.1 // indirect
1515
github.com/go-playground/universal-translator v0.18.1 // indirect
16-
github.com/go-playground/validator/v10 v10.16.0 // indirect
17-
github.com/leodido/go-urn v1.2.4 // indirect
18-
golang.org/x/crypto v0.17.0 // indirect
19-
golang.org/x/net v0.17.0 // indirect
20-
golang.org/x/sys v0.15.0 // indirect
16+
github.com/go-playground/validator/v10 v10.18.0 // indirect
17+
github.com/leodido/go-urn v1.4.0 // indirect
18+
golang.org/x/crypto v0.19.0 // indirect
19+
golang.org/x/net v0.21.0 // indirect
20+
golang.org/x/sys v0.17.0 // indirect
2121
golang.org/x/text v0.14.0 // indirect
2222
)

playground/go/go.sum

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
21
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
32
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
5-
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
3+
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
4+
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
65
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
76
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
87
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
98
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
109
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
1110
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
12-
github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqRRkz6M78GuJAfGE=
13-
github.com/go-playground/validator/v10 v10.16.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
11+
github.com/go-playground/validator/v10 v10.18.0 h1:BvolUXjp4zuvkZ5YN5t7ebzbhlUtPsPm2S9NAZ5nl9U=
12+
github.com/go-playground/validator/v10 v10.18.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
1413
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
1514
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
16-
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
17-
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
15+
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
16+
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
1817
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1918
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
20-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
21-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
22-
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
23-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
24-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
25-
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
26-
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
27-
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
28-
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
29-
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
30-
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
31-
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
32-
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
19+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
20+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
21+
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
22+
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
23+
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
24+
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
25+
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
26+
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
3327
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
3428
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
35-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
36-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
3729
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
3830
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

playground/go/ingestion.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import (
88
)
99

1010
func testIngestion(appID, apiKey string) int {
11-
ingestionClient := ingestion.NewClient(appID, apiKey, ingestion.US)
11+
ingestionClient, err := ingestion.NewClient(appID, apiKey, ingestion.US)
12+
if err != nil {
13+
panic(err)
14+
}
1215

1316
// another example to generate payload for a request.
1417
createAuthenticationResponse, err := ingestionClient.CreateAuthentication(ingestionClient.NewApiCreateAuthenticationRequest(

playground/go/insights.go

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

99
func testInsights(appID, apiKey string) int {
10-
insightsClient := insights.NewClient(appID, apiKey, insights.US)
10+
insightsClient, err := insights.NewClient(appID, apiKey, insights.US)
11+
if err != nil {
12+
panic(err)
13+
}
1114

1215
events := insights.NewInsightsEvents([]insights.EventsItems{
13-
insights.ClickedObjectIDsAsEventsItems(insights.NewClickedObjectIDs("myEvent",
16+
*insights.ClickedObjectIDsAsEventsItems(insights.NewClickedObjectIDs("myEvent",
1417
insights.CLICKEVENT_CLICK,
1518
"test_index",
1619
[]string{"myObjectID"},

playground/go/personalization.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import (
99
)
1010

1111
func testPersonalization(appID, apiKey string) int {
12-
personalizationClient := personalization.NewClient(appID, apiKey, personalization.US)
12+
personalizationClient, err := personalization.NewClient(appID, apiKey, personalization.US)
13+
if err != nil {
14+
panic(err)
15+
}
1316
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
1417
defer cancel()
1518

playground/go/query-suggestions.go

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

99
func testQuerySuggestions(appID, apiKey string) int {
10-
suggestionsClient := suggestions.NewClient(appID, apiKey, suggestions.US)
10+
suggestionsClient, err := suggestions.NewClient(appID, apiKey, suggestions.US)
11+
if err != nil {
12+
panic(err)
13+
}
1114

1215
// if there is no params for the requests, we don't need to give empty request instance such as `suggestionsClient.NewApiGetAllConfigsRequest()`.
1316
querySuggestionsIndex, err := suggestionsClient.GetAllConfigs()

playground/go/recommend.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import (
44
"fmt"
55

66
"github.com/algolia/algoliasearch-client-go/v4/algolia/recommend"
7+
"github.com/algolia/algoliasearch-client-go/v4/algolia/utils"
78
)
89

910
func testRecommend(appID, apiKey string) int {
10-
recommendClient := recommend.NewClient(appID, apiKey)
11+
recommendClient, err := recommend.NewClient(appID, apiKey)
12+
if err != nil {
13+
panic(err)
14+
}
1115

1216
/*
1317
recommend.NewGetRecommendationsParams([]recommend.RecommendationsRequest{
@@ -22,7 +26,7 @@ func testRecommend(appID, apiKey string) int {
2226
Model: recommend.RECOMMENDATIONMODELS_BOUGHT_TOGETHER,
2327
ObjectID: "test_query",
2428
IndexName: "test_index",
25-
Threshold: recommend.PtrInt32(0),
29+
Threshold: utils.PtrInt32(0),
2630
},
2731
},
2832
},

playground/go/search.go

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

99
func testSearch(appID, apiKey string) int {
1010
indexName := getEnvWithDefault("SEARCH_INDEX", "test_index")
11-
searchClient := search.NewClient(appID, apiKey)
11+
searchClient, err := search.NewClient(appID, apiKey)
12+
if err != nil {
13+
panic(err)
14+
}
1215

1316
response, err := searchClient.AddOrUpdateObject(
1417
searchClient.NewApiAddOrUpdateObjectRequest(
@@ -40,7 +43,7 @@ func testSearch(appID, apiKey string) int {
4043
searchClient.NewApiSearchRequest(
4144
search.NewSearchMethodParams(
4245
[]search.SearchQuery{
43-
search.SearchForHitsAsSearchQuery(
46+
*search.SearchForHitsAsSearchQuery(
4447
search.NewSearchForHits(
4548
indexName,
4649
search.WithSearchForHitsQuery("foo"),

specs/search/helpers/generateSecuredApiKey.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ securedAPIKeyRestrictions:
4848
4949
For example, if you set the filter group:admin on your generated API key, and you add groups:press OR groups:visitors with the filters query parameter, your final search filter is equivalent to groups:admin AND (groups:press OR groups:visitors).
5050
validUntil:
51-
type: number
52-
format: duration
51+
type: integer
52+
format: int64
5353
description: Unix timestamp used to set the expiration date of the API key.
5454
restrictIndices:
5555
type: array

templates/go/search_helpers.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,19 @@ func (c *APIClient) GenerateSecuredApiKey(parentApiKey string, restrictions *Sec
318318
func encodeRestrictions(restrictions *SecuredAPIKeyRestrictions) (string, error) {
319319
toSerialize := map[string]any{}
320320
if restrictions.Filters != nil {
321-
toSerialize["filters"] = restrictions.Filters
321+
toSerialize["filters"] = *restrictions.Filters
322322
}
323323
if restrictions.ValidUntil != nil {
324-
toSerialize["validUntil"] = restrictions.ValidUntil
324+
toSerialize["validUntil"] = *restrictions.ValidUntil
325325
}
326326
if restrictions.RestrictIndices != nil {
327327
toSerialize["restrictIndices"] = restrictions.RestrictIndices
328328
}
329329
if restrictions.RestrictSources != nil {
330-
toSerialize["restrictSources"] = restrictions.RestrictSources
330+
toSerialize["restrictSources"] = *restrictions.RestrictSources
331331
}
332332
if restrictions.UserToken != nil {
333-
toSerialize["userToken"] = restrictions.UserToken
333+
toSerialize["userToken"] = *restrictions.UserToken
334334
}
335335
if restrictions.SearchParams != nil {
336336
// merge with searchParams

0 commit comments

Comments
 (0)