Skip to content
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

Added config for specific endpoint class #2

Merged
merged 1 commit into from
Apr 15, 2021

Conversation

ezimuel
Copy link
Contributor

@ezimuel ezimuel commented Apr 7, 2021

This PR adds the ability to specify $config on each endpoint class. Example as follows:

use Elastic\EnterpriseSearch\Client;

$client = new Client([
    'host' => 'http://localhost:3002'
]);
$workplaceRead = $client->workplaceSearch([
    'token' => '<AUTH_TOKEN for reading>'
]);
$workplaceWrite = $client->workplaceSearch([
    'token' => '<AUTH_TOKEN for writing>'
]);

This configuration allows having multiple client instances with different token permissions (e.g. for reading and writing).
The $config passed in the specific endpoint class (e.g. workplaceSearch($config)) will override the values specified in the Client.

You can even instantiate the Client without any $config, as follows:

use Elastic\EnterpriseSearch\Client;

$client = new Client();
$workplace = $client->workplaceSearch([
    'host' => 'http://localhost:3002',
    'token' => '<AUTH_TOKEN>'
]);

@ezimuel ezimuel added this to the 7.13.0 milestone Apr 7, 2021
Copy link
Member

@picandocodigo picandocodigo left a comment

Choose a reason for hiding this comment

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

LGTM!

@ezimuel ezimuel removed the request for review from afoucret April 15, 2021 15:06
@ezimuel
Copy link
Contributor Author

ezimuel commented Apr 15, 2021

Thanks @picandocodigo

@ezimuel ezimuel merged commit b23bb8e into elastic:master Apr 15, 2021
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.

None yet

2 participants