This commit is contained in:
2026-05-04 13:15:16 +08:00
parent b8f599a617
commit 093ce2e8bc
776 changed files with 70357 additions and 16 deletions
+22
View File
@@ -0,0 +1,22 @@
{
"scanSettings": {
"configMode": "AUTO",
"configExternalURL": "",
"projectToken": "",
"baseBranches": []
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure",
"displayMode": "diff",
"useMendCheckNames": true
},
"issueSettings": {
"minSeverityLevel": "LOW",
"issueType": "DEPENDENCY"
},
"remediateSettings": {
"workflowRules": {
"enabled": true
}
}
}
+13
View File
@@ -0,0 +1,13 @@
This software is licensed under the Apache License, version 2.0 by the OpenSearch Contributors.
This software also includes certain Elastic software that can be used under the Apache License, Version 2.0
(<LICENSE-APACHE> or <http://www.apache.org/licenses/LICENSE-2.0> (http://www.apache.org/licenses/LICENSE-2.0))
or the GNU Lesser General Public License, Version 2.1
(<LICENSE-LGPL> or <https://www.gnu.org/licenses/lgpl-2.1.html> (https://www.gnu.org/licenses/lgpl-2.1.html))
Election of Apache 2.0.
For the avoidance of doubt, the OpenSearch Contributors (i) elect to use only the Apache License, Version 2.0 for all
software where a choice of Apache License, Version 2.0 and GNU Lesser General Public License, Version 2.1 is
made available and (ii) elect to use only the Apache License, Version 2.0 on modifications of the software
by OpenSearch Contributors.
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+459
View File
@@ -0,0 +1,459 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
+44
View File
@@ -0,0 +1,44 @@
This software is licensed under the Apache 2.0 by the OpenSearch Contributors.
Election of Apache 2.0.
For the avoidance of doubt, the OpenSearch Contributors
(i) elect to use only the Apache License, Version 2.0 for all software where a
choice of Apache License, Version 2.0 and GNU Lesser General Public License, Version 2.1 is made available and
(ii) elect to use only the Apache License, Version 2.0 on modifications of the software by OpenSearch Contributors.
This software includes certain Elastic software that included the following in the NOTICE file
located here: https://github.com/elastic/elasticsearch-php/blob/master/NOTICE
Apache v2.0 Notice:
Copyright 2013-2014 Elasticsearch
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
LGPL v2.1 Notice:
Copyright (C) 2013-2014 Elasticsearch
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -0,0 +1 @@
<svg viewBox="0 0 372 72" height="64" fill="none" xmlns="http://www.w3.org/2000/svg"><style>.a{fill:#005EB8}.b{fill:#003B5C}@media(prefers-color-scheme:dark){.a{fill:#00A3E0}.b{fill:#B9D9EB}}</style><g class="a"><path d="M61.74 26.5a2.26 2.26 0 00-2.27 2.26 33.71 33.71 0 01-33.7 33.71 2.26 2.26 0 100 4.53A38.24 38.24 0 0064 28.76a2.26 2.26 0 00-2.26-2.26zM3.92 17A24.43 24.43 0 00.05 31.9c.86 13.73 13.3 24.14 25.03 23.02 4.6-.45 9.31-4.2 8.9-10.9-.19-2.92-1.62-4.64-3.93-5.96C27.84 36.8 25 36 21.79 35.1c-3.89-1.1-8.4-2.32-11.85-4.87-4.15-3.06-6.99-6.6-6.02-13.23z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M107.78 48.26c3.15-4.49 4.72-10.92 4.72-19.28 0-8.36-1.56-14.77-4.69-19.24C104.7 5.24 100.2 3 94.34 3 88.4 3 83.87 5.23 80.72 9.7 77.57 14.15 76 20.55 76 28.91c0 8.43 1.57 14.9 4.72 19.39 3.15 4.47 7.67 6.7 13.55 6.7 5.86 0 10.36-2.25 13.5-6.74zm-19.94-6.11c-1.46-3.02-2.19-7.4-2.19-13.17 0-5.78.73-10.17 2.2-13.16 1.45-3.02 3.62-4.53 6.49-4.53 5.65 0 8.47 5.9 8.47 17.7 0 11.79-2.85 17.68-8.54 17.68-2.83 0-4.97-1.5-6.43-4.52zM128.2 54c1.28.74 2.66 1 4.31 1 3.53 0 6.4-1.67 8.44-5.24C142.98 46.2 144 41.28 144 35c0-6.36-.99-11.28-2.96-14.76-1.97-3.5-4.7-5.24-8.18-5.24-3.62 0-6.46 2.16-8.36 6h-.5l-1.5-5h-7v55.5h9V55c0-.65-.13-2.85-.5-6h.5a10.06 10.06 0 003.69 5zm-2.3-28.62c.8-1.69 2.09-2.53 3.88-2.53 1.67 0 2.9 1 3.68 2.98.8 2 1.2 5 1.2 9.03 0 8.2-1.6 12.3-4.81 12.3-1.86 0-3.19-.98-4-2.92-.8-1.95-1.2-5.05-1.2-9.3v-1.22c.05-3.9.46-6.67 1.24-8.34zM161.64 55c-4.84 0-8.67-1.7-11.48-5.13-2.78-3.44-4.17-8.3-4.17-14.58 0-6.37 1.26-11.34 3.8-14.92 2.52-3.58 6.04-5.37 10.56-5.37 4.23 0 7.55 1.54 9.99 4.6 2.43 3.05 3.65 7.34 3.65 12.85v5.05h-18.5c.07 3.44.67 5.88 2.01 7.56a6.77 6.77 0 005.57 2.5c3.01 0 6.1-.94 9.25-2.81v7.58c-2.97 1.78-6.53 2.67-10.68 2.67zm-1.35-32.9c-1.33 0-2.42.7-3.27 2.11-.86 1.39-1.4 3.86-1.53 6.79h9.5c-.05-2.82-.55-5.26-1.37-6.72-.8-1.45-1.92-2.18-3.33-2.18zm36.2 8.9v23h9V29.2c0-4.64-.88-8.17-2.63-10.58C201.14 16.2 198.52 15 195 15c-2.08 0-3.9.51-5.44 1.53-1.55 1-2.74 2.68-3.57 4.47h-.5l-1.25-5H177v38h9.5V35.75c0-4.71.17-7.92 1.1-9.9.92-1.99 2.37-2.98 4.36-2.98 1.5 0 2.59.71 3.25 2.15A13.12 13.12 0 01196.5 31z"/></g><g class="b"><path d="M48.08 41a24.43 24.43 0 003.87-14.9c-.86-13.73-13.3-24.14-25.03-23.02-4.6.45-9.31 4.2-8.9 10.9.19 2.92 1.62 4.64 3.93 5.96C24.16 21.2 27 22 30.21 22.9c3.89 1.1 8.4 2.32 11.85 4.87 4.15 3.06 6.99 6.6 6.02 13.23z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M362.5 31v23h9V29c0-4.6-.9-8.09-2.7-10.45-1.8-2.38-4.52-3.55-8.05-3.55-3.83 0-6.9 2.24-8.75 6h-.5c.14-1.94.26-3.05.35-3.86.1-.84.15-1.36.15-2.14V.5h-9V54h9.5V35.5c0-4.15.14-7.22 1-9.42.85-2.22 2.34-3.33 4.46-3.33 2.84 0 4.54 2.63 4.54 8.25zM231.85 51.23c2.43-2.52 3.65-6.14 3.65-10.86 0-2.96-.67-5.59-2-7.9-1.3-2.3-3.63-4.56-6.98-6.77-2.48-1.62-4.22-3.06-5.23-4.33a7.08 7.08 0 01-1.47-4.46c0-1.73.41-3.1 1.23-4.08a4.39 4.39 0 013.58-1.53c1.4 0 2.7.26 3.93.76 1.23.51 2.41 1.09 3.54 1.73l3.15-7.54A21.76 21.76 0 00223.93 3c-4.12 0-7.4 1.27-9.86 3.8-2.43 2.54-3.65 5.98-3.65 10.32 0 2.26.3 4.24.91 5.95.63 1.7 1.51 3.25 2.63 4.63a24.91 24.91 0 005.02 4.3c2.53 1.7 4.34 3.26 5.44 4.66a7.22 7.22 0 011.65 4.6c0 1.71-.47 3.06-1.4 4.05-.92 1-2.29 1.49-4.11 1.49-3.2 0-6.72-1.23-10.56-3.7v9.3c3.13 1.74 6.93 2.6 11.4 2.6 4.56 0 8.04-1.26 10.45-3.77zm9.82-1.36c2.81 3.42 6.64 5.13 11.48 5.13 4.15 0 7.71-.89 10.68-2.67v-7.58c-3.15 1.87-6.24 2.8-9.25 2.8a6.77 6.77 0 01-5.57-2.49c-1.34-1.68-1.94-4.12-2.01-7.56h18.5v-5.05c0-5.51-1.22-9.8-3.65-12.84-2.44-3.07-5.76-4.61-9.99-4.61-4.52 0-8.04 1.79-10.57 5.37-2.53 3.58-3.79 8.55-3.79 14.92 0 6.28 1.4 11.14 4.17 14.58zm6.86-25.66c.85-1.4 1.94-2.11 3.27-2.11 1.41 0 2.52.73 3.33 2.18.82 1.46 1.32 3.9 1.37 6.72H247c.14-2.93.67-5.4 1.53-6.79zM288 54l-1.5-5h-.5c-1.38 2.26-2.7 3.87-4.18 4.72a10.99 10.99 0 01-5.57 1.28 8.17 8.17 0 01-6.8-3.18c-1.63-2.12-2.45-5.07-2.45-8.85 0-4.06 1.12-7.07 3.36-9.02 2.27-1.99 5.65-3.08 10.13-3.29l5.19-.2v-2.77c0-3.6-1.58-5.4-4.73-5.4-2.34 0-5.03.9-8.06 2.7l-3.23-6.36A23.23 23.23 0 01282.25 15c4.13 0 7.34 1.18 9.5 3.53 2.16 2.32 3.25 5.63 3.25 9.92V54h-7zm-7.93-6.2c1.7 0 3.06-.74 4.07-2.24 1.02-1.52 1.54-3.54 1.54-6.05v-3.25l-2.88.14c-2.12.12-3.69.71-4.7 1.8-.97 1.08-1.46 2.7-1.46 4.84 0 3.18 1.14 4.77 3.43 4.77zM318 15.76a14.31 14.31 0 00-3.78-.75 6.1 6.1 0 00-4.13 1.55A10.4 10.4 0 00307 21h-.5l-1.5-5h-7v38h9.46V34c0-3.36.22-5.52 1.4-7.27a5.76 5.76 0 015.09-2.66c1.02 0 1.91.2 2.55.43l1.5-8.75zM332 55c-4.56 0-8.05-1.52-10.43-4.87-2.38-3.35-3.57-8.27-3.57-14.75 0-6.8 1.12-11.86 3.37-15.2 2.26-3.35 5.65-5.18 10.37-5.18 1.41 0 3.01.36 4.57.78 1.56.41 3.45.94 4.69 1.72l-3.11 7.24c-1.9-1.13-3.58-1.7-5.05-1.7-1.95 0-3.35 1.04-4.23 3.09-.84 2.03-1.27 5.1-1.27 9.18 0 4 .43 6.98 1.27 8.97.85 1.96 2.24 2.94 4.16 2.94 2.3 0 4.68-.8 7.18-2.42v8.1c-2.4 1.5-5.04 2.1-7.95 2.1z"/></g></svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

+49
View File
@@ -0,0 +1,49 @@
![OpenSearch logo](OpenSearch.svg)
- [Welcome!](#welcome)
- [Project Resources](#project-resources)
- [Code of Conduct](#code-of-conduct)
- [Sample code](#sample-code)
- [Compatibility with OpenSearch](#compatibility-with-opensearch)
- [License](#license)
- [Copyright](#copyright)
## Welcome!
**opensearch-php** is [a community-driven, open source fork](https://aws.amazon.com/blogs/opensource/introducing-opensearch/) of elasticsearch-php licensed under the [Apache v2.0 License](LICENSE). For more information, see [opensearch.org](https://opensearch.org/).
## Project Resources
* [Project Website](https://opensearch.org/)
* [User Guide](USER_GUIDE.md)
* [Samples](samples)
* [Developer Guide](DEVELOPER_GUIDE.md)
* [Downloads](https://opensearch.org/downloads/).
* [Documentation](https://docs.opensearch.org/latest/)
* Need help? Try [Forums](https://forum.opensearch.org/)
* [Project Principles](https://opensearch.org/#principles)
* [Contributing to OpenSearch](CONTRIBUTING.md)
* [Maintainer Responsibilities](MAINTAINERS.md)
* [Release Management](RELEASING.md)
* [Admin Responsibilities](ADMINS.md)
* [Security](SECURITY.md)
## Code of Conduct
This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUCT.md). For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq), or contact [opensource-codeofconduct@amazon.com](mailto:opensource-codeofconduct@amazon.com) with any additional questions or comments.
## Sample code
See [Sample Code](USER_GUIDE.md).
## Compatibility with OpenSearch
See [Compatibility](COMPATIBILITY.md).
## License
This project is licensed under the [Apache v2.0 License](LICENSE).
## Copyright
Copyright OpenSearch Contributors. See [NOTICE](NOTICE) for details.
+3
View File
@@ -0,0 +1,3 @@
## Reporting a Vulnerability
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](https://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. Please do **not** create a public GitHub issue.
+63
View File
@@ -0,0 +1,63 @@
- [Upgrading OpenSearch PHP Client](#upgrading-opensearch-php-client)
- [Upgrading to \>= 2.4.0](#upgrading-to--240)
- [PSR-18 HTTP Client Interfaces](#psr-18-http-client-interfaces)
- [Configuring Guzzle HTTP Client in 2.4.x](#configuring-guzzle-http-client-in-24x)
- [Configuring Symfony HTTP Client in 2.4.x](#configuring-symfony-http-client-in-24x)
# Upgrading OpenSearch PHP Client
## Upgrading to >= 2.4.0
The openseach-php library removes the hard-coded dependency on the [Guzzle HTTP client](https://docs.guzzlephp.org/en/stable/#) and switches to the following PSR interfaces:
- [PSR-7 HTTP message interfaces](https://www.php-fig.org/psr/psr-7/)
- [PSR-17 HTTP Factories](https://www.php-fig.org/psr/psr-17/)
- [PSR-18 HTTP Client](https://www.php-fig.org/psr/psr-18/)
You can continue to use Guzzle, but will need to configure it as a PSR-18 HTTP Client.
### PSR-18 HTTP Client Interfaces
Starting with opensearch-php 2.4.0 you can use any PSR-18 compatible HTTP client.
To simplify creating a Client, we provide two factories to create PSR-18 HTTP clients for Guzzle and Symfony HTTP clients since opensearch-php 2.5.0.
### Configuring Guzzle HTTP Client in 2.4.x
To configure Guzzle as a PSR HTTP Client with the similar configuration to opensearch-php 1.x you can use the following example:
Ensure the Guzzle packages are installed via composer:
```php
composer require guzzlehttp/guzzle
```
```php
$client = (new \OpenSearch\GuzzleClientFactory())->create([
'base_uri' => 'https://localhost:9200',
'auth' => ['admin', getenv('OPENSEARCH_PASSWORD')],
'verify' => false,
]);
// Send a request to the 'info' endpoint.
$info = $client->info();
```
### Configuring Symfony HTTP Client in 2.4.x
You can configure [Symfony HTTP Client](https://symfony.com/doc/current/http_client.html) as a PSR HTTP Client using the following example:
```php
composer require symfony/http-client
```
```php
$client = (new \OpenSearch\SymfonyClientFactory())->create([
'base_uri' => 'https://localhost:9200',
'auth_basic' => ['admin', getenv('OPENSEARCH_PASSWORD')],
'verify_peer' => false,
]);
// Send a request to the 'info' endpoint.
$info = $client->info();
```
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env php
<?php
require __DIR__.'/../vendor/autoload.php';
use OpenSearch\Util\Command\GenerateEndpointsCommand;
use OpenSearch\Util\Command\UpdateChangelogCommand;
use Symfony\Component\Console\Application;
$app = new Application();
$app->addCommand(new GenerateEndpointsCommand());
$app->addCommand(new UpdateChangelogCommand());
$app->run();
+114
View File
@@ -0,0 +1,114 @@
{
"name": "opensearch-project/opensearch-php",
"description": "PHP Client for OpenSearch",
"keywords": [
"search",
"client",
"opensearch",
"elasticsearch"
],
"type": "library",
"license": [
"Apache-2.0",
"LGPL-2.1-only"
],
"authors": [
{
"name": "Elastic"
},
{
"name": "OpenSearch Contributors"
}
],
"require": {
"php": "^8.2",
"ext-json": ">=1.3.7",
"ext-curl": "*",
"ezimuel/ringphp": "^1.4.0",
"php-http/discovery": "^1.20",
"psr/http-client": "^1.0.3",
"psr/http-client-implementation": "*",
"psr/http-factory": "^1.1.0",
"psr/http-factory-implementation": "*",
"psr/http-message": "^2.0",
"psr/http-message-implementation": "*",
"psr/log": "^3.0.2",
"symfony/yaml": "^v6.4.26|^7.3.5|^v8.0.0"
},
"require-dev": {
"ext-zip": "*",
"aws/aws-sdk-php": "^3.359.8",
"colinodell/psr-testlogger": "^1.3.1",
"friendsofphp/php-cs-fixer": "^v3.89.1",
"guzzlehttp/psr7": "^2.8.0",
"mockery/mockery": "^1.6.12",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^1.12.32",
"phpstan/phpstan-deprecation-rules": "^1.2.1",
"phpstan/phpstan-mockery": "^1.1.3",
"phpstan/phpstan-phpunit": "^1.4.2",
"phpunit/phpunit": "^10.5.58",
"react/promise": "^v3.3",
"symfony/console": "v6.4.31|^7.4.3|^8.0.3",
"symfony/finder": "^v6.4.31|^7.4.3|^v8.0.3",
"symfony/http-client": "^6.4.31|^7.4.3|^v8.0.3",
"symfony/http-client-contracts": "^v3.6.0|^v8.0.3",
"twig/twig": "^3.0"
},
"suggest": {
"monolog/monolog": "Allows for client-level logging and tracing",
"aws/aws-sdk-php": "Required (^3.0.0) in order to use the AWS Signing Client Decorator",
"guzzlehttp/psr7": "Required (^2.7) in order to use the Guzzle HTTP client",
"symfony/http-client": "Required (^6.4|^7.0|^8.0) in order to use the Symfony HTTP client"
},
"autoload": {
"psr-4": {
"OpenSearch\\": "src/OpenSearch/"
}
},
"autoload-dev": {
"psr-4": {
"OpenSearch\\Tests\\": "tests/",
"OpenSearch\\Util\\": "util/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": true,
"phpstan/extension-installer": true
}
},
"scripts": {
"php-cs": [
"php-cs-fixer fix"
],
"phpstan": [
"phpstan analyse --no-progress"
],
"unit": [
"phpunit --exclude-group integration"
],
"integration": [
"phpunit --group integration"
],
"integration-min": [
"phpunit --group integration-min"
],
"phpunit": [
"phpunit"
],
"apigen": [
"rm -f apigen",
"curl -L https://github.com/ApiGen/ApiGen/releases/download/v7.0.0-alpha.4/apigen.phar -o apigen",
"chmod +x apigen",
"./apigen src --output docs",
"rm -f apigen"
],
"generate-api": [
"php bin/console app:generate-endpoints",
"composer run php-cs",
"php bin/console app:update-changelog"
]
}
}
+6
View File
@@ -0,0 +1,6 @@
exclude_path = ["vendor"]
accept = ["200","403","429"]
exclude = [
"https://localhost:9200",
"^mailto:",
]
@@ -0,0 +1,45 @@
<?php
namespace OpenSearch\Aws;
use Aws\Credentials\CredentialsInterface;
use Aws\Signature\SignatureInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* A decorator client that signs requests using the provided AWS credentials and signer.
*/
class SigningClientDecorator implements ClientInterface
{
/**
* @param ClientInterface $inner The client to decorate.
* @param CredentialsInterface $credentials The AWS credentials to use for signing requests.
* @param SignatureInterface $signer The AWS signer to use for signing requests.
* @param array $headers Additional headers to add to the request. `Host` is required.
* @return void
*/
public function __construct(
protected ClientInterface $inner,
protected CredentialsInterface $credentials,
protected SignatureInterface $signer,
protected array $headers = []
) {
}
public function sendRequest(RequestInterface $request): ResponseInterface
{
foreach ($this->headers as $name => $value) {
$request = $request->withHeader($name, $value);
}
if (empty($request->getHeaderLine('Host'))) {
throw new \RuntimeException('Missing Host header.');
}
$request = $request->withHeader('x-amz-content-sha256', hash('sha256', (string) $request->getBody()));
$request = $this->signer->signRequest($request, $this->credentials);
return $this->inner->sendRequest($request);
}
}
@@ -0,0 +1,115 @@
<?php
declare(strict_types=1);
namespace OpenSearch\Aws;
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\Credentials;
use Aws\Exception\CredentialsException;
use Aws\Signature\SignatureInterface;
use Aws\Signature\SignatureV4;
use Psr\Http\Client\ClientInterface;
use Psr\Log\LoggerInterface;
/**
* A factory for creating an HTTP Client that signs requests using AWS credentials.
*/
class SigningClientFactory
{
/**
* The allowed AWS services.
*/
public const ALLOWED_SERVICES = ['es', 'aoss'];
public function __construct(
protected ?SignatureInterface $signer = null,
protected ?CredentialProvider $provider = null,
protected ?LoggerInterface $logger = null,
) {
}
/**
* Creates a new signing client.
*
* @param ClientInterface $innerClient
* The decorated inner HTTP client.
* @param array<string,string> $options
* The AWS auth options.
*/
public function create(ClientInterface $innerClient, array $options): ClientInterface
{
if (!isset($options['host'])) {
throw new \InvalidArgumentException('The host option is required.');
}
// Get the credentials.
$provider = $this->getCredentialProvider($options);
$promise = $provider();
try {
$credentials = $promise->wait();
} catch (CredentialsException $e) {
$this->logger?->error('Failed to get AWS credentials: @message', ['@message' => $e->getMessage()]);
$credentials = new Credentials('', '');
}
// Get the signer.
$signer = $this->getSigner($options);
return new SigningClientDecorator($innerClient, $credentials, $signer, ['host' => $options['host']]);
}
/**
* Gets the credential provider.
*
* @param array<string,mixed> $options
* The options array.
*/
protected function getCredentialProvider(array $options): CredentialProvider|\Closure|null|callable
{
// Check for a provided credential provider.
if ($this->provider) {
return $this->provider;
}
// Check for provided access key and secret.
if (isset($options['credentials'])) {
return CredentialProvider::fromCredentials(
new Credentials(
$options['credentials']['access_key'] ?? '',
$options['credentials']['secret_key'] ?? '',
$options['credentials']['session_token'] ?? null,
)
);
}
// Fallback to the default provider.
return CredentialProvider::defaultProvider();
}
/**
* Gets the request signer.
*
* @param array<string,string> $options
* The options.
*/
protected function getSigner(array $options): SignatureInterface
{
if ($this->signer) {
return $this->signer;
}
if (!isset($options['region'])) {
throw new \InvalidArgumentException('The region option is required.');
}
$service = $options['service'] ?? 'es';
if (!in_array($service, self::ALLOWED_SERVICES, true)) {
throw new \InvalidArgumentException('The service option must be either "es" or "aoss".');
}
return new SignatureV4($service, $options['region'], $options);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,861 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch;
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\Credentials;
use Aws\Credentials\CredentialsInterface;
use GuzzleHttp\Ring\Client\CurlHandler;
use GuzzleHttp\Ring\Client\CurlMultiHandler;
use GuzzleHttp\Ring\Client\Middleware;
use OpenSearch\Common\Exceptions\AuthenticationConfigException;
use OpenSearch\Common\Exceptions\InvalidArgumentException;
use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\ConnectionPool\AbstractConnectionPool;
use OpenSearch\ConnectionPool\Selectors\RoundRobinSelector;
use OpenSearch\ConnectionPool\Selectors\SelectorInterface;
use OpenSearch\ConnectionPool\StaticNoPingConnectionPool;
use OpenSearch\Connections\ConnectionFactory;
use OpenSearch\Connections\ConnectionFactoryInterface;
use OpenSearch\Connections\ConnectionInterface;
use OpenSearch\Handlers\SigV4Handler;
use OpenSearch\Namespaces\NamespaceBuilderInterface;
use OpenSearch\Serializers\SerializerInterface;
use OpenSearch\Serializers\SmartSerializer;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use ReflectionClass;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(ClientBuilder::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class ClientBuilder
{
public const ALLOWED_METHODS_FROM_CONFIG = ['includePortInHostHeader'];
/**
* @var Transport|null
*/
private $transport;
private ?EndpointFactoryInterface $endpointFactory = null;
/**
* @var NamespaceBuilderInterface[]
*/
private $registeredNamespacesBuilders = [];
/**
* @var ConnectionFactoryInterface|null
*/
private $connectionFactory;
/**
* @var callable|null
*/
private $handler;
/**
* @var LoggerInterface|null
*/
private $logger;
/**
* @var LoggerInterface|null
*/
private $tracer;
/**
* @var string|AbstractConnectionPool
*/
private $connectionPool = StaticNoPingConnectionPool::class;
/**
* @var string|SerializerInterface|null
*/
private $serializer = SmartSerializer::class;
/**
* @var string|SelectorInterface|null
*/
private $selector = RoundRobinSelector::class;
/**
* @var array
*/
private $connectionPoolArgs = [
'randomizeHosts' => true
];
/**
* @var array|null
*/
private $hosts;
/**
* @var array
*/
private $connectionParams;
/**
* @var int|null
*/
private $retries;
/**
* @var null|callable
*/
private $sigV4CredentialProvider;
/**
* @var null|string
*/
private $sigV4Region;
/**
* @var null|string
*/
private $sigV4Service;
/**
* @var bool
*/
private $sniffOnStart = false;
/**
* @var null|array
*/
private $sslCert;
/**
* @var null|array
*/
private $sslKey;
/**
* @var null|bool|string
*/
private $sslVerification;
/**
* @var bool
*/
private $includePortInHostHeader = false;
/**
* @var string|null
*/
private $basicAuthentication = null;
/**
* Create an instance of ClientBuilder
*/
public static function create(): ClientBuilder
{
return new self();
}
/**
* Can supply first param to Client::__construct() when invoking manually or with dependency injection
*/
public function getTransport(): Transport
{
return $this->transport;
}
/**
* Can supply second param to Client::__construct() when invoking manually or with dependency injection
*
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::getEndpointFactory() instead.
*/
public function getEndpoint(): callable
{
@trigger_error(__METHOD__ . '() is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::getEndpointFactory() instead.', E_USER_DEPRECATED);
return fn ($c) => $this->endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c);
}
/**
* Can supply third param to Client::__construct() when invoking manually or with dependency injection
*
* @return NamespaceBuilderInterface[]
*/
public function getRegisteredNamespacesBuilders(): array
{
return $this->registeredNamespacesBuilders;
}
/**
* Build a new client from the provided config. Hash keys
* should correspond to the method name e.g. ['connectionPool']
* corresponds to setConnectionPool().
*
* Missing keys will use the default for that setting if applicable
*
* Unknown keys will throw an exception by default, but this can be silenced
* by setting `quiet` to true
*
* @param array $config
* @param bool $quiet False if unknown settings throw exception, true to silently
* ignore unknown settings
* @throws Common\Exceptions\RuntimeException
*/
public static function fromConfig(array $config, bool $quiet = false): Client
{
$builder = new self();
foreach ($config as $key => $value) {
$method = in_array($key, self::ALLOWED_METHODS_FROM_CONFIG, true) ? $key : "set$key";
$reflection = new ReflectionClass($builder);
if ($reflection->hasMethod($method)) {
$func = $reflection->getMethod($method);
if ($func->getNumberOfParameters() > 1) {
$builder->$method(...$value);
} else {
$builder->$method($value);
}
unset($config[$key]);
}
}
if ($quiet === false && count($config) > 0) {
$unknown = implode(array_keys($config));
throw new RuntimeException("Unknown parameters provided: $unknown");
}
return $builder->build();
}
/**
* Get the default handler
*
* @param array $multiParams
* @param array $singleParams
* @throws \RuntimeException
*/
public static function defaultHandler(array $multiParams = [], array $singleParams = []): callable
{
$future = null;
if (extension_loaded('curl')) {
$config = array_merge([ 'mh' => curl_multi_init() ], $multiParams);
if (function_exists('curl_reset')) {
$default = new CurlHandler($singleParams);
$future = new CurlMultiHandler($config);
} else {
$default = new CurlMultiHandler($config);
}
} else {
throw new \RuntimeException('OpenSearch-PHP requires cURL, or a custom HTTP handler.');
}
return $future ? Middleware::wrapFuture($default, $future) : $default;
}
/**
* Get the multi handler for async (CurlMultiHandler)
*
* @throws \RuntimeException
*/
public static function multiHandler(array $params = []): CurlMultiHandler
{
if (function_exists('curl_multi_init')) {
return new CurlMultiHandler(array_merge([ 'mh' => curl_multi_init() ], $params));
}
throw new \RuntimeException('CurlMulti handler requires cURL.');
}
/**
* Get the handler instance (CurlHandler)
*
* @throws \RuntimeException
*/
public static function singleHandler(): CurlHandler
{
if (function_exists('curl_reset')) {
return new CurlHandler();
}
throw new \RuntimeException('CurlSingle handler requires cURL.');
}
/**
* Set connection Factory
*
* @param ConnectionFactoryInterface $connectionFactory
*/
public function setConnectionFactory(ConnectionFactoryInterface $connectionFactory): ClientBuilder
{
$this->connectionFactory = $connectionFactory;
return $this;
}
/**
* Set the connection pool (default is StaticNoPingConnectionPool)
*
* @param AbstractConnectionPool|string $connectionPool
* @param array $args
* @throws \InvalidArgumentException
*/
public function setConnectionPool($connectionPool, array $args = []): ClientBuilder
{
if (is_string($connectionPool)) {
$this->connectionPool = $connectionPool;
$this->connectionPoolArgs = $args;
} elseif (is_object($connectionPool)) {
$this->connectionPool = $connectionPool;
} else {
throw new InvalidArgumentException("Serializer must be a class path or instantiated object extending AbstractConnectionPool");
}
return $this;
}
/**
* Set the endpoint
*
* @param callable $endpoint
*
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::setEndpointFactory() instead.
*/
public function setEndpoint(callable $endpoint): ClientBuilder
{
@trigger_error(__METHOD__ . '() is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\ClientBuilder::setEndpointFactory() instead.', E_USER_DEPRECATED);
$this->endpointFactory = new LegacyEndpointFactory($endpoint);
return $this;
}
public function setEndpointFactory(EndpointFactoryInterface $endpointFactory): ClientBuilder
{
$this->endpointFactory = $endpointFactory;
return $this;
}
/**
* Register namespace
*
* @param NamespaceBuilderInterface $namespaceBuilder
*/
public function registerNamespace(NamespaceBuilderInterface $namespaceBuilder): ClientBuilder
{
$this->registeredNamespacesBuilders[] = $namespaceBuilder;
return $this;
}
/**
* Set the transport
*
* @param Transport $transport
*/
public function setTransport(Transport $transport): ClientBuilder
{
$this->transport = $transport;
return $this;
}
/**
* Set the HTTP handler (cURL is default)
*
* @param mixed $handler
*/
public function setHandler($handler): ClientBuilder
{
$this->handler = $handler;
return $this;
}
/**
* Set the PSR-3 Logger
*
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger): ClientBuilder
{
$this->logger = $logger;
return $this;
}
/**
* Set the PSR-3 tracer
*
* @param LoggerInterface $tracer
*/
public function setTracer(LoggerInterface $tracer): ClientBuilder
{
$this->tracer = $tracer;
return $this;
}
/**
* Set the serializer
*
* @param \OpenSearch\Serializers\SerializerInterface|string $serializer
*/
public function setSerializer($serializer): ClientBuilder
{
$this->parseStringOrObject($serializer, $this->serializer, 'SerializerInterface');
return $this;
}
/**
* Set the hosts (nodes)
*
* @param array $hosts
*/
public function setHosts(array $hosts): ClientBuilder
{
$this->hosts = $hosts;
return $this;
}
/**
* Set Basic access authentication
*
* @see https://en.wikipedia.org/wiki/Basic_access_authentication
* @param string $username
* @param string $password
*
* @throws AuthenticationConfigException
*/
public function setBasicAuthentication(string $username, string $password): ClientBuilder
{
$this->basicAuthentication = $username.':'.$password;
return $this;
}
/**
* Set connection parameters
*
* @param array $params
*/
public function setConnectionParams(array $params): ClientBuilder
{
$this->connectionParams = $params;
return $this;
}
/**
* Set number or retries (default is equal to number of nodes)
*
* @param int $retries
*/
public function setRetries(int $retries): ClientBuilder
{
$this->retries = $retries;
return $this;
}
/**
* Set the selector algorithm
*
* @param \OpenSearch\ConnectionPool\Selectors\SelectorInterface|string $selector
*/
public function setSelector($selector): ClientBuilder
{
$this->parseStringOrObject($selector, $this->selector, 'SelectorInterface');
return $this;
}
/**
* Set the credential provider for SigV4 request signing. The value provider should be a
* callable object that will return
*
* @param callable|bool|array|CredentialsInterface|null $credentialProvider
*/
public function setSigV4CredentialProvider($credentialProvider): ClientBuilder
{
if ($credentialProvider !== null && $credentialProvider !== false) {
$this->sigV4CredentialProvider = $this->normalizeCredentialProvider($credentialProvider);
}
return $this;
}
/**
* Set the region for SigV4 signing.
*
* @param string|null $region
*/
public function setSigV4Region($region): ClientBuilder
{
$this->sigV4Region = $region;
return $this;
}
/**
* Set the service for SigV4 signing.
*
* @param string|null $service
*/
public function setSigV4Service($service): ClientBuilder
{
$this->sigV4Service = $service;
return $this;
}
/**
* Set sniff on start
*
* @param bool $sniffOnStart enable or disable sniff on start
*/
public function setSniffOnStart(bool $sniffOnStart): ClientBuilder
{
$this->sniffOnStart = $sniffOnStart;
return $this;
}
/**
* Set SSL certificate
*
* @param string $cert The name of a file containing a PEM formatted certificate.
* @param string $password if the certificate requires a password
*/
public function setSSLCert(string $cert, ?string $password = null): ClientBuilder
{
$this->sslCert = [$cert, $password];
return $this;
}
/**
* Set SSL key
*
* @param string $key The name of a file containing a private SSL key
* @param string $password if the private key requires a password
*/
public function setSSLKey(string $key, ?string $password = null): ClientBuilder
{
$this->sslKey = [$key, $password];
return $this;
}
/**
* Set SSL verification
*
* @param bool|string $value
*/
public function setSSLVerification($value = true): ClientBuilder
{
$this->sslVerification = $value;
return $this;
}
/**
* Include the port in Host header
*
* @see https://github.com/elastic/elasticsearch-php/issues/993
*/
public function includePortInHostHeader(bool $enable): ClientBuilder
{
$this->includePortInHostHeader = $enable;
return $this;
}
/**
* Build and returns the Client object
*/
public function build(): Client
{
$this->buildLoggers();
if (is_null($this->handler)) {
$this->handler = ClientBuilder::defaultHandler();
}
if (!is_null($this->sigV4CredentialProvider)) {
if (is_null($this->sigV4Region)) {
throw new RuntimeException("A region must be supplied for SigV4 request signing.");
}
if (is_null($this->sigV4Service)) {
$this->setSigV4Service("es");
}
$this->handler = new SigV4Handler($this->sigV4Region, $this->sigV4Service, $this->sigV4CredentialProvider, $this->handler);
}
$sslOptions = null;
if (isset($this->sslKey)) {
$sslOptions['ssl_key'] = $this->sslKey;
}
if (isset($this->sslCert)) {
$sslOptions['cert'] = $this->sslCert;
}
if (isset($this->sslVerification)) {
$sslOptions['verify'] = $this->sslVerification;
}
if (!is_null($sslOptions)) {
$sslHandler = function (callable $handler, array $sslOptions) {
return function (array $request) use ($handler, $sslOptions) {
// Add our custom headers
foreach ($sslOptions as $key => $value) {
$request['client'][$key] = $value;
}
// Send the request using the handler and return the response.
return $handler($request);
};
};
$this->handler = $sslHandler($this->handler, $sslOptions);
}
if (is_null($this->serializer)) {
$this->serializer = new SmartSerializer();
} elseif (is_string($this->serializer)) {
$this->serializer = new $this->serializer();
}
$this->connectionParams['client']['port_in_header'] = $this->includePortInHostHeader;
if (! is_null($this->basicAuthentication)) {
if (isset($this->connectionParams['client']['curl']) === false) {
$this->connectionParams['client']['curl'] = [];
}
$this->connectionParams['client']['curl'] += [
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $this->basicAuthentication
];
}
if (is_null($this->connectionFactory)) {
// Make sure we are setting Content-Type and Accept (unless the user has explicitly
// overridden it
if (! isset($this->connectionParams['client']['headers'])) {
$this->connectionParams['client']['headers'] = [];
}
if (! isset($this->connectionParams['client']['headers']['Content-Type'])) {
$this->connectionParams['client']['headers']['Content-Type'] = ['application/json'];
}
if (! isset($this->connectionParams['client']['headers']['Accept'])) {
$this->connectionParams['client']['headers']['Accept'] = ['application/json'];
}
$this->connectionFactory = new ConnectionFactory($this->handler, $this->connectionParams, $this->serializer, $this->logger, $this->tracer);
}
if (is_null($this->hosts)) {
$this->hosts = $this->getDefaultHost();
}
if (is_null($this->selector)) {
$this->selector = new RoundRobinSelector();
} elseif (is_string($this->selector)) {
$this->selector = new $this->selector();
}
$this->buildTransport();
if (is_null($this->endpointFactory)) {
$this->endpointFactory = new EndpointFactory($this->serializer);
}
$registeredNamespaces = [];
foreach ($this->registeredNamespacesBuilders as $builder) {
/**
* @var NamespaceBuilderInterface $builder
*/
$registeredNamespaces[$builder->getName()] = $builder->getObject($this->transport, $this->serializer);
}
return $this->instantiate($this->transport, $this->endpointFactory, $registeredNamespaces);
}
protected function instantiate(Transport $transport, EndpointFactoryInterface $endpointFactory, array $registeredNamespaces): Client
{
return new Client($transport, $endpointFactory, $registeredNamespaces);
}
private function buildLoggers(): void
{
if (is_null($this->logger)) {
$this->logger = new NullLogger();
}
if (is_null($this->tracer)) {
$this->tracer = new NullLogger();
}
}
private function buildTransport(): void
{
$connections = $this->buildConnectionsFromHosts($this->hosts);
if (is_string($this->connectionPool)) {
$this->connectionPool = new $this->connectionPool(
$connections,
$this->selector,
$this->connectionFactory,
$this->connectionPoolArgs
);
}
if (is_null($this->retries)) {
$this->retries = count($connections);
}
if (is_null($this->transport)) {
$this->transport = new Transport($this->retries, $this->connectionPool, $this->logger, $this->sniffOnStart);
}
}
private function parseStringOrObject($arg, &$destination, $interface): void
{
if (is_string($arg)) {
$destination = new $arg();
} elseif (is_object($arg)) {
$destination = $arg;
} else {
throw new InvalidArgumentException("Serializer must be a class path or instantiated object implementing $interface");
}
}
private function getDefaultHost(): array
{
return ['localhost:9200'];
}
/**
* @return ConnectionInterface[]
* @throws RuntimeException
*/
private function buildConnectionsFromHosts(array $hosts): array
{
$connections = [];
foreach ($hosts as $host) {
if (is_string($host)) {
$host = $this->prependMissingScheme($host);
$host = $this->extractURIParts($host);
} elseif (is_array($host)) {
$host = $this->normalizeExtendedHost($host);
} else {
$this->logger->error("Could not parse host: ".print_r($host, true));
throw new RuntimeException("Could not parse host: ".print_r($host, true));
}
$connections[] = $this->connectionFactory->create($host);
}
return $connections;
}
/**
* @throws RuntimeException
*/
private function normalizeExtendedHost(array $host): array
{
if (isset($host['host']) === false) {
$this->logger->error("Required 'host' was not defined in extended format: ".print_r($host, true));
throw new RuntimeException("Required 'host' was not defined in extended format: ".print_r($host, true));
}
if (isset($host['scheme']) === false) {
$host['scheme'] = 'http';
}
if (isset($host['port']) === false) {
$host['port'] = 9200;
}
return $host;
}
/**
* @throws InvalidArgumentException
*/
private function extractURIParts(string $host): array
{
$parts = parse_url($host);
if ($parts === false) {
throw new InvalidArgumentException(sprintf('Could not parse URI: "%s"', $host));
}
if (isset($parts['port']) !== true) {
$parts['port'] = 9200;
}
return $parts;
}
private function prependMissingScheme(string $host): string
{
if (!preg_match("/^https?:\/\//", $host)) {
$host = 'http://' . $host;
}
return $host;
}
private function normalizeCredentialProvider($provider): ?callable
{
if ($provider === null || $provider === false) {
return null;
}
if (is_callable($provider)) {
return $provider;
}
SigV4Handler::assertDependenciesInstalled();
if ($provider === true) {
return CredentialProvider::defaultProvider();
}
if ($provider instanceof CredentialsInterface) {
return CredentialProvider::fromCredentials($provider);
} elseif (is_array($provider) && isset($provider['key']) && isset($provider['secret'])) {
return CredentialProvider::fromCredentials(
new Credentials(
$provider['key'],
$provider['secret'],
isset($provider['token']) ? $provider['token'] : null,
isset($provider['expires']) ? $provider['expires'] : null
)
);
}
throw new InvalidArgumentException('Credentials must be an instance of Aws\Credentials\CredentialsInterface, an'
. ' associative array that contains "key", "secret", and an optional "token" key-value pairs, a credentials'
. ' provider function, or true.');
}
}
@@ -0,0 +1,17 @@
<?php
namespace OpenSearch;
/**
* Creates an OpenSearch client.
*/
interface ClientFactoryInterface
{
/**
* Creates a new OpenSearch client.
*
* @param array<string,mixed> $options
* The options to use when creating the client. The options are specific to the HTTP client implementation.
*/
public function create(array $options): Client;
}
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common;
use Psr\Log\AbstractLogger;
use Psr\Log\LoggerInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(EmptyLogger::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use Psr\Log\NullLogger instead', E_USER_DEPRECATED);
/**
* Class EmptyLogger
*
* Logger that doesn't do anything. Similar to Monolog's NullHandler,
* but avoids the overhead of partially loading Monolog
*
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use Psr\Log\NullLogger instead.
*/
class EmptyLogger extends AbstractLogger implements LoggerInterface
{
/**
* {@inheritDoc}
*/
public function log($level, $message, array $context = []): void
{
return;
}
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(AuthenticationConfigException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class AuthenticationConfigException extends \RuntimeException implements OpenSearchException
{
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(BadMethodCallException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* BadMethodCallException
*
* Denote problems with a method call (e.g. incorrect number of arguments)
*
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class BadMethodCallException extends \OpenSearch\Exception\BadMethodCallException
{
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(BadRequest400Exception::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class BadRequest400Exception extends \Exception implements OpenSearchException
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(ClientErrorResponseException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class ClientErrorResponseException extends TransportException implements OpenSearchException
{
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(Conflict409Exception::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class Conflict409Exception extends \Exception implements OpenSearchException
{
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions\Curl;
use OpenSearch\Common\Exceptions\OpenSearchException;
use OpenSearch\Common\Exceptions\TransportException;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(CouldNotConnectToHost::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class CouldNotConnectToHost extends TransportException implements OpenSearchException
{
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions\Curl;
use OpenSearch\Common\Exceptions\OpenSearchException;
use OpenSearch\Common\Exceptions\TransportException;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(CouldNotResolveHostException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class CouldNotResolveHostException extends TransportException implements OpenSearchException
{
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions\Curl;
use OpenSearch\Common\Exceptions\OpenSearchException;
use OpenSearch\Common\Exceptions\TransportException;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(OperationTimeoutException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class OperationTimeoutException extends TransportException implements OpenSearchException
{
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
use OpenSearch\Exception\ForbiddenHttpException;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(Forbidden403Exception::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\ForbiddenHttpException instead', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @see \OpenSearch\Exception\ForbiddenHttpException
*/
class Forbidden403Exception extends ForbiddenHttpException
{
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(InvalidArgumentException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class InvalidArgumentException extends \InvalidArgumentException implements OpenSearchException
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(MaxRetriesException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class MaxRetriesException extends TransportException implements OpenSearchException
{
}
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
use OpenSearch\Exception\NotFoundHttpException;
@trigger_error(
// @phpstan-ignore classConstant.deprecatedClass
Missing404Exception::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\NotFoundHttpException instead.',
E_USER_DEPRECATED
);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @see \OpenSearch\Exception\NotFoundHttpException
*/
class Missing404Exception extends NotFoundHttpException
{
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
@trigger_error(
// @phpstan-ignore classConstant.deprecatedClass
NoDocumentsToGetException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\NoDocumentsToGetException instead.',
E_USER_DEPRECATED
);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\NoDocumentsToGetException instead.
*
* @see \OpenSearch\Exception\ScriptLangNotSupportedException
*/
class NoDocumentsToGetException extends \OpenSearch\Exception\NoDocumentsToGetException
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(NoNodesAvailableException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class NoNodesAvailableException extends ServerErrorResponseException implements OpenSearchException
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(NoShardAvailableException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\NoShardAvailableException instead.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\NoShardAvailableException instead.
*
* @see \OpenSearch\Exception\NoShardAvailableException
*/
class NoShardAvailableException extends \OpenSearch\Exception\NoShardAvailableException
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
use OpenSearch\Exception\OpenSearchExceptionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(NoNodesAvailableException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
interface OpenSearchException extends OpenSearchExceptionInterface
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(RequestTimeout408Exception::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class RequestTimeout408Exception extends BadRequest400Exception implements OpenSearchException
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(RoutingMissingException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\RoutingMissingException instead.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use OpenSearch\Exception\UnauthorizedHttpException instead.
*
* @see \OpenSearch\Exception\ScriptLangNotSupportedException
*/
class RoutingMissingException extends \OpenSearch\Exception\RoutingMissingException
{
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(RuntimeException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\RuntimeException instead.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\RuntimeException instead.
*/
class RuntimeException extends \OpenSearch\Exception\RuntimeException
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(ScriptLangNotSupportedException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use OpenSearch\Exception\ScriptLangNotSupportedException instead.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use OpenSearch\Exception\UnauthorizedHttpException instead.
*
* @see \OpenSearch\Exception\ScriptLangNotSupportedException
*/
class ScriptLangNotSupportedException extends \OpenSearch\Exception\ScriptLangNotSupportedException
{
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions\Serializer;
use OpenSearch\Exception\JsonException;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(JsonErrorException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\JsonErrorException instead.', E_USER_DEPRECATED);
/**
* Class JsonErrorException
*
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\JsonErrorException instead.
*/
class JsonErrorException extends JsonException
{
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(RequestTimeout408Exception::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class ServerErrorResponseException extends TransportException implements OpenSearchException
{
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(TransportException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class TransportException extends \Exception implements OpenSearchException
{
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
use OpenSearch\Exception\UnauthorizedHttpException;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(Unauthorized401Exception::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use OpenSearch\Exception\UnauthorizedHttpException instead.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use OpenSearch\Exception\UnauthorizedHttpException instead.
*
* @see \OpenSearch\Exception\UnauthorizedHttpException
*/
class Unauthorized401Exception extends UnauthorizedHttpException
{
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Common\Exceptions;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(UnexpectedValueException::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\UnexpectedValueException instead.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0. Use \OpenSearch\Exception\UnexpectedValueException instead.
*/
class UnexpectedValueException extends \OpenSearch\Exception\UnexpectedValueException
{
}
@@ -0,0 +1,101 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool;
use OpenSearch\Common\Exceptions\InvalidArgumentException;
use OpenSearch\ConnectionPool\Selectors\SelectorInterface;
use OpenSearch\Connections\ConnectionFactoryInterface;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(AbstractConnectionPool::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
abstract class AbstractConnectionPool implements ConnectionPoolInterface
{
/**
* Array of connections
*
* @var ConnectionInterface[]
*/
protected $connections;
/**
* Array of initial seed connections
*
* @var ConnectionInterface[]
*/
protected $seedConnections;
/**
* Selector object, used to select a connection on each request
*
* @var SelectorInterface
*/
protected $selector;
/**
* @var array<string, mixed>
*/
protected $connectionPoolParams;
/**
* @var ConnectionFactoryInterface
*/
protected $connectionFactory;
/**
* Constructor
*
* @param ConnectionInterface[] $connections The Connections to choose from
* @param SelectorInterface $selector A Selector instance to perform the selection logic for the available connections
* @param ConnectionFactoryInterface $factory ConnectionFactory instance
* @param array<string, mixed> $connectionPoolParams
*/
public function __construct(array $connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, array $connectionPoolParams)
{
$paramList = array('connections', 'selector', 'connectionPoolParams');
foreach ($paramList as $param) {
if (isset($$param) === false) {
throw new InvalidArgumentException('`' . $param . '` parameter must not be null');
}
}
if (isset($connectionPoolParams['randomizeHosts']) === true
&& $connectionPoolParams['randomizeHosts'] === true
) {
shuffle($connections);
}
$this->connections = $connections;
$this->seedConnections = $connections;
$this->selector = $selector;
$this->connectionPoolParams = $connectionPoolParams;
$this->connectionFactory = $factory;
}
abstract public function nextConnection(bool $force = false): ConnectionInterface;
abstract public function scheduleCheck(): void;
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedInterface
@trigger_error(ConnectionPoolInterface::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
interface ConnectionPoolInterface
{
public function nextConnection(bool $force = false): ConnectionInterface;
public function scheduleCheck(): void;
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool\Selectors;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(RandomSelector::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class RandomSelector implements SelectorInterface
{
/**
* Select a random connection from the provided array
*
* @param ConnectionInterface[] $connections an array of ConnectionInterface instances to choose from
*/
public function select(array $connections): ConnectionInterface
{
return $connections[array_rand($connections)];
}
}
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool\Selectors;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(RoundRobinSelector::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class RoundRobinSelector implements SelectorInterface
{
/**
* @var int
*/
private $current = 0;
/**
* Select the next connection in the sequence
*
* @param ConnectionInterface[] $connections an array of ConnectionInterface instances to choose from
*/
public function select(array $connections): ConnectionInterface
{
$returnConnection = $connections[$this->current % count($connections)];
$this->current += 1;
return $returnConnection;
}
}
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool\Selectors;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedInterface
@trigger_error(SelectorInterface::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
interface SelectorInterface
{
/**
* Perform logic to select a single ConnectionInterface instance from the array provided
*
* @param \OpenSearch\Connections\ConnectionInterface[] $connections an array of ConnectionInterface instances to choose from
*/
public function select(array $connections): ConnectionInterface;
}
@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool\Selectors;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(StickyRoundRobinSelector::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class StickyRoundRobinSelector implements SelectorInterface
{
/**
* @var int
*/
private $current = 0;
/**
* @var int
*/
private $currentCounter = 0;
/**
* Use current connection unless it is dead, otherwise round-robin
*
* @param ConnectionInterface[] $connections Array of connections to choose from
*/
public function select(array $connections): ConnectionInterface
{
/**
* @var ConnectionInterface[] $connections
*/
if ($connections[$this->current]->isAlive()) {
return $connections[$this->current];
}
$this->currentCounter += 1;
$this->current = $this->currentCounter % count($connections);
return $connections[$this->current];
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool;
use OpenSearch\ConnectionPool\Selectors\SelectorInterface;
use OpenSearch\Connections\ConnectionFactoryInterface;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(SimpleConnectionPool::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class SimpleConnectionPool extends AbstractConnectionPool implements ConnectionPoolInterface
{
/**
* @param ConnectionInterface[] $connections
* @param array<string, mixed> $connectionPoolParams
*/
public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams)
{
parent::__construct($connections, $selector, $factory, $connectionPoolParams);
}
public function nextConnection(bool $force = false): ConnectionInterface
{
return $this->selector->select($this->connections);
}
public function scheduleCheck(): void
{
}
}
@@ -0,0 +1,189 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool;
use OpenSearch\Common\Exceptions\Curl\OperationTimeoutException;
use OpenSearch\Common\Exceptions\NoNodesAvailableException;
use OpenSearch\ConnectionPool\Selectors\SelectorInterface;
use OpenSearch\Connections\Connection;
use OpenSearch\Connections\ConnectionFactoryInterface;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(SniffingConnectionPool::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class SniffingConnectionPool extends AbstractConnectionPool
{
/**
* @var int
*/
private $sniffingInterval;
/**
* @var int
*/
private $nextSniff;
/**
* @param ConnectionInterface[] $connections
* @param array<string, mixed> $connectionPoolParams
*/
public function __construct(
$connections,
SelectorInterface $selector,
ConnectionFactoryInterface $factory,
$connectionPoolParams
) {
parent::__construct($connections, $selector, $factory, $connectionPoolParams);
$this->setConnectionPoolParams($connectionPoolParams);
$this->nextSniff = time() + $this->sniffingInterval;
}
public function nextConnection(bool $force = false): ConnectionInterface
{
$this->sniff($force);
$size = count($this->connections);
while ($size--) {
/**
* @var Connection $connection
*/
$connection = $this->selector->select($this->connections);
if ($connection->isAlive() === true || $connection->ping() === true) {
return $connection;
}
}
if ($force === true) {
throw new NoNodesAvailableException("No alive nodes found in your cluster");
}
return $this->nextConnection(true);
}
public function scheduleCheck(): void
{
$this->nextSniff = -1;
}
private function sniff(bool $force = false): void
{
if ($force === false && $this->nextSniff > time()) {
return;
}
$total = count($this->connections);
while ($total--) {
/**
* @var Connection $connection
*/
$connection = $this->selector->select($this->connections);
if ($connection->isAlive() xor $force) {
continue;
}
if ($this->sniffConnection($connection) === true) {
return;
}
}
if ($force === true) {
return;
}
foreach ($this->seedConnections as $connection) {
/**
* @var Connection $connection
*/
if ($this->sniffConnection($connection) === true) {
return;
}
}
}
private function sniffConnection(Connection $connection): bool
{
try {
$response = $connection->sniff();
} catch (OperationTimeoutException $exception) {
return false;
}
$nodes = $this->parseClusterState($response);
if (count($nodes) === 0) {
return false;
}
$this->connections = [];
foreach ($nodes as $node) {
$nodeDetails = [
'host' => $node['host'],
'port' => $node['port'],
];
$this->connections[] = $this->connectionFactory->create($nodeDetails);
}
$this->nextSniff = time() + $this->sniffingInterval;
return true;
}
/**
* @return list<array{host: string, port: int}>
*/
private function parseClusterState($nodeInfo): array
{
$pattern = '/([^:]*):(\d+)/';
$hosts = [];
foreach ($nodeInfo['nodes'] as $node) {
if (isset($node['http']) === true && isset($node['http']['publish_address']) === true) {
if (preg_match($pattern, $node['http']['publish_address'], $match) === 1) {
$hosts[] = [
'host' => $match[1],
'port' => (int)$match[2],
];
}
}
}
return $hosts;
}
/**
* @param array<string, mixed> $connectionPoolParams
*/
private function setConnectionPoolParams(array $connectionPoolParams): void
{
$this->sniffingInterval = (int)($connectionPoolParams['sniffingInterval'] ?? 300);
}
}
@@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool;
use OpenSearch\Common\Exceptions\NoNodesAvailableException;
use OpenSearch\ConnectionPool\Selectors\SelectorInterface;
use OpenSearch\Connections\Connection;
use OpenSearch\Connections\ConnectionFactoryInterface;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(StaticConnectionPool::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class StaticConnectionPool extends AbstractConnectionPool implements ConnectionPoolInterface
{
/**
* @var int
*/
private $pingTimeout = 60;
/**
* @var int
*/
private $maxPingTimeout = 3600;
/**
* @param ConnectionInterface[] $connections
* @param array<string, mixed> $connectionPoolParams
*/
public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams)
{
parent::__construct($connections, $selector, $factory, $connectionPoolParams);
$this->scheduleCheck();
}
public function nextConnection(bool $force = false): ConnectionInterface
{
$skipped = [];
$total = count($this->connections);
while ($total--) {
/**
* @var Connection $connection
*/
$connection = $this->selector->select($this->connections);
if ($connection->isAlive() === true) {
return $connection;
}
if ($this->readyToRevive($connection) === true) {
if ($connection->ping() === true) {
return $connection;
}
} else {
$skipped[] = $connection;
}
}
// All "alive" nodes failed, force pings on "dead" nodes
foreach ($skipped as $connection) {
if ($connection->ping() === true) {
return $connection;
}
}
throw new NoNodesAvailableException("No alive nodes found in your cluster");
}
public function scheduleCheck(): void
{
foreach ($this->connections as $connection) {
$connection->markDead();
}
}
private function readyToRevive(Connection $connection): bool
{
$timeout = min(
$this->pingTimeout * pow(2, $connection->getPingFailures()),
$this->maxPingTimeout
);
if ($connection->getLastPing() + $timeout < time()) {
return true;
} else {
return false;
}
}
}
@@ -0,0 +1,96 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\ConnectionPool;
use OpenSearch\Common\Exceptions\NoNodesAvailableException;
use OpenSearch\ConnectionPool\Selectors\SelectorInterface;
use OpenSearch\Connections\Connection;
use OpenSearch\Connections\ConnectionFactoryInterface;
use OpenSearch\Connections\ConnectionInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(StaticNoPingConnectionPool::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*
* @phpstan-ignore class.extendsDeprecatedClass
*/
class StaticNoPingConnectionPool extends AbstractConnectionPool implements ConnectionPoolInterface
{
/**
* @var int
*/
private $pingTimeout = 60;
/**
* @var int
*/
private $maxPingTimeout = 3600;
/**
* @param ConnectionInterface[] $connections
* @param array<string, mixed> $connectionPoolParams
*/
public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams)
{
parent::__construct($connections, $selector, $factory, $connectionPoolParams);
}
public function nextConnection(bool $force = false): ConnectionInterface
{
$total = count($this->connections);
while ($total--) {
/**
* @var Connection $connection
*/
$connection = $this->selector->select($this->connections);
if ($connection->isAlive() === true) {
return $connection;
}
if ($this->readyToRevive($connection) === true) {
return $connection;
}
}
throw new NoNodesAvailableException("No alive nodes found in your cluster");
}
public function scheduleCheck(): void
{
}
private function readyToRevive(Connection $connection): bool
{
$timeout = min(
$this->pingTimeout * pow(2, $connection->getPingFailures()),
$this->maxPingTimeout
);
if ($connection->getLastPing() + $timeout < time()) {
return true;
} else {
return false;
}
}
}
@@ -0,0 +1,794 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Connections;
use Exception;
use GuzzleHttp\Ring\Core;
use GuzzleHttp\Ring\Exception\ConnectException;
use GuzzleHttp\Ring\Exception\RingException;
use OpenSearch\Client;
use OpenSearch\Common\Exceptions\BadRequest400Exception;
use OpenSearch\Common\Exceptions\Conflict409Exception;
use OpenSearch\Common\Exceptions\Curl\CouldNotConnectToHost;
use OpenSearch\Common\Exceptions\Curl\CouldNotResolveHostException;
use OpenSearch\Common\Exceptions\Curl\OperationTimeoutException;
use OpenSearch\Common\Exceptions\Forbidden403Exception;
use OpenSearch\Common\Exceptions\MaxRetriesException;
use OpenSearch\Common\Exceptions\Missing404Exception;
use OpenSearch\Common\Exceptions\NoDocumentsToGetException;
use OpenSearch\Common\Exceptions\NoShardAvailableException;
use OpenSearch\Common\Exceptions\OpenSearchException;
use OpenSearch\Common\Exceptions\RequestTimeout408Exception;
use OpenSearch\Common\Exceptions\RoutingMissingException;
use OpenSearch\Common\Exceptions\ScriptLangNotSupportedException;
use OpenSearch\Common\Exceptions\ServerErrorResponseException;
use OpenSearch\Common\Exceptions\TransportException;
use OpenSearch\Common\Exceptions\Unauthorized401Exception;
use OpenSearch\Serializers\SerializerInterface;
use OpenSearch\Transport;
use Psr\Log\LoggerInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(Connection::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class Connection implements ConnectionInterface
{
/**
* @var callable
*/
protected $handler;
/**
* @var SerializerInterface
*/
protected $serializer;
/**
* @var string
*/
protected $transportSchema = 'http'; // TODO depreciate this default
/**
* @var string
*/
protected $host;
/**
* @var string|null
*/
protected $path;
/**
* @var int
*/
protected $port;
/**
* @var LoggerInterface
*/
protected $log;
/**
* @var LoggerInterface
*/
protected $trace;
/**
* @var array
*/
protected $connectionParams;
/**
* @var array<string, list<string>>
*/
protected $headers = [];
/**
* @var bool
*/
protected $isAlive = false;
/**
* @var float
*/
private $pingTimeout = 1; //TODO expose this
/**
* @var int
*/
private $lastPing = 0;
/**
* @var int
*/
private $failedPings = 0;
/**
* @var mixed[]
*/
private $lastRequest = array();
/**
* @var string
*/
private $OSVersion = null;
/**
* @param array{host: string, port?: int, scheme?: string, user?: string, pass?: string, path?: string} $hostDetails
* @param array{client?: array{headers?: array<string, list<string>>, curl?: array<int, mixed>}} $connectionParams
*/
public function __construct(
callable $handler,
array $hostDetails,
array $connectionParams,
SerializerInterface $serializer,
LoggerInterface $log,
LoggerInterface $trace
) {
if (isset($hostDetails['port']) !== true) {
$hostDetails['port'] = 9200;
}
if (isset($hostDetails['scheme'])) {
$this->transportSchema = $hostDetails['scheme'];
}
// Only Set the Basic if API Key is not set and setBasicAuthentication was not called prior
if (isset($connectionParams['client']['headers']['Authorization']) === false
&& isset($connectionParams['client']['curl'][CURLOPT_HTTPAUTH]) === false
&& isset($hostDetails['user'])
&& isset($hostDetails['pass'])
) {
$connectionParams['client']['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
$connectionParams['client']['curl'][CURLOPT_USERPWD] = $hostDetails['user'].':'.$hostDetails['pass'];
}
$connectionParams['client']['curl'][CURLOPT_PORT] = $hostDetails['port'];
if (isset($connectionParams['client']['headers'])) {
$this->headers = $connectionParams['client']['headers'];
unset($connectionParams['client']['headers']);
}
// Add the User-Agent using the format: <client-repo-name>/<client-version> (metadata-values)
$this->headers['User-Agent'] = [sprintf(
'opensearch-php/%s (%s %s; PHP %s)',
Client::VERSION,
PHP_OS,
$this->getOSVersion(),
PHP_VERSION
)];
$host = $hostDetails['host'];
$path = null;
if (isset($hostDetails['path']) === true) {
$path = $hostDetails['path'];
}
$port = $hostDetails['port'];
$this->host = $host;
$this->path = $path;
$this->port = $port;
$this->log = $log;
$this->trace = $trace;
$this->connectionParams = $connectionParams;
$this->serializer = $serializer;
$this->handler = $this->wrapHandler($handler);
}
/**
* @param string $method
* @param string $uri
* @param null|array<string, mixed> $params
* @param mixed $body
* @param array $options
* @param Transport|null $transport
* @return mixed
*/
public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], ?Transport $transport = null)
{
if ($body !== null) {
$body = $this->serializer->serialize($body);
}
$headers = $this->headers;
if (isset($options['client']['headers']) && is_array($options['client']['headers'])) {
$headers = array_merge($this->headers, $options['client']['headers']);
}
$host = $this->host;
if (isset($this->connectionParams['client']['port_in_header']) && $this->connectionParams['client']['port_in_header']) {
$host .= ':' . $this->port;
}
$request = [
'http_method' => $method,
'scheme' => $this->transportSchema,
'uri' => $this->getURI($uri, $params),
'body' => $body,
'headers' => array_merge(
[
'Host' => [$host]
],
$headers
)
];
$request = array_replace_recursive($request, $this->connectionParams, $options);
// RingPHP does not like if client is empty
if (empty($request['client'])) {
unset($request['client']);
}
$handler = $this->handler;
$future = $handler($request, $this, $transport, $options);
return $future;
}
public function getTransportSchema(): string
{
return $this->transportSchema;
}
public function getLastRequestInfo(): array
{
return $this->lastRequest;
}
private function wrapHandler(callable $handler): callable
{
return function (array $request, Connection $connection, ?Transport $transport, $options) use ($handler) {
$this->lastRequest = [];
$this->lastRequest['request'] = $request;
// Send the request using the wrapped handler.
$response = Core::proxy(
$handler($request),
function ($response) use ($connection, $transport, $request, $options) {
$this->lastRequest['response'] = $response;
if (isset($response['error']) === true) {
if ($response['error'] instanceof ConnectException || $response['error'] instanceof RingException) {
$this->log->warning("Curl exception encountered.");
$exception = $this->getCurlRetryException($request, $response);
$this->logRequestFail($request, $response, $exception);
$node = $connection->getHost();
$this->log->warning("Marking node $node dead.");
$connection->markDead();
// If the transport has not been set, we are inside a Ping or Sniff,
// so we don't want to retrigger retries anyway.
//
// TODO this could be handled better, but we are limited because connectionpools do not
// have access to Transport. Architecturally, all of this needs to be refactored
if (isset($transport) === true) {
$transport->connectionPool->scheduleCheck();
$neverRetry = isset($request['client']['never_retry']) ? $request['client']['never_retry'] : false;
$shouldRetry = $transport->shouldRetry($request);
$shouldRetryText = ($shouldRetry) ? 'true' : 'false';
$this->log->warning("Retries left? $shouldRetryText");
if ($shouldRetry && !$neverRetry) {
return $transport->performRequest(
$request['http_method'],
$request['uri'],
[],
$request['body'],
$options
);
}
}
$this->log->warning("Out of retries, throwing exception from $node");
// Only throw if we run out of retries
throw $exception;
} else {
// Something went seriously wrong, bail
$exception = new TransportException($response['error']->getMessage());
$this->logRequestFail($request, $response, $exception);
throw $exception;
}
} else {
$connection->markAlive();
if (isset($response['headers']['Warning'])) {
$this->logWarning($request, $response);
}
if (isset($response['body']) === true) {
$response['body'] = stream_get_contents($response['body']);
$this->lastRequest['response']['body'] = $response['body'];
}
if ($response['status'] >= 400 && $response['status'] < 500) {
$ignore = $request['client']['ignore'] ?? [];
// Skip 404 if succeeded true in the body (e.g. clear_scroll)
$body = $response['body'] ?? '';
if (strpos($body, '"succeeded":true') !== false) {
$ignore[] = 404;
}
$this->process4xxError($request, $response, $ignore);
} elseif ($response['status'] >= 500) {
$ignore = $request['client']['ignore'] ?? [];
$this->process5xxError($request, $response, $ignore);
}
// No error, deserialize
$response['body'] = $this->serializer->deserialize($response['body'], $response['transfer_stats']);
}
$this->logRequestSuccess($request, $response);
return isset($request['client']['verbose']) && $request['client']['verbose'] === true ? $response : $response['body'];
}
);
return $response;
};
}
/**
* @param array<string, string|int|bool>|null $params
*/
private function getURI(string $uri, ?array $params): string
{
if (isset($params) === true && !empty($params)) {
$params = array_map(
function ($value) {
if ($value === true) {
return 'true';
} elseif ($value === false) {
return 'false';
}
return $value;
},
$params
);
$uri .= '?' . http_build_query($params);
}
if ($this->path !== null) {
$uri = $this->path . $uri;
}
return $uri;
}
/**
* @return array<string, list<string>>
*/
public function getHeaders(): array
{
return $this->headers;
}
public function logWarning(array $request, array $response): void
{
$this->log->warning('Deprecation', $response['headers']['Warning']);
}
/**
* Log a successful request
*
* @param array $request
* @param array $response
* @return void
*/
public function logRequestSuccess(array $request, array $response): void
{
$port = $request['client']['curl'][CURLOPT_PORT] ?? $response['transfer_stats']['primary_port'] ?? '';
$uri = $this->addPortInUrl($response['effective_url'], (int) $port);
$this->log->debug('Request Body', array($request['body']));
$this->log->info(
'Request Success:',
array(
'method' => $request['http_method'],
'uri' => $uri,
'port' => $port,
'headers' => $request['headers'],
'HTTP code' => $response['status'],
'duration' => $response['transfer_stats']['total_time'],
)
);
$this->log->debug('Response', array($response['body']));
// Build the curl command for Trace.
$curlCommand = $this->buildCurlCommand($request['http_method'], $uri, $request['body']);
$this->trace->info($curlCommand);
$this->trace->debug(
'Response:',
array(
'response' => $response['body'],
'method' => $request['http_method'],
'uri' => $uri,
'port' => $port,
'HTTP code' => $response['status'],
'duration' => $response['transfer_stats']['total_time'],
)
);
}
/**
* Log a failed request
*
* @param array $request
* @param array $response
* @param \Throwable $exception
*
* @return void
*/
public function logRequestFail(array $request, array $response, \Throwable $exception): void
{
$port = $request['client']['curl'][CURLOPT_PORT] ?? $response['transfer_stats']['primary_port'] ?? '';
$uri = $this->addPortInUrl($response['effective_url'], (int) $port);
$this->log->debug('Request Body', array($request['body']));
$this->log->warning(
'Request Failure:',
array(
'method' => $request['http_method'],
'uri' => $uri,
'port' => $port,
'headers' => $request['headers'],
'HTTP code' => $response['status'],
'duration' => $response['transfer_stats']['total_time'],
'error' => $exception->getMessage(),
)
);
$this->log->warning('Response', array($response['body']));
// Build the curl command for Trace.
$curlCommand = $this->buildCurlCommand($request['http_method'], $uri, $request['body']);
$this->trace->info($curlCommand);
$this->trace->debug(
'Response:',
array(
'response' => $response,
'method' => $request['http_method'],
'uri' => $uri,
'port' => $port,
'HTTP code' => $response['status'],
'duration' => $response['transfer_stats']['total_time'],
)
);
}
public function ping(): bool
{
$options = [
'client' => [
'timeout' => $this->pingTimeout,
'never_retry' => true,
'verbose' => true
]
];
try {
$response = $this->performRequest('HEAD', '/', null, null, $options);
$response = $response->wait();
} catch (TransportException $exception) {
$this->markDead();
return false;
}
if ($response['status'] === 200) {
$this->markAlive();
return true;
} else {
$this->markDead();
return false;
}
}
/**
* @return array|\GuzzleHttp\Ring\Future\FutureArray
*/
public function sniff()
{
$options = [
'client' => [
'timeout' => $this->pingTimeout,
'never_retry' => true
]
];
return $this->performRequest('GET', '/_nodes/', null, null, $options);
}
public function isAlive(): bool
{
return $this->isAlive;
}
public function markAlive(): void
{
$this->failedPings = 0;
$this->isAlive = true;
$this->lastPing = time();
}
public function markDead(): void
{
$this->isAlive = false;
$this->failedPings += 1;
$this->lastPing = time();
}
public function getLastPing(): int
{
return $this->lastPing;
}
public function getPingFailures(): int
{
return $this->failedPings;
}
public function getHost(): string
{
return $this->host;
}
public function getUserPass(): ?string
{
return $this->connectionParams['client']['curl'][CURLOPT_USERPWD] ?? null;
}
public function getPath(): ?string
{
return $this->path;
}
/**
* @return int
*/
public function getPort()
{
return $this->port;
}
protected function getCurlRetryException(array $request, array $response): OpenSearchException
{
$exception = null;
$message = $response['error']->getMessage();
$exception = new MaxRetriesException($message);
switch ($response['curl']['errno']) {
case 6:
$exception = new CouldNotResolveHostException($message, 0, $exception);
break;
case 7:
$exception = new CouldNotConnectToHost($message, 0, $exception);
break;
case 28:
$exception = new OperationTimeoutException($message, 0, $exception);
break;
}
return $exception;
}
/**
* Get the OS version using php_uname if available
* otherwise it returns an empty string
*
* @see https://github.com/elastic/elasticsearch-php/issues/922
*/
private function getOSVersion(): string
{
if ($this->OSVersion === null) {
$this->OSVersion = strpos(strtolower(ini_get('disable_functions')), 'php_uname') !== false
? ''
: php_uname("r");
}
return $this->OSVersion;
}
/**
* Add the port value in the URL if not present
*/
private function addPortInUrl(string $uri, int $port): string
{
if (strpos($uri, ':', 7) !== false) {
return $uri;
}
return preg_replace('#([^/])/([^/])#', sprintf("$1:%s/$2", $port), $uri, 1);
}
/**
* Construct a string cURL command
*/
private function buildCurlCommand(string $method, string $url, ?string $body): string
{
if (strpos($url, '?') === false) {
$url .= '?pretty=true';
} else {
str_replace('?', '?pretty=true', $url);
}
$curlCommand = 'curl -X' . strtoupper($method);
$curlCommand .= " '" . $url . "'";
if (isset($body) === true && $body !== '') {
$curlCommand .= " -d '" . $body . "'";
}
return $curlCommand;
}
/**
* @throws OpenSearchException
*/
private function process4xxError(array $request, array $response, array $ignore): void
{
$statusCode = $response['status'];
/**
* @var \Exception $exception
*/
$exception = $this->tryDeserialize400Error($response);
if (array_search($response['status'], $ignore) !== false) {
return;
}
$responseBody = $this->convertBodyToString($response['body'], $statusCode, $exception);
if ($statusCode === 401) {
$exception = new Unauthorized401Exception($responseBody);
} elseif ($statusCode === 403) {
$exception = new Forbidden403Exception($responseBody);
} elseif ($statusCode === 404) {
$exception = new Missing404Exception($responseBody);
} elseif ($statusCode === 409) {
$exception = new Conflict409Exception($responseBody, $statusCode);
} elseif ($statusCode === 400 && strpos($responseBody, 'script_lang not supported') !== false) {
$exception = new ScriptLangNotSupportedException($responseBody);
} elseif ($statusCode === 408) {
$exception = new RequestTimeout408Exception($responseBody);
} else {
$exception = new BadRequest400Exception($responseBody);
}
$this->logRequestFail($request, $response, $exception);
throw $exception;
}
/**
* @throws OpenSearchException
*/
private function process5xxError(array $request, array $response, array $ignore): void
{
$statusCode = (int) $response['status'];
$responseBody = $response['body'];
/**
* @var \Exception $exception
*/
$exception = $this->tryDeserialize500Error($response);
$exceptionText = "[$statusCode Server Exception] ".$exception->getMessage();
$this->log->error($exceptionText);
$this->log->error($exception->getTraceAsString());
if (array_search($statusCode, $ignore) !== false) {
return;
}
if ($statusCode === 500 && strpos($responseBody, "RoutingMissingException") !== false) {
$exception = new RoutingMissingException($exception->getMessage(), [], 0, $exception);
} elseif ($statusCode === 500 && preg_match('/ActionRequestValidationException.+ no documents to get/', $responseBody) === 1) {
$exception = new NoDocumentsToGetException($exception->getMessage(), [], 0, $exception);
} elseif ($statusCode === 500 && strpos($responseBody, 'NoShardAvailableActionException') !== false) {
$exception = new NoShardAvailableException($exception->getMessage(), [], 0, $exception);
} else {
$exception = new ServerErrorResponseException(
$this->convertBodyToString($responseBody, $statusCode, $exception),
);
}
$this->logRequestFail($request, $response, $exception);
throw $exception;
}
private function convertBodyToString($body, int $statusCode, Exception $exception): string
{
if (empty($body)) {
return sprintf(
"Unknown %d error from OpenSearch %s",
$statusCode,
$exception->getMessage()
);
}
// if body is not string, we convert it so it can be used as Exception message
if (!is_string($body)) {
return json_encode($body);
}
return $body;
}
private function tryDeserialize400Error(array $response): OpenSearchException
{
return $this->tryDeserializeError($response, BadRequest400Exception::class);
}
private function tryDeserialize500Error(array $response): OpenSearchException
{
return $this->tryDeserializeError($response, ServerErrorResponseException::class);
}
private function tryDeserializeError(array $response, string $errorClass): OpenSearchException
{
$error = $this->serializer->deserialize($response['body'], $response['transfer_stats']);
if (is_array($error) === true) {
if (isset($error['error']) === false) {
// <2.0 "i just blew up" nonstructured exception
// $error is an array but we don't know the format, reuse the response body instead
// added json_encode to convert into a string
return new $errorClass(json_encode($response['body']), (int) $response['status']);
}
// 2.0 structured exceptions
if (is_array($error['error']) && array_key_exists('reason', $error['error']) === true) {
// Try to use root cause first (only grabs the first root cause)
$info = $error['error']['root_cause'][0] ?? $error['error'];
$cause = $info['reason'];
$type = $info['type'];
// added json_encode to convert into a string
$original = new $errorClass(json_encode($response['body']), $response['status']);
return new $errorClass("$type: $cause", (int) $response['status'], $original);
}
// <2.0 semi-structured exceptions
// added json_encode to convert into a string
$original = new $errorClass(json_encode($response['body']), $response['status']);
$errorEncoded = $error['error'];
if (is_array($errorEncoded)) {
$errorEncoded = json_encode($errorEncoded);
}
return new $errorClass($errorEncoded, (int) $response['status'], $original);
}
// if responseBody is not string, we convert it so it can be used as Exception message
$responseBody = $response['body'];
if (!is_string($responseBody)) {
$responseBody = json_encode($responseBody);
}
// <2.0 "i just blew up" nonstructured exception
return new $errorClass($responseBody);
}
}
@@ -0,0 +1,87 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Connections;
use OpenSearch\Serializers\SerializerInterface;
use Psr\Log\LoggerInterface;
// @phpstan-ignore classConstant.deprecatedClass
@trigger_error(ConnectionFactory::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
class ConnectionFactory implements ConnectionFactoryInterface
{
/**
* @var array
*/
private $connectionParams;
/**
* @var SerializerInterface
*/
private $serializer;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var LoggerInterface
*/
private $tracer;
/**
* @var callable
*/
private $handler;
/**
* @param array{client?: array{headers?: array<string, list<string>>, curl?: array<int, mixed>}} $connectionParams
*/
public function __construct(callable $handler, array $connectionParams, SerializerInterface $serializer, LoggerInterface $logger, LoggerInterface $tracer)
{
$this->handler = $handler;
$this->connectionParams = $connectionParams;
$this->logger = $logger;
$this->tracer = $tracer;
$this->serializer = $serializer;
}
public function create(array $hostDetails): ConnectionInterface
{
if (isset($hostDetails['path'])) {
$hostDetails['path'] = rtrim($hostDetails['path'], '/');
}
return new Connection(
$this->handler,
$hostDetails,
$this->connectionParams,
$this->serializer,
$this->logger,
$this->tracer
);
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Connections;
// @phpstan-ignore classConstant.deprecatedInterface
@trigger_error(ConnectionFactoryInterface::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
interface ConnectionFactoryInterface
{
/**
* @param array{host: string, port?: int, scheme?: string, user?: string, pass?: string, path?: string} $hostDetails
*/
public function create(array $hostDetails): ConnectionInterface;
}
@@ -0,0 +1,87 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Connections;
use OpenSearch\Transport;
// @phpstan-ignore classConstant.deprecatedInterface
@trigger_error(ConnectionInterface::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
/**
* @deprecated in 2.4.0 and will be removed in 3.0.0.
*/
interface ConnectionInterface
{
/**
* Get the transport schema for this connection
*/
public function getTransportSchema(): string;
/**
* Get the hostname for this connection
*/
public function getHost(): string;
/**
* Get the port for this connection
*
* @return int
*/
public function getPort();
/**
* Get the username:password string for this connection, null if not set
*/
public function getUserPass(): ?string;
/**
* Get the URL path suffix, null if not set
*/
public function getPath(): ?string;
/**
* Check to see if this instance is marked as 'alive'
*/
public function isAlive(): bool;
/**
* Mark this instance as 'alive'
*/
public function markAlive(): void;
/**
* Mark this instance as 'dead'
*/
public function markDead(): void;
/**
* Return an associative array of information about the last request
*/
public function getLastRequestInfo(): array;
/**
* @param array<string, mixed>|null $params
* @param mixed $body
* @return mixed
*/
public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], ?Transport $transport = null);
}
@@ -0,0 +1,57 @@
<?php
namespace OpenSearch;
use OpenSearch\Endpoints\AbstractEndpoint;
use OpenSearch\Serializers\SerializerInterface;
use OpenSearch\Serializers\SmartSerializer;
use ReflectionClass;
/**
* A factory for creating endpoints.
*/
class EndpointFactory implements EndpointFactoryInterface
{
private ?SerializerInterface $serializer;
public function __construct(?SerializerInterface $serializer = null)
{
$this->serializer = $serializer;
}
/**
* {@inheritdoc}
*/
public function getEndpoint(string $class): AbstractEndpoint
{
return $this->createEndpoint($class);
}
private function getSerializer(): SerializerInterface
{
if ($this->serializer === null) {
$this->serializer = new SmartSerializer();
}
return $this->serializer;
}
/**
* Creates an endpoint.
*
* @phpstan-template T of AbstractEndpoint
* @phpstan-param class-string<T> $class
* @phpstan-return T
* @throws \ReflectionException
*/
private function createEndpoint(string $class): AbstractEndpoint
{
$reflection = new ReflectionClass($class);
$constructor = $reflection->getConstructor();
if ($constructor && $constructor->getParameters()) {
return new $class($this->getSerializer());
}
return new $class();
}
}
@@ -0,0 +1,21 @@
<?php
namespace OpenSearch;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* A factory for creating endpoints.
*/
interface EndpointFactoryInterface
{
/**
* Gets an endpoint.
*
* @phpstan-template T of AbstractEndpoint
* @phpstan-param class-string<T> $class
* @phpstan-return T
*/
public function getEndpoint(string $class): AbstractEndpoint;
}
@@ -0,0 +1,79 @@
<?php
namespace OpenSearch;
/**
* Provides and interface for endpoints.
*/
interface EndpointInterface
{
/**
* Get the whitelist of allowed parameters.
*
* @return string[]
*/
public function getParamWhitelist(): array;
/**
* Get the URI.
*/
public function getURI(): string;
/**
* Get the HTTP method.
*/
public function getMethod(): string;
/**
* Set the query string parameters.
*/
public function setParams(array $params): static;
/**
* Get the query string parameters.
*/
public function getParams(): array;
/**
* Get the options.
*
* @return array<string, mixed>
*/
public function getOptions(): array;
/**
* Get the index.
*/
public function getIndex(): ?string;
/**
* Set the index.
*
* @param string|string[]|null $index
*
* @return $this
*/
public function setIndex(string|array|null $index): static;
/**
* Get the document ID.
*
* @param int|string|null $docID
*
* @return $this
*/
public function setId(int|string|null $docID): static;
/**
* Get the body of the request.
*/
public function getBody(): string|array|null;
/**
* Set the body of the request.
*
* @param string|iterable<string,mixed>|null $body
*/
public function setBody(string|iterable|null $body): static;
}
@@ -0,0 +1,319 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints;
use OpenSearch\EndpointInterface;
use OpenSearch\Exception\UnexpectedValueException;
use OpenSearch\Serializers\SerializerInterface;
use function array_filter;
abstract class AbstractEndpoint implements EndpointInterface
{
/**
* @var array
*/
protected $params = [];
/**
* @var string|null
*/
protected $index = null;
/**
* @var string|int|null
*/
protected $id = null;
/**
* @var string|null
*/
protected $method = null;
/**
* @var string|array|null
*/
protected $body = null;
/**
* @var array
*/
private $options = [];
/**
* @var SerializerInterface
*/
protected $serializer;
/**
* @return string[]
*/
abstract public function getParamWhitelist(): array;
/**
* @return string
*/
abstract public function getURI(): string;
/**
* @return string
*/
abstract public function getMethod(): string;
/**
* Set the parameters for this endpoint
*
* @param mixed[] $params Array of parameters
* @return $this
*/
public function setParams(array $params): static
{
$this->extractOptions($params);
$this->checkUserParams($params);
$params = $this->convertCustom($params);
$this->params = $this->convertArraysToStrings($params);
$this->checkForDeprecations();
return $this;
}
public function getParams(): array
{
return $this->params;
}
public function getOptions(): array
{
return $this->options;
}
public function getIndex(): ?string
{
return $this->index;
}
/**
* @param string|string[]|null $index
*
* @return $this
*/
public function setIndex($index): static
{
if ($index === null) {
return $this;
}
if (is_array($index) === true) {
$index = array_filter($index);
$index = array_map('trim', $index);
$index = implode(",", $index);
}
$this->index = $index;
return $this;
}
public function setId(int|string|null $docID): static
{
if ($docID === null) {
return $this;
}
if (is_int($docID)) {
$docID = (string)$docID;
}
$this->id = $docID;
return $this;
}
public function getBody(): string|array|null
{
return $this->body;
}
public function setBody(string|iterable|null $body): static
{
$this->body = $body;
return $this;
}
protected function getOptionalURI(string $endpoint): string
{
$uri = [];
$uri[] = $this->getOptionalIndex();
$uri[] = $endpoint;
$uri = array_filter($uri);
return '/' . implode('/', $uri);
}
private function getOptionalIndex(): string
{
if (isset($this->index) === true) {
return $this->index;
} else {
return '_all';
}
}
/**
* @param array<string, mixed> $params
*
* @throws UnexpectedValueException
*/
private function checkUserParams(array $params)
{
if (empty($params)) {
return; //no params, just return.
}
$whitelist = array_merge(
$this->getParamWhitelist(),
['pretty', 'human', 'error_trace', 'source', 'filter_path', 'opaqueId']
);
$invalid = array_diff(array_keys($params), $whitelist);
if (count($invalid) > 0) {
sort($invalid);
sort($whitelist);
throw new UnexpectedValueException(
sprintf(
(count($invalid) > 1 ? '"%s" are not valid parameters.' : '"%s" is not a valid parameter.') . ' Allowed parameters are "%s"',
implode('", "', $invalid),
implode('", "', $whitelist)
)
);
}
}
/**
* @param array<string, mixed> $params Note: this is passed by-reference!
*/
private function extractOptions(&$params)
{
// Extract out client options, then start transforming
if (isset($params['client']) === true) {
// Check if the opaqueId is populated and add the header
if (isset($params['client']['opaqueId']) === true) {
if (isset($params['client']['headers']) === false) {
$params['client']['headers'] = [];
}
$params['client']['headers']['x-opaque-id'] = [trim($params['client']['opaqueId'])];
unset($params['client']['opaqueId']);
}
$this->options['client'] = $params['client'];
unset($params['client']);
}
$ignore = isset($this->options['client']['ignore']) ? $this->options['client']['ignore'] : null;
if (isset($ignore) === true) {
if (is_string($ignore)) {
$this->options['client']['ignore'] = explode(",", $ignore);
} elseif (is_array($ignore)) {
$this->options['client']['ignore'] = $ignore;
} else {
$this->options['client']['ignore'] = [$ignore];
}
}
}
/**
* @param array<string, mixed> $params
*
* @return array<string, mixed>
*/
private function convertCustom(array $params): array
{
if (isset($params['custom']) === true) {
foreach ($params['custom'] as $k => $v) {
$params[$k] = $v;
}
unset($params['custom']);
}
return $params;
}
private function convertArraysToStrings(array $params): array
{
foreach ($params as $key => &$value) {
if (!($key === 'client' || $key == 'custom') && is_array($value) === true) {
if ($this->isNestedArray($value) !== true) {
$value = implode(",", $value);
}
}
}
return $params;
}
private function isNestedArray(array $a): bool
{
foreach ($a as $v) {
if (is_array($v)) {
return true;
}
}
return false;
}
/**
* This function returns all param deprecations also optional with a replacement field
*
* @return array<string, string|null>
*/
protected function getParamDeprecation(): array
{
return [];
}
private function checkForDeprecations(): void
{
$deprecations = $this->getParamDeprecation();
if ($deprecations === []) {
return;
}
$keys = array_keys($this->params);
foreach ($keys as $key) {
if (array_key_exists($key, $deprecations)) {
$val = $deprecations[$key];
$msg = sprintf('The parameter "%s" is deprecated and will be removed without replacement in the next major version', $key);
if ($val) {
$msg = sprintf('The parameter "%s" is deprecated and will be replaced with parameter "%s" in the next major version', $key, $val);
}
trigger_error($msg, E_USER_DEPRECATED);
}
}
}
}
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\AsyncSearch;
use OpenSearch\Exception\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;
class Delete extends AbstractEndpoint
{
public function getURI(): string
{
$id = $this->id ?? null;
if (isset($id)) {
return "/_async_search/$id";
}
throw new RuntimeException('Missing parameter for the endpoint async_search.delete');
}
public function getParamWhitelist(): array
{
return [];
}
public function getMethod(): string
{
return 'DELETE';
}
}
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\AsyncSearch;
use OpenSearch\Exception\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;
class Get extends AbstractEndpoint
{
public function getURI(): string
{
$id = $this->id ?? null;
if (isset($id)) {
return "/_async_search/$id";
}
throw new RuntimeException('Missing parameter for the endpoint async_search.get');
}
public function getParamWhitelist(): array
{
return [
'wait_for_completion_timeout',
'keep_alive',
'typed_keys'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,99 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\AsyncSearch;
use OpenSearch\Endpoints\AbstractEndpoint;
class Submit extends AbstractEndpoint
{
public function getURI(): string
{
$index = $this->index ?? null;
if (isset($index)) {
return "/$index/_async_search";
}
return "/_async_search";
}
public function getParamWhitelist(): array
{
return [
'wait_for_completion_timeout',
'keep_on_completion',
'keep_alive',
'batched_reduce_size',
'request_cache',
'analyzer',
'analyze_wildcard',
'default_operator',
'df',
'explain',
'stored_fields',
'docvalue_fields',
'from',
'ignore_unavailable',
'ignore_throttled',
'allow_no_indices',
'expand_wildcards',
'lenient',
'preference',
'q',
'routing',
'search_type',
'size',
'sort',
'_source',
'_source_excludes',
'_source_includes',
'terminate_after',
'stats',
'suggest_field',
'suggest_mode',
'suggest_size',
'suggest_text',
'timeout',
'track_scores',
'track_total_hits',
'allow_partial_search_results',
'typed_keys',
'version',
'seq_no_primary_term',
'max_concurrent_shard_requests'
];
}
public function getMethod(): string
{
return 'POST';
}
public function setBody($body): static
{
if (isset($body) !== true) {
return $this;
}
$this->body = $body;
return $this;
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\AsynchronousSearch;
use OpenSearch\Exception\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Delete extends AbstractEndpoint
{
public function getURI(): string
{
if (!isset($this->id) || $this->id === '') {
throw new RuntimeException('id is required for delete');
}
$id = rawurlencode($this->id);
return "/_plugins/_asynchronous_search/$id";
}
public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'DELETE';
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\AsynchronousSearch;
use OpenSearch\Exception\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Get extends AbstractEndpoint
{
public function getURI(): string
{
if (!isset($this->id) || $this->id === '') {
throw new RuntimeException('id is required for get');
}
$id = rawurlencode($this->id);
return "/_plugins/_asynchronous_search/$id";
}
public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\AsynchronousSearch;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Search extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_asynchronous_search";
}
public function getParamWhitelist(): array
{
return [
'index',
'keep_alive',
'keep_on_completion',
'wait_for_completion_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'POST';
}
public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;
return $this;
}
}
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\AsynchronousSearch;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Stats extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_asynchronous_search/stats";
}
public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints;
use OpenSearch\Serializers\SerializerInterface;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Bulk extends AbstractEndpoint
{
public function __construct(SerializerInterface $serializer)
{
$this->serializer = $serializer;
}
public function getURI(): string
{
$index = $this->index ? rawurlencode($this->index) : null;
if (isset($index)) {
return "/$index/_bulk";
}
return "/_bulk";
}
public function getParamWhitelist(): array
{
return [
'_source',
'_source_excludes',
'_source_includes',
'index',
'pipeline',
'refresh',
'require_alias',
'routing',
'timeout',
'wait_for_active_shards',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'POST';
}
public function setBody(string|iterable|null $body): static
{
if (is_null($body)) {
return $this;
}
if (is_string($body)) {
if (!str_ends_with($body, "\n")) {
$body .= "\n";
}
$this->body = $body;
return $this;
}
// Must be an iterable.
foreach ($body as $item) {
$this->body .= $this->serializer->serialize($item) . "\n";
}
return $this;
}
}
@@ -0,0 +1,88 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints;
use OpenSearch\Serializers\SerializerInterface;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class BulkStream extends AbstractEndpoint
{
public function __construct(SerializerInterface $serializer)
{
$this->serializer = $serializer;
}
public function getURI(): string
{
$index = $this->index ? rawurlencode($this->index) : null;
if (isset($index)) {
return "/$index/_bulk/stream";
}
return "/_bulk/stream";
}
public function getParamWhitelist(): array
{
return [
'_source',
'_source_excludes',
'_source_includes',
'batch_interval',
'batch_size',
'pipeline',
'refresh',
'require_alias',
'routing',
'timeout',
'wait_for_active_shards',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'PUT';
}
public function setBody(string|iterable|null $body): static
{
if (is_null($body)) {
return $this;
}
if (is_string($body)) {
if (!str_ends_with($body, "\n")) {
$body .= "\n";
}
$this->body = $body;
return $this;
}
// Must be an iterable.
foreach ($body as $item) {
$this->body .= $this->serializer->serialize($item) . "\n";
}
return $this;
}
}
@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Aliases extends AbstractEndpoint
{
protected $name;
public function getURI(): string
{
$name = $this->name ? rawurlencode($this->name) : null;
if (isset($name)) {
return "/_cat/aliases/$name";
}
return "/_cat/aliases";
}
public function getParamWhitelist(): array
{
return [
'expand_wildcards',
'format',
'h',
'help',
'local',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
public function setName($name): static
{
if (!isset($name)) {
return $this;
}
if (is_array($name) === true) {
$name = implode(",", $name);
}
$this->name = rawurlencode($name);
return $this;
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class AllPitSegments extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/pit_segments/_all";
}
public function getParamWhitelist(): array
{
return [
'bytes',
'format',
'h',
'help',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Allocation extends AbstractEndpoint
{
protected $node_id;
public function getURI(): string
{
$node_id = $this->node_id ? rawurlencode($this->node_id) : null;
if (isset($node_id)) {
return "/_cat/allocation/$node_id";
}
return "/_cat/allocation";
}
public function getParamWhitelist(): array
{
return [
'bytes',
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
public function setNodeId($node_id): static
{
if (!isset($node_id)) {
return $this;
}
if (is_array($node_id) === true) {
$node_id = implode(",", $node_id);
}
$this->node_id = rawurlencode($node_id);
return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class ClusterManager extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/cluster_manager";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Count extends AbstractEndpoint
{
public function getURI(): string
{
$index = $this->index ? rawurlencode($this->index) : null;
if (isset($index)) {
return "/_cat/count/$index";
}
return "/_cat/count";
}
public function getParamWhitelist(): array
{
return [
'format',
'h',
'help',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Fielddata extends AbstractEndpoint
{
protected $fields;
public function getURI(): string
{
$fields = $this->fields ? rawurlencode($this->fields) : null;
if (isset($fields)) {
return "/_cat/fielddata/$fields";
}
return "/_cat/fielddata";
}
public function getParamWhitelist(): array
{
return [
'bytes',
'fields',
'format',
'h',
'help',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
public function setFields($fields): static
{
if (!isset($fields)) {
return $this;
}
if (is_array($fields) === true) {
$fields = implode(",", $fields);
}
$this->fields = rawurlencode($fields);
return $this;
}
}
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Health extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/health";
}
public function getParamWhitelist(): array
{
return [
'format',
'h',
'help',
's',
'time',
'ts',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Help extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat";
}
public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Indices extends AbstractEndpoint
{
public function getURI(): string
{
$index = $this->index ? rawurlencode($this->index) : null;
if (isset($index)) {
return "/_cat/indices/$index";
}
return "/_cat/indices";
}
public function getParamWhitelist(): array
{
return [
'bytes',
'cluster_manager_timeout',
'expand_wildcards',
'format',
'h',
'health',
'help',
'include_unloaded_segments',
'local',
'master_timeout',
'pri',
's',
'time',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
/**
* @deprecated To promote inclusive language, use '/_cat/cluster_manager' instead.
*/
class Master extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/master";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class NodeAttrs extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/nodeattrs";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Nodes extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/nodes";
}
public function getParamWhitelist(): array
{
return [
'bytes',
'cluster_manager_timeout',
'format',
'full_id',
'h',
'help',
'local',
'master_timeout',
's',
'time',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class PendingTasks extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/pending_tasks";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'time',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class PitSegments extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/pit_segments";
}
public function getParamWhitelist(): array
{
return [
'bytes',
'format',
'h',
'help',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;
return $this;
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Plugins extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/plugins";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Recovery extends AbstractEndpoint
{
public function getURI(): string
{
$index = $this->index ? rawurlencode($this->index) : null;
if (isset($index)) {
return "/_cat/recovery/$index";
}
return "/_cat/recovery";
}
public function getParamWhitelist(): array
{
return [
'active_only',
'bytes',
'detailed',
'format',
'h',
'help',
'index',
's',
'time',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Repositories extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/repositories";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class SegmentReplication extends AbstractEndpoint
{
public function getURI(): string
{
$index = $this->index ? rawurlencode($this->index) : null;
if (isset($index)) {
return "/_cat/segment_replication/$index";
}
return "/_cat/segment_replication";
}
public function getParamWhitelist(): array
{
return [
'active_only',
'allow_no_indices',
'bytes',
'completed_only',
'detailed',
'expand_wildcards',
'format',
'h',
'help',
'ignore_throttled',
'ignore_unavailable',
'index',
's',
'shards',
'time',
'timeout',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Segments extends AbstractEndpoint
{
public function getURI(): string
{
$index = $this->index ? rawurlencode($this->index) : null;
if (isset($index)) {
return "/_cat/segments/$index";
}
return "/_cat/segments";
}
public function getParamWhitelist(): array
{
return [
'bytes',
'cluster_manager_timeout',
'format',
'h',
'help',
'master_timeout',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Shards extends AbstractEndpoint
{
public function getURI(): string
{
$index = $this->index ? rawurlencode($this->index) : null;
if (isset($index)) {
return "/_cat/shards/$index";
}
return "/_cat/shards";
}
public function getParamWhitelist(): array
{
return [
'bytes',
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'time',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Snapshots extends AbstractEndpoint
{
protected $repository;
public function getURI(): string
{
$repository = $this->repository ? rawurlencode($this->repository) : null;
if (isset($repository)) {
return "/_cat/snapshots/$repository";
}
return "/_cat/snapshots";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'ignore_unavailable',
'master_timeout',
'repository',
's',
'time',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
public function setRepository($repository): static
{
if (!isset($repository)) {
return $this;
}
if (is_array($repository) === true) {
$repository = implode(",", $repository);
}
$this->repository = rawurlencode($repository);
return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Tasks extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/tasks";
}
public function getParamWhitelist(): array
{
return [
'actions',
'detailed',
'format',
'h',
'help',
's',
'time',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path',
'node_id',
'parent_task'
];
}
public function getMethod(): string
{
return 'GET';
}
}
@@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Templates extends AbstractEndpoint
{
protected $name;
public function getURI(): string
{
$name = $this->name ? rawurlencode($this->name) : null;
if (isset($name)) {
return "/_cat/templates/$name";
}
return "/_cat/templates";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
public function setName($name): static
{
if (is_null($name)) {
return $this;
}
$this->name = $name;
return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cat;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class ThreadPool extends AbstractEndpoint
{
protected $thread_pool_patterns;
public function getURI(): string
{
$thread_pool_patterns = $this->thread_pool_patterns ? rawurlencode($this->thread_pool_patterns) : null;
if (isset($thread_pool_patterns)) {
return "/_cat/thread_pool/$thread_pool_patterns";
}
return "/_cat/thread_pool";
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'format',
'h',
'help',
'local',
'master_timeout',
's',
'size',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'GET';
}
public function setThreadPoolPatterns($thread_pool_patterns): static
{
if (!isset($thread_pool_patterns)) {
return $this;
}
if (is_array($thread_pool_patterns) === true) {
$thread_pool_patterns = implode(",", $thread_pool_patterns);
}
$this->thread_pool_patterns = rawurlencode($thread_pool_patterns);
return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,82 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class ClearScroll extends AbstractEndpoint
{
protected $scroll_id;
public function getURI(): string
{
$scroll_id = $this->scroll_id ? rawurlencode($this->scroll_id) : null;
if (isset($scroll_id)) {
@trigger_error('A scroll id can be quite large and should be specified as part of the body', E_USER_DEPRECATED);
}
if (isset($scroll_id)) {
return "/_search/scroll/$scroll_id";
}
return "/_search/scroll";
}
public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'DELETE';
}
public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;
return $this;
}
public function setScrollId($scroll_id): static
{
if (!isset($scroll_id)) {
return $this;
}
if (is_array($scroll_id) === true) {
$scroll_id = implode(",", $scroll_id);
}
$this->scroll_id = rawurlencode($scroll_id);
return $this;
}
}
@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cluster;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class AllocationExplain extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cluster/allocation/explain";
}
public function getParamWhitelist(): array
{
return [
'include_disk_info',
'include_yes_decisions',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return isset($this->body) ? 'POST' : 'GET';
}
public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;
return $this;
}
}
@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cluster;
use OpenSearch\Exception\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class DeleteComponentTemplate extends AbstractEndpoint
{
protected $name;
public function getURI(): string
{
$name = $this->name ? rawurlencode($this->name) : null;
if (isset($name)) {
return "/_component_template/$name";
}
throw new RuntimeException('Missing parameter for the endpoint cluster.delete_component_template');
}
public function getParamWhitelist(): array
{
return [
'cluster_manager_timeout',
'master_timeout',
'timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'DELETE';
}
public function setName($name): static
{
if (is_null($name)) {
return $this;
}
$this->name = $name;
return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\Cluster;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class DeleteDecommissionAwareness extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cluster/decommission/awareness";
}
public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'DELETE';
}
}
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* OpenSearch PHP client
*
* @link https://github.com/opensearch-project/opensearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/
namespace OpenSearch\Endpoints\Cluster;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class DeleteVotingConfigExclusions extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cluster/voting_config_exclusions";
}
public function getParamWhitelist(): array
{
return [
'wait_for_removal',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'DELETE';
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
namespace OpenSearch\Endpoints\Cluster;
use OpenSearch\Endpoints\AbstractEndpoint;
/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class DeleteWeightedRouting extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cluster/routing/awareness/weights";
}
public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}
public function getMethod(): string
{
return 'DELETE';
}
public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;
return $this;
}
}

Some files were not shown because too many files have changed in this diff Show More