Search...:Direct(3pm)

πŸ“¦
version 8.12 Β· 5 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Search::Elasticsearch::Role::Client::Direct β€” bestie, it's the request-parsing role for Direct clients ✨


πŸ¦‹ VERSION πŸ¦‹

version 8.12 β€” she's giving current, no cap πŸ’…


🌸 DESCRIPTION 🌸

okay so listen. This role is a one-trick pony in the best way possible β€” it hands you exactly one method, parse_request(), and that's literally it.

Who needs it? Any class that has to take an API definition from Search::Elasticsearch::Role::API and glow it up into an actual request that can be passed along to perform_request() in Search::Elasticsearch::Transport. That's the whole vibe. πŸŽ€


✨ METHODS ✨

🫢 perform_request()

$request = $client->parse_request(\%defn,\%params);

So the %defn here is a definition that came back from api() in Search::Elasticsearch::Role::API, except it's got one extra key: name πŸ‘‘. And that name should be the name of the method that got called on the client. Like, if somebody calls $client->search, then the name is literally search. That's it, that's the rule πŸ“

Then parse_request() takes all the params you passed in and turns them into:

  • a path β€” built via path_init() in Search::Elasticsearch::Util::API::Path πŸ›£οΈ
  • a query-string hash β€” built via qs_init in Search::Elasticsearch::Util::API::QS πŸ”
  • and it will pass a body value straight through, untouched, like it's not even there ✨
⚠️ NOTE, and this one's important bestie: if you specify a path key inside %params, it gets used directly β€” no trying to build the path from the path template, she skips all that. Same energy with params: if a params key shows up in %params, that becomes the basis for the query string hash. For instance:
$client->perform_request(
    {
        method => 'GET',
        name   => 'new_method'
    },
    {
        path   => '/new/method',
        params => { foo => 'bar' },
        body   => \%body
    }
);

And that's why this is so iconic β€” it makes it super easy to add support for custom plugins, or for brand new functionality that the released client doesn't support yet. main character energy for real πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

Enrico Zimuel <enrico.zimuel@elastic.co> β€” thank you king πŸ’œ


This software is Copyright (c) 2024 by Elasticsearch BV.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004

and that's the whole page, bestie!! πŸŽ€ this was perl v5.38.2, dated 2024-02-04, and it's the Search::Elasticsearch::Role::Client::Direct manpage from the User Contributed Perl Documentation β€” slay, go parse some requests, ily πŸ’–βœ¨

πŸ“¦ where this page comes from