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

[FEATURE] Expose an HTTP namespace with a higher level get/put/post #192

Open
dblock opened this issue May 20, 2024 · 2 comments
Open

[FEATURE] Expose an HTTP namespace with a higher level get/put/post #192

dblock opened this issue May 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dblock
Copy link
Member

dblock commented May 20, 2024

Is your feature request related to a problem?

To make a raw HTTP request one has to write this.

$response = $client->request('GET', '/shakespeare/_search', [
    'body' => [
        'query' => [
            'match' => [
                'text_entry' => 'long live king'
            ]
        ]
    ]
]);

What solution would you like?

I'd like a higher level DSL so I could write this:

$response = $client->http()->get('/shakespeare/_search', [
    'body' => [
        'query' => [
            'match' => [
                'text_entry' => 'long live king'
            ]
        ]
    ]
]);

This would be consistent with other clients (see https://code.dblock.org/2023/10/16/making-raw-json-rest-requests-to-opensearch.html) and make it a bit easier on the user.

Let's make sure to have a full working sample along the lines of https://github.com/dblock/opensearch-php-client-demo/blob/main/json.php and a user guide.

@shyim
Copy link
Collaborator

shyim commented Feb 10, 2025

Do we need this issue still? the linked PR is merged

@dblock
Copy link
Member Author

dblock commented Feb 10, 2025

Yes, that PR does this:

$response = $client->request('GET', '/shakespeare/_search', [
    'body' => [
        'query' => [
            'match' => [
                'text_entry' => 'long live king'
            ]
        ]
    ]
]);

we want this:

$response = $client->http().get('/shakespeare/_search', [
    'body' => [
        'query' => [
            'match' => [
                'text_entry' => 'long live king'
            ]
        ]
    ]
]);

It's just syntax sugar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants