Skip to content

add support of QueryParameters on resource algolia_api_key#182

Open
Laurent-OC wants to merge 2 commits intok-yomo:mainfrom
OpenClassrooms:queryParameters
Open

add support of QueryParameters on resource algolia_api_key#182
Laurent-OC wants to merge 2 commits intok-yomo:mainfrom
OpenClassrooms:queryParameters

Conversation

@Laurent-OC
Copy link

@Laurent-OC Laurent-OC commented Jun 30, 2023

Copy link
Owner

@k-yomo k-yomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!! I left some comments regarding type conversion.

MaxQueriesPerIPPerHour: d.Get("max_queries_per_ip_per_hour").(int),
Indexes: castStringSet(d.Get("indexes")),
Referers: castStringSet(d.Get("referers")),
QueryParameters: d.Get("query_parameters").(string),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also type error. We would need to decode the string to QueryParameters struct like below.
https://github.com/algolia/algoliasearch-client-go/blob/40b333da0e6c734924e9ec40a831c63ad87f78bf/algolia/search/key.go#L70-L73

"max_hits_per_query": key.MaxHitsPerQuery,
"max_queries_per_ip_per_hour": key.MaxQueriesPerIPPerHour,
"referers": key.Referers,
"query_parameters": key.QueryParameters,
Copy link
Owner

@k-yomo k-yomo Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is type mismatch because QueryParameters is not string.
We should convert it to string with transport.URLEncode(key.QueryParameters) like below.
https://github.com/algolia/algoliasearch-client-go/blob/40b333da0e6c734924e9ec40a831c63ad87f78bf/algolia/search/key.go#L42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants