diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 51cc95da1..6185445c7 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,16 +5,16 @@ steps: env: PHP_VERSION: "{{ matrix.php }}" TEST_SUITE: "{{ matrix.suite }}" - STACK_VERSION: 8.9-SNAPSHOT + STACK_VERSION: 8.12-SNAPSHOT matrix: setup: suite: - "free" - "platinum" php: + - "8.3-cli" - "8.2-cli" - "8.1-cli" - "8.0-cli" - - "7.4-cli" command: ./.buildkite/run-tests artifact_paths: "*.xml" diff --git a/.ci/Dockerfile b/.ci/Dockerfile deleted file mode 100644 index d392dc310..000000000 --- a/.ci/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -ARG PHP_VERSION=8.0-cli -FROM php:${PHP_VERSION} - -WORKDIR /usr/src/app - -# Install git -RUN apt-get update -qq > /dev/null && \ - apt-get install -y --no-install-recommends git -qq > /dev/null - -# Install zip extension for PHP -RUN apt-get install -y \ - libzip-dev \ - zip \ - libyaml-dev \ - -qq > /dev/null \ - && docker-php-ext-install zip > /dev/null - -# Install yaml extension for PHP -RUN pecl channel-update pecl.php.net > /dev/null -RUN pecl install yaml > /dev/null -RUN docker-php-ext-enable yaml > /dev/null - -# Print ext YAML version -RUN php -i | grep -E "yaml|YAML|Module Version" - -# Print PHP version -RUN php -v - -# Install composer -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - -# Print composer version -RUN composer --version - -COPY composer.json . - -# Install dependencies with composer -RUN composer install --no-progress > /dev/null - -COPY . . - -CMD ["bash", ".ci/yaml-tests.sh"] \ No newline at end of file diff --git a/.ci/certs/ca.crt b/.ci/certs/ca.crt deleted file mode 100755 index 71f9bfc81..000000000 --- a/.ci/certs/ca.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSjCCAjKgAwIBAgIVAJQLm8V2LcaCTHUcoIfO+KL63nG3MA0GCSqGSIb3DQEB -CwUAMDQxMjAwBgNVBAMTKUVsYXN0aWMgQ2VydGlmaWNhdGUgVG9vbCBBdXRvZ2Vu -ZXJhdGVkIENBMB4XDTIwMDIyNjA1NTA1N1oXDTIzMDIyNTA1NTA1N1owNDEyMDAG -A1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5lcmF0ZWQgQ0Ew -ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDYyajkPvGtUOE5M1OowQfB -kWVrWjo1+LIxzgCeRHp0YztLtdVJ0sk2xoSrt2uZpxcPepdyOseLTjFJex1D2yCR -AEniIqcFif4G72nDih2LlbhpUe/+/MTryj8ZTkFTzI+eMmbQi5FFMaH+kwufmdt/ -5/w8YazO18SxxJUlzMqzfNUrhM8vvvVdxgboU7PWhk28wZHCMHQovomHmzclhRpF -N0FMktA98vHHeRjH19P7rNhifSd7hZzoH3H148HVAKoPgqnZ6vW2O2YfAWOP6ulq -cyszr57p8fS9B2wSdlWW7nVHU1JuKcYD67CxbBS23BeGFgCj4tiNrmxO8S5Yf85v -AgMBAAGjUzBRMB0GA1UdDgQWBBSWAlip9eoPmnG4p4OFZeOUBlAbNDAfBgNVHSME -GDAWgBSWAlip9eoPmnG4p4OFZeOUBlAbNDAPBgNVHRMBAf8EBTADAQH/MA0GCSqG -SIb3DQEBCwUAA4IBAQA19qqrMTWl7YyId+LR/QIHDrP4jfxmrEELrAL58q5Epc1k -XxZLzOBSXoBfBrPdv+3XklWqXrZjKWfdkux0Xmjnl4qul+srrZDLJVZG3I7IrITh -AmQUmL9MuPiMnAcxoGZp1xpijtW8Qmd2qnambbljWfkuVaa4hcVRfrAX6TciIQ21 -bS5aeLGrPqR14h30YzDp0RMmTujEa1o6ExN0+RSTkE9m89Q6WdM69az8JW7YkWqm -I+UCG3TcLd3TXmN1zNQkq4y2ObDK4Sxy/2p6yFPI1Fds5w/zLfBOvvPQY61vEqs8 -SCCcQIe7f6NDpIRIBlty1C9IaEHj7edyHjF6rtYb ------END CERTIFICATE----- diff --git a/.ci/certs/ca.key b/.ci/certs/ca.key deleted file mode 100644 index dfc41b558..000000000 --- a/.ci/certs/ca.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpgIBAAKCAQEA2Mmo5D7xrVDhOTNTqMEHwZFla1o6NfiyMc4AnkR6dGM7S7XV -SdLJNsaEq7drmacXD3qXcjrHi04xSXsdQ9sgkQBJ4iKnBYn+Bu9pw4odi5W4aVHv -/vzE68o/GU5BU8yPnjJm0IuRRTGh/pMLn5nbf+f8PGGsztfEscSVJczKs3zVK4TP -L771XcYG6FOz1oZNvMGRwjB0KL6Jh5s3JYUaRTdBTJLQPfLxx3kYx9fT+6zYYn0n -e4Wc6B9x9ePB1QCqD4Kp2er1tjtmHwFjj+rpanMrM6+e6fH0vQdsEnZVlu51R1NS -binGA+uwsWwUttwXhhYAo+LYja5sTvEuWH/ObwIDAQABAoIBAQC8QDGnMnmPdWJ+ -13FYY3cmwel+FXXjFDk5QpgK15A2rUz6a8XxO1d7d1wR+U84uH4v9Na6XQyWjaoD -EyPQnuJiyAtgkZLUHoY244PGR5NsePEQlBSCKmGeF5w/j1LvP/2e9EmP4wKdQYJY -nLxFNcgEBCFnFbKIU5n8fKa/klybCrwlBokenyBro02tqH4LL7h1YMRRrl97fv1V -e/y/0WcMN+KnMglfz6haimBRV2yamCCHHmBImC+wzOgT/quqlxPfI+a3ScHxuA65 -3QyCavaqlPh+T3lXnN/Na4UWqFtzMmwgJX2x1zM5qiln46/JoDiXtagvV43L3rNs -LhPRFeIRAoGBAPhEB7nNpEDNjIRUL6WpebWS9brKAVY7gYn7YQrKGhhCyftyaiBZ -zYgxPaJdqYXf+DmkWlANGoYiwEs40QwkR/FZrvO4+Xh3n3dgtl59ZmieuoQvDsG+ -RYIj+TfBaqhewhZNMMl7dxz7DeyQhyRCdsvl3VqJM0RuOsIrzrhCIEItAoGBAN+K -lgWI7swDpOEaLmu+IWMkGImh1LswXoZqIgi/ywZ7htZjPzidOIeUsMi+lrYsKojG -uU3sBxASsf9kYXDnuUuUbGT5M/N2ipXERt7klUAA/f5sg1IKlTrabaN/HGs/uNtf -Efa8v/h2VyTurdPCJ17TNpbOMDwX1qGM62tyt2CLAoGBAIHCnP8iWq18QeuQTO8b -a3/Z9hHRL22w4H4MI6aOB6GSlxuTq6CJD4IVqo9IwSg17fnCy2l3z9s4IqWuZqUf -+XJOW8ELd2jdrT2qEOfGR1Z7UCVyqxXcq1vgDYx0zZh/HpalddB5dcJx/c8do2Ty -UEE2PcHqYB9uNcvzNbLc7RtpAoGBALbuU0yePUTI6qGnajuTcQEPpeDjhRHWSFRZ -ABcG1N8uMS66Mx9iUcNp462zgeP8iqY5caUZtMHreqxT+gWKK7F0+as7386pwElF -QPXgO18QMMqHBIQb0vlBjJ1SRPBjSiSDTVEML1DljvTTOX7kEJHh6HdKrmBO5b54 -cqMQUo53AoGBAPVWRPUXCqlBz914xKna0ZUh2aesRBg5BvOoq9ey9c52EIU5PXL5 -0Isk8sWSsvhl3tjDPBH5WuL5piKgnCTqkVbEHmWu9s1T57Mw6NuxlPMLBWvyv4c6 -tB9brOxv0ui3qGMuBsBoDKbkNnwXyOXLyFg7O+H4l016A3mLQzJM+NGV ------END RSA PRIVATE KEY----- diff --git a/.ci/certs/testnode.crt b/.ci/certs/testnode.crt deleted file mode 100755 index a49dfd775..000000000 --- a/.ci/certs/testnode.crt +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDIzCCAgugAwIBAgIVAMTO6uVx9dLox2t0lY4IcBKZXb5WMA0GCSqGSIb3DQEB -CwUAMDQxMjAwBgNVBAMTKUVsYXN0aWMgQ2VydGlmaWNhdGUgVG9vbCBBdXRvZ2Vu -ZXJhdGVkIENBMB4XDTIwMDIyNjA1NTA1OVoXDTIzMDIyNTA1NTA1OVowEzERMA8G -A1UEAxMIaW5zdGFuY2UwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDK -YLTOikVENiN/qYupOsoXd7VYYnryyfCC/dK4FC2aozkbqjFzBdvPGAasoc4yEiH5 -CGeXMgJuOjk1maqetmdIsw00j4oHJviYsnGXzxxS5swhD7spcW4Uk4V4tAUzrbfT -vW/2WW/yYCLe5phVb2chz0jL+WYb4bBmdfs/t6RtP9RqsplYAmVp3gZ6lt2YNtvE -k9gz0TVk3DuO1TquIClfRYUjuywS6xDSvxJ8Jl91EfDWM8QU+9F+YAtiv74xl2U3 -P0wwMqNvMxf9/3ak3lTQGsgO4L6cwbKpVLMMzxSVunZz/sgl19xy3qHHz1Qr2MjJ -/2c2J7vahUL4NPRkjJClAgMBAAGjTTBLMB0GA1UdDgQWBBS2Wn8E2VZv4oenY+pR -O8G3zfQXhzAfBgNVHSMEGDAWgBSWAlip9eoPmnG4p4OFZeOUBlAbNDAJBgNVHRME -AjAAMA0GCSqGSIb3DQEBCwUAA4IBAQAvwPvCiJJ6v9jYcyvYY8I3gP0oCwrylpRL -n91UlgRSHUmuAObyOoVN5518gSV/bTU2SDrstcLkLFxHvnfpoGJoxsQEHuGxwDRI -nhYNd62EKLerehNM/F9ILKmvTh8f6QPCzjUuExTXv+63l2Sr6dBS7FHsGs6UKUYO -llM/y9wMZ1LCuZuBg9RhtgpFXRSgDM9Z7Begu0d/BPX9od/qAeZg9Arz4rwUiCN4 -IJOMEBEPi5q1tgeS0Fb1Grpqd0Uz5tZKtEHNKzLG+zSMmkneL62Nk2HsmEFZKwzg -u2pU42UaUE596G6o78s1aLn9ICcElPHTjiuZNSiyuu9IzvFDjGQw ------END CERTIFICATE----- diff --git a/.ci/certs/testnode.key b/.ci/certs/testnode.key deleted file mode 100755 index 82efeecb9..000000000 --- a/.ci/certs/testnode.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEAymC0zopFRDYjf6mLqTrKF3e1WGJ68snwgv3SuBQtmqM5G6ox -cwXbzxgGrKHOMhIh+QhnlzICbjo5NZmqnrZnSLMNNI+KByb4mLJxl88cUubMIQ+7 -KXFuFJOFeLQFM623071v9llv8mAi3uaYVW9nIc9Iy/lmG+GwZnX7P7ekbT/UarKZ -WAJlad4GepbdmDbbxJPYM9E1ZNw7jtU6riApX0WFI7ssEusQ0r8SfCZfdRHw1jPE -FPvRfmALYr++MZdlNz9MMDKjbzMX/f92pN5U0BrIDuC+nMGyqVSzDM8Ulbp2c/7I -Jdfcct6hx89UK9jIyf9nNie72oVC+DT0ZIyQpQIDAQABAoIBADAh7f7NjgnaInlD -ds8KB3SraPsbeQhzlPtiqRJU4j/MIFH/GYG03AGWQkget67a9y+GmzSvlTpoKKEh -6h2TXl9BDpv4o6ht0WRn1HJ5tM/Wyqf2WNpTew3zxCPgFPikkXsPrChYPzLTQJfp -GkP/mfTFmxfAOlPZSp4j41zVLYs53eDkAegFPVfKSr1XNNJ3QODLPcIBfxBYsiC9 -oU+jRW8xYuj31cEl5k5UqrChJ1rm3mt6cguqXKbISuoSvi13gXI6DccqhuLAU+Kr -ib2XYrRP+pWocZo/pM9WUVoNGtFxfY88sAQtvG6gDKo2AURtFyq84Ow0h9mdixV/ -gRIDPcECgYEA5nEqE3OKuG9WuUFGXvjtn4C0F6JjflYWh7AbX51S4F6LKrW6/XHL -Rg4BtF+XReT7OQ6llsV8kZeUxsUckkgDLzSaA8lysNDV5KkhAWHfRqH//QKFbqZi -JL9t3x63Qt81US8s2hQk3khPYTRM8ZB3xHiXvZYSGC/0x/DxfEO3QJECgYEA4NK5 -sxtrat8sFz6SK9nWEKimPjDVzxJ0hxdX4tRq/JdOO5RncawVqt6TNP9gTuxfBvhW -MhJYEsQj8iUoL1dxo9d1eP8HEANNV0iX5OBvJNmgBp+2OyRSyr+PA55+wAxYuAE7 -QKaitOjW57fpArNRt2hQyiSzTuqUFRWTWJHCWNUCgYAEurPTXF6vdFGCUc2g61jt -GhYYGhQSpq+lrz6Qksj9o9MVWE9zHh++21C7o+6V16I0RJGva3QoBMVf4vG4KtQt -5tV2WG8LI+4P2Ey+G4UajP6U8bVNVQrUmD0oBBhcvfn5JY+1Fg6/pRpD82/U0VMz -7AmpMWhDqNBMPiymkTk0kQKBgCuWb05cSI0ly4SOKwS5bRk5uVFhYnKNH255hh6C -FGP4acB/WzbcqC7CjEPAJ0nl5d6SExQOHmk1AcsWjR3wlCWxxiK5PwNJwJrlhh1n -reS1FKN0H36D4lFQpkeLWQOe4Sx7gKNeKzlr0w6Fx3Uwku0+Gju2tdTdAey8jB6l -08opAoGAEe1AuR/OFp2xw6V8TH9UHkkpGxy+OrXI6PX6tgk29PgB+uiMu4RwbjVz -1di1KKq2XecAilVbnyqY+edADxYGbSnci9x5wQRIebfMi3VXKtV8NQBv2as6qwtW -JDcQUWotOHjpdvmfJWWkcBhbAKrgX8ukww00ZI/lC3/rmkGnBBg= ------END RSA PRIVATE KEY----- diff --git a/.ci/certs/testnode_san.crt b/.ci/certs/testnode_san.crt deleted file mode 100644 index 8abba55b5..000000000 --- a/.ci/certs/testnode_san.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDVjCCAj6gAwIBAgIULh42yRefYlRRl1hvt055LrUH0HwwDQYJKoZIhvcNAQEL -BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l -cmF0ZWQgQ0EwHhcNMjAwMjI4MDMzNzIwWhcNMjMwMjI3MDMzNzIwWjATMREwDwYD -VQQDEwhpbnN0YW5jZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIUP -t267NN21z+3ukajej8eojSXwP6zHxy7CUAp+sQ7bTq2XCKxkYX3CW9ThcS4cV9mL -ayYdWEYnbEDGYPQDo7Wk3Ih5OEXTMZb/yNEx5D4S2lGMOS5bCDdYx6GvwCMG4jNx -aMktosaxpprAJiHh2oLgQk0hQc/a9JfMo6kJKtuhjxsxjxLwcOHhuaUD7NS0Pjop -CJkSYcrL+nnQPQjKe4uLhAbSyiX914h4QX0CJ0e4z1ccdDX2PFWTrwaIf//vQhCR -wP2YKdfjR0JB4oDAlu85GsIs2cFLPysM5ufuNZO4fCr8uOwloKI8zZ2HhlIfBEcY -Gcy4g9N/9epmxMXZlGcCAwEAAaOBgDB+MB0GA1UdDgQWBBRefYm8DHHDdkTPHhS1 -HEUwTb2uiDAfBgNVHSMEGDAWgBSWAlip9eoPmnG4p4OFZeOUBlAbNDAxBgNVHREE -KjAogglsb2NhbGhvc3SHBH8AAAGHEAAAAAAAAAAAAAAAAAAAAAGCA2VzMTAJBgNV -HRMEAjAAMA0GCSqGSIb3DQEBCwUAA4IBAQC+pauqM2wJjQaHyHu+kIm59P4b/5Oj -IH1cYCQfMB7Y2UMLxp0ew+f7o7zzE2DA52YYFDWy6J5DVWtSBPyeFGgX+RH+aA+9 -Iv4cc9QpAs6aFjncorHrzNOrWLgCHIeRAxTR0CAkeP2dUZfDBuMpRyP6rAsYzyLH -Rb3/BfYJSI5vxgt5Ke49Y/ljDKFJTyDmAVrHQ4JWrseYE1UZ2eDkBXeiRlYE/QtB -YsrUSqdL6zvFZyUcilxDUUabNcA+GgeGZ2lAEA90F8vwi62QwRXo3Iv1Hz+6xc43 -nFofDK9D8/qkrUD9iuhpx1974QwPhwWyjn9RZRpbZA4ngRL+szdRXR4N ------END CERTIFICATE----- diff --git a/.ci/certs/testnode_san.key b/.ci/certs/testnode_san.key deleted file mode 100644 index 75d19539e..000000000 --- a/.ci/certs/testnode_san.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEAhQ+3brs03bXP7e6RqN6Px6iNJfA/rMfHLsJQCn6xDttOrZcI -rGRhfcJb1OFxLhxX2YtrJh1YRidsQMZg9AOjtaTciHk4RdMxlv/I0THkPhLaUYw5 -LlsIN1jHoa/AIwbiM3FoyS2ixrGmmsAmIeHaguBCTSFBz9r0l8yjqQkq26GPGzGP -EvBw4eG5pQPs1LQ+OikImRJhysv6edA9CMp7i4uEBtLKJf3XiHhBfQInR7jPVxx0 -NfY8VZOvBoh//+9CEJHA/Zgp1+NHQkHigMCW7zkawizZwUs/Kwzm5+41k7h8Kvy4 -7CWgojzNnYeGUh8ERxgZzLiD03/16mbExdmUZwIDAQABAoIBAEwhjulLMVc9JEfV -PP/qv0cUOBYh3LzF3T/yq4slq7Z9YgnOJYdFM8aZgqNNjc09KEJvE5JOLeiNu9Ff -768Nugg+2HM5MCo7SN9FYCfZLOcbMFCCM2FDcnMAV9A512vzD08xryuT8dNPZ6yZ -DfhK2hQRrb2lrpr3gwSrcGRRu3THqvq7X1RIjpLV3teDMeP8rQPAlpj8fmP+kdVV -5y1ihiDIo87McihG9FMavJtBDXQkUEuVw6eIeir8L/zHHD/ZwhYjNHZGWbrB88sz -CkJkfWh/FlA63tCVdJzkmnERALLTVy9mR0Sq6sUlnFhFNO2BRdWgYLrcp9McfTJC -e8+WsSECgYEAuwQ3nAaFL0jqYu1AREyKT/f3WUenf2UsX7dwwV2/yFtQvkzW7ji4 -uZLnfUnZBojtHf35dRo+hDgtvhZhgZNAuPPsbOl/EIMTcbChEqV/3CSTFlhLFM1d -hfM9PoM+Bt/pyUNabjD1sWM0X7WeUhzcddshY3S4daBsNsLuOzweRRcCgYEAtiSS -4qiiGafYsY7gOHuAlOhs/00+1uWIFEHKgoHM9vzCxDN3LCmBdynHk8ZE2TAdhw+l -7xpu6LUxKQDfGmVZa9Epg0kQmVq9c54oQP57pJ3tR+68++insEkfnaZH8jblfq2s -sSkFrY3pdS19edq60nuft64kswKRUUkamCXTXTECgYBdoSfiMpV9bekC7DsPtq5M -iR3KEgi2zEViCmomNTRuL+GF1NyKWdWJ+xVwcYd5MRZdvKimyyPfeGzWTUg14i42 -KtEEWgZmkukqMz8BIeCYq6sENeIpIQQgqv3PjU+Bi5r1S4Y7wsFPNRakkD4aaB6r -1rCppWcwZMeoxwEUoO2aswKBgBdDIIdWJi3EpAY5SyWrkEZ0UMdiZC4p7nE33ddB -IJ5CtdU9BXFcc652ZYjX/58FaCABvZ2F8LhDu92SwOusGfmNIxIjWL1dO2jywA1c -8wmZKd7P/M7nbdMz45fMzs9+d1zwbWfK53C8+R4AC1BuwQF0zHc3BHTgVRLelUjt -O8thAoGAdO2gHIqEsZzTgbvLbsh52eVbumjfNGnrnEv1fjb+o+/wAol8dymcmzbL -bZCRzoyA0qwU9kdPFgX46H6so6o1tUM2GQtVFoT6kDnPv7EkLQK0C4cDh6OOHxDU -NPvr/9fHhQd9EDWDvS1JnVMAdKDO6ELp3SoKGGmCXR2QplnqWAk= ------END RSA PRIVATE KEY----- diff --git a/.ci/docker/Dockerfile b/.ci/docker/Dockerfile deleted file mode 100644 index 138fb1cb6..000000000 --- a/.ci/docker/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -ARG PHP_VERSION=8.0-cli -FROM php:${PHP_VERSION} - -# Create app directory -WORKDIR /usr/src/app diff --git a/.ci/functions/cleanup.sh b/.ci/functions/cleanup.sh deleted file mode 100644 index 4c25166fb..000000000 --- a/.ci/functions/cleanup.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash -# -# Shared cleanup routines between different steps -# -# Please source .ci/functions/imports.sh as a whole not just this file -# -# Version 1.0.0 -# - Initial version after refactor - -function cleanup_volume { - if [[ "$(docker volume ls -q -f name=$1)" ]]; then - echo -e "\033[34;1mINFO:\033[0m Removing volume $1\033[0m" - (docker volume rm "$1") || true - fi -} -function container_running { - if [[ "$(docker ps -q -f name=$1)" ]]; then - return 0; - else return 1; - fi -} -function cleanup_node { - if container_running "$1"; then - echo -e "\033[34;1mINFO:\033[0m Removing container $1\033[0m" - (docker container rm --force --volumes "$1") || true - fi - if [[ -n "$1" ]]; then - echo -e "\033[34;1mINFO:\033[0m Removing volume $1-${suffix}-data\033[0m" - cleanup_volume "$1-${suffix}-data" - fi -} -function cleanup_network { - if [[ "$(docker network ls -q -f name=$1)" ]]; then - echo -e "\033[34;1mINFO:\033[0m Removing network $1\033[0m" - (docker network rm "$1") || true - fi -} - -function cleanup_trap { - status=$? - set +x - if [[ "$DETACH" != "true" ]]; then - echo -e "\033[34;1mINFO:\033[0m clean the network if not detached (start and exit)\033[0m" - cleanup_all_in_network "$1" - fi - # status is 0 or SIGINT - if [[ "$status" == "0" || "$status" == "130" ]]; then - echo -e "\n\033[32;1mSUCCESS run-tests\033[0m" - exit 0 - else - echo -e "\n\033[31;1mFAILURE during run-tests\033[0m" - exit ${status} - fi -}; -function cleanup_all_in_network { - - if [[ -z "$(docker network ls -q -f name="^$1\$")" ]]; then - echo -e "\033[34;1mINFO:\033[0m $1 is already deleted\033[0m" - return 0 - fi - containers=$(docker network inspect -f '{{ range $key, $value := .Containers }}{{ printf "%s\n" .Name}}{{ end }}' $1) - while read -r container; do - cleanup_node "$container" - done <<< "$containers" - cleanup_network $1 - echo -e "\033[32;1mSUCCESS:\033[0m Cleaned up and exiting\033[0m" -}; diff --git a/.ci/functions/imports.sh b/.ci/functions/imports.sh deleted file mode 100644 index c05f36826..000000000 --- a/.ci/functions/imports.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash -# -# Sets up all the common variables and imports relevant functions -# -# Version 1.0.1 -# - Initial version after refactor -# - Validate STACK_VERSION asap - -function require_stack_version() { - if [[ -z $STACK_VERSION ]]; then - echo -e "\033[31;1mERROR:\033[0m Required environment variable [STACK_VERSION] not set\033[0m" - exit 1 - fi -} - -require_stack_version - -if [[ -z $es_node_name ]]; then - # only set these once - set -euo pipefail - export TEST_SUITE=${TEST_SUITE-free} - export RUNSCRIPTS=${RUNSCRIPTS-} - export DETACH=${DETACH-false} - export CLEANUP=${CLEANUP-false} - - export es_node_name=instance - export elastic_password=changeme - export elasticsearch_image=elasticsearch - export elasticsearch_scheme="https" - if [[ $TEST_SUITE != "platinum" ]]; then - export elasticsearch_scheme="http" - fi - export elasticsearch_url=${elasticsearch_scheme}://elastic:${elastic_password}@${es_node_name}:9200 - export external_elasticsearch_url=${elasticsearch_url/$es_node_name/localhost} - export elasticsearch_container="${elasticsearch_image}:${STACK_VERSION}" - - export suffix=rest-test - export moniker=$(echo "$elasticsearch_container" | tr -C "[:alnum:]" '-') - export network_name=${moniker}${suffix} - - export ssl_cert="${script_path}/certs/testnode.crt" - export ssl_key="${script_path}/certs/testnode.key" - export ssl_ca="${script_path}/certs/ca.crt" - -fi - - export script_path=$(dirname $(realpath -s $0)) - source $script_path/functions/cleanup.sh - source $script_path/functions/wait-for-container.sh - trap "cleanup_trap ${network_name}" EXIT - - -if [[ "$CLEANUP" == "true" ]]; then - cleanup_all_in_network $network_name - exit 0 -fi - -echo -e "\033[34;1mINFO:\033[0m Creating network $network_name if it does not exist already \033[0m" -docker network inspect "$network_name" > /dev/null 2>&1 || docker network create "$network_name" - diff --git a/.ci/functions/wait-for-container.sh b/.ci/functions/wait-for-container.sh deleted file mode 100644 index 1a721b588..000000000 --- a/.ci/functions/wait-for-container.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# Exposes a routine scripts can call to wait for a container if that container set up a health command -# -# Please source .ci/functions/imports.sh as a whole not just this file -# -# Version 1.0.1 -# - Initial version after refactor -# - Make sure wait_for_contiainer is silent - -function wait_for_container { - set +x - until ! container_running "$1" || (container_running "$1" && [[ "$(docker inspect -f "{{.State.Health.Status}}" ${1})" != "starting" ]]); do - echo "" - docker inspect -f "{{range .State.Health.Log}}{{.Output}}{{end}}" ${1} - echo -e "\033[34;1mINFO:\033[0m waiting for node $1 to be up\033[0m" - sleep 2; - done; - - # Always show logs if the container is running, this is very useful both on CI as well as while developing - if container_running $1; then - docker logs $1 - fi - - if ! container_running $1 || [[ "$(docker inspect -f "{{.State.Health.Status}}" ${1})" != "healthy" ]]; then - cleanup_all_in_network $2 - echo - echo -e "\033[31;1mERROR:\033[0m Failed to start $1 in detached mode beyond health checks\033[0m" - echo -e "\033[31;1mERROR:\033[0m dumped the docker log before shutting the node down\033[0m" - return 1 - else - echo - echo -e "\033[32;1mSUCCESS:\033[0m Detached and healthy: ${1} on docker network: ${network_name}\033[0m" - return 0 - fi -} diff --git a/.ci/jobs/defaults.yml b/.ci/jobs/defaults.yml deleted file mode 100644 index 194e3a081..000000000 --- a/.ci/jobs/defaults.yml +++ /dev/null @@ -1,74 +0,0 @@ - - -##### GLOBAL METADATA - -- meta: - cluster: clients-ci - -##### JOB DEFAULTS - -- job: - project-type: matrix - logrotate: - daysToKeep: 30 - numToKeep: 100 - properties: - - github: - url: https://github.com/elastic/elasticsearch-php/ - - inject: - properties-content: HOME=$JENKINS_HOME - concurrent: true - node: flyweight - scm: - - git: - name: origin - credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba - reference-repo: /var/lib/jenkins/.git-references/elasticsearch-php.git - branches: - - ${branch_specifier} - url: https://github.com/elastic/elasticsearch-php.git - wipe-workspace: 'True' - triggers: - - github - vault: - # vault read auth/approle/role/clients-ci/role-id - role_id: ddbd0d44-0e51-105b-177a-c8fdfd445126 - axes: - - axis: - type: slave - name: label - values: - - linux - - axis: - type: yaml - filename: .ci/test-matrix.yml - name: STACK_VERSION - - axis: - type: yaml - filename: .ci/test-matrix.yml - name: PHP_VERSION - - axis: - type: yaml - filename: .ci/test-matrix.yml - name: TEST_SUITE - yaml-strategy: - exclude-key: exclude - filename: .ci/test-matrix.yml - wrappers: - - ansicolor - - timeout: - type: absolute - timeout: 120 - fail: true - - timestamps - - workspace-cleanup - builders: - - shell: |- - #!/usr/local/bin/runbld - .ci/run-tests - publishers: - - email: - recipients: build-lang-clients@elastic.co - - junit: - results: "tests/*-junit.xml" - allow-empty-results: true diff --git a/.ci/jobs/elastic+elasticsearch-php+7.17.yml b/.ci/jobs/elastic+elasticsearch-php+7.17.yml deleted file mode 100644 index 59d08ce18..000000000 --- a/.ci/jobs/elastic+elasticsearch-php+7.17.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-php+7.17 - display-name: 'elastic / elasticsearch-php # 7.17' - description: Testing the elasticsearch-php 7.17 branch. - parameters: - - string: - name: branch_specifier - default: refs/heads/7.17 - description: the Git branch specifier to build (<branchName>, <tagName>, - <commitId>, etc.) - triggers: - - github - - timed: 'H */12 * * *' diff --git a/.ci/jobs/elastic+elasticsearch-php+8.8.yml b/.ci/jobs/elastic+elasticsearch-php+8.8.yml deleted file mode 100644 index a6e2c7e8f..000000000 --- a/.ci/jobs/elastic+elasticsearch-php+8.8.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-php+8.8 - display-name: 'elastic / elasticsearch-php # 8.8' - description: Testing the elasticsearch-php 8.8 branch. - parameters: - - string: - name: branch_specifier - default: refs/heads/8.8 - description: the Git branch specifier to build (<branchName>, <tagName>, - <commitId>, etc.) - triggers: - - github - - timed: 'H */12 * * *' \ No newline at end of file diff --git a/.ci/jobs/elastic+elasticsearch-php+8.9.yml b/.ci/jobs/elastic+elasticsearch-php+8.9.yml deleted file mode 100644 index f28bffc6b..000000000 --- a/.ci/jobs/elastic+elasticsearch-php+8.9.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-php+8.9 - display-name: 'elastic / elasticsearch-php # 8.9' - description: Testing the elasticsearch-php 8.9 branch. - parameters: - - string: - name: branch_specifier - default: refs/heads/8.9 - description: the Git branch specifier to build (<branchName>, <tagName>, - <commitId>, etc.) - triggers: - - github - - timed: 'H */12 * * *' diff --git a/.ci/jobs/elastic+elasticsearch-php+main.yml b/.ci/jobs/elastic+elasticsearch-php+main.yml deleted file mode 100644 index 67b4fb021..000000000 --- a/.ci/jobs/elastic+elasticsearch-php+main.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-php+main - display-name: 'elastic / elasticsearch-php # main' - description: Testing the elasticsearch-php main branch. - parameters: - - string: - name: branch_specifier - default: refs/heads/main - description: the Git branch specifier to build (<branchName>, <tagName>, - <commitId>, etc.) - triggers: - - github - - timed: 'H */12 * * *' diff --git a/.ci/jobs/elastic+elasticsearch-php+pull-request.yml b/.ci/jobs/elastic+elasticsearch-php+pull-request.yml deleted file mode 100644 index 1c1f9309c..000000000 --- a/.ci/jobs/elastic+elasticsearch-php+pull-request.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- job: - name: elastic+elasticsearch-php+pull-request - display-name: 'elastic / elasticsearch-php # pull-request' - description: Testing of elasticsearch-php pull requests. - junit_results: "tests/*-junit.xml" - scm: - - git: - branches: - - ${ghprbActualCommit} - refspec: +refs/pull/*:refs/remotes/origin/pr/* - triggers: - - github-pull-request: - org-list: - - elastic - allow-whitelist-orgs-as-admins: true - github-hooks: true - status-context: clients-ci - cancel-builds-on-update: true - publishers: [] diff --git a/.ci/packer_cache.sh b/.ci/packer_cache.sh deleted file mode 100644 index 12d751e0f..000000000 --- a/.ci/packer_cache.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -source /usr/local/bin/bash_standard_lib.sh - -DOCKER_IMAGES="php:8.2-cli -php:8.1-cli -php:8.0-cli -php:7.4-cli -" - -for di in ${DOCKER_IMAGES} -do -(retry 2 docker pull "${di}") || echo "Error pulling ${di} Docker image, we continue" -done - diff --git a/.ci/run-elasticsearch.sh b/.ci/run-elasticsearch.sh deleted file mode 100755 index cbace1912..000000000 --- a/.ci/run-elasticsearch.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env bash -# -# Launch one or more Elasticsearch nodes via the Docker image, -# to form a cluster suitable for running the REST API tests. -# -# Export the STACK_VERSION variable, eg. '8.0.0-SNAPSHOT'. -# Export the TEST_SUITE variable, eg. 'free' or 'platinum' defaults to 'free'. -# Export the NUMBER_OF_NODES variable to start more than 1 node - -# Version 1.6.1 -# - Initial version of the run-elasticsearch.sh script -# - Deleting the volume should not dependent on the container still running -# - Fixed `ES_JAVA_OPTS` config -# - Moved to STACK_VERSION and TEST_VERSION -# - Refactored into functions and imports -# - Support NUMBER_OF_NODES -# - Added 5 retries on docker pull for fixing transient network errors -# - Added flags to make local CCR configurations work -# - Added action.destructive_requires_name=false as the default will be true in v8 -# - Added ingest.geoip.downloader.enabled=false as it causes false positives in testing -# - Moved ELASTIC_PASSWORD and xpack.security.enabled to the base arguments for "Security On by default" -# - Use https only when TEST_SUITE is "platinum", when "free" use http -# - Set xpack.security.enabled=false for "free" and xpack.security.enabled=true for "platinum" - -script_path=$(dirname $(realpath -s $0)) -source $script_path/functions/imports.sh -set -euo pipefail - -echo -e "\033[34;1mINFO:\033[0m Take down node if called twice with the same arguments (DETACH=true) or on seperate terminals \033[0m" -cleanup_node $es_node_name - -master_node_name=${es_node_name} -cluster_name=${moniker}${suffix} - -declare -a volumes -environment=($(cat <<-END - --env ELASTIC_PASSWORD=$elastic_password - --env node.name=$es_node_name - --env cluster.name=$cluster_name - --env cluster.initial_master_nodes=$master_node_name - --env discovery.seed_hosts=$master_node_name - --env cluster.routing.allocation.disk.threshold_enabled=false - --env bootstrap.memory_lock=true - --env node.attr.testattr=test - --env path.repo=/tmp - --env repositories.url.allowed_urls=http://snapshot.test* - --env action.destructive_requires_name=false - --env ingest.geoip.downloader.enabled=false - --env cluster.deprecation_indexing.enabled=false -END -)) -if [[ "$TEST_SUITE" == "platinum" ]]; then - environment+=($(cat <<-END - --env xpack.security.enabled=true - --env xpack.license.self_generated.type=trial - --env xpack.security.http.ssl.enabled=true - --env xpack.security.http.ssl.verification_mode=certificate - --env xpack.security.http.ssl.key=certs/testnode.key - --env xpack.security.http.ssl.certificate=certs/testnode.crt - --env xpack.security.http.ssl.certificate_authorities=certs/ca.crt - --env xpack.security.transport.ssl.enabled=true - --env xpack.security.transport.ssl.verification_mode=certificate - --env xpack.security.transport.ssl.key=certs/testnode.key - --env xpack.security.transport.ssl.certificate=certs/testnode.crt - --env xpack.security.transport.ssl.certificate_authorities=certs/ca.crt -END -)) - volumes+=($(cat <<-END - --volume $ssl_cert:/usr/share/elasticsearch/config/certs/testnode.crt - --volume $ssl_key:/usr/share/elasticsearch/config/certs/testnode.key - --volume $ssl_ca:/usr/share/elasticsearch/config/certs/ca.crt -END -)) -else - environment+=($(cat <<-END - --env xpack.security.enabled=false - --env xpack.security.http.ssl.enabled=false -END -)) -fi - -cert_validation_flags="" -if [[ "$TEST_SUITE" == "platinum" ]]; then - cert_validation_flags="--insecure --cacert /usr/share/elasticsearch/config/certs/ca.crt --resolve ${es_node_name}:443:127.0.0.1" -fi - -# Pull the container, retry on failures up to 5 times with -# short delays between each attempt. Fixes most transient network errors. -docker_pull_attempts=0 -until [ "$docker_pull_attempts" -ge 5 ] -do - docker pull -q docker.elastic.co/elasticsearch/"$elasticsearch_container" && break - docker_pull_attempts=$((docker_pull_attempts+1)) - echo "Failed to pull image, retrying in 10 seconds (retry $docker_pull_attempts/5)..." - sleep 10 -done - -NUMBER_OF_NODES=${NUMBER_OF_NODES-1} -http_port=9200 -for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do - node_name=${es_node_name}$i - node_url=${external_elasticsearch_url/9200/${http_port}}$i - if [[ "$i" == "0" ]]; then node_name=$es_node_name; fi - environment+=($(cat <<-END - --env node.name=$node_name -END -)) - echo "$i: $http_port $node_url " - volume_name=${node_name}-${suffix}-data - volumes+=($(cat <<-END - --volume $volume_name:/usr/share/elasticsearch/data${i} -END -)) - - # make sure we detach for all but the last node if DETACH=false (default) so all nodes are started - local_detach="true" - if [[ "$i" == "$((NUMBER_OF_NODES-1))" ]]; then local_detach=$DETACH; fi - echo -e "\033[34;1mINFO:\033[0m Starting container $node_name \033[0m" - set -x - docker run \ - --name "$node_name" \ - --network "$network_name" \ - --env "ES_JAVA_OPTS=-Xms1g -Xmx1g -da:org.elasticsearch.xpack.ccr.index.engine.FollowingEngineAssertions" \ - "${environment[@]}" \ - "${volumes[@]}" \ - --publish "$http_port":9200 \ - --ulimit nofile=65536:65536 \ - --ulimit memlock=-1:-1 \ - --detach="$local_detach" \ - --health-cmd="curl $cert_validation_flags --fail $elasticsearch_url/_cluster/health || exit 1" \ - --health-interval=5s \ - --health-retries=20 \ - --health-timeout=2s \ - --rm \ - docker.elastic.co/elasticsearch/"$elasticsearch_container"; - - set +x - if wait_for_container "$es_node_name" "$network_name"; then - echo -e "\033[32;1mSUCCESS:\033[0m Running on: $node_url\033[0m" - fi - -done - diff --git a/.ci/run-repository.sh b/.ci/run-repository.sh deleted file mode 100644 index ae349f80f..000000000 --- a/.ci/run-repository.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash -# parameters are available to this script - -# STACK_VERSION -- version e.g Major.Minor.Patch(-Prelease) -# TEST_SUITE -- which test suite to run: oss or xpack -# ELASTICSEARCH_URL -- The url at which elasticsearch is reachable, a default is composed based on STACK_VERSION and TEST_SUITE -# PHP_VERSION -- PHP version (defined in test-matrix.yml, a default is hardcoded here) -script_path=$(dirname $(realpath -s $0)) -source $script_path/functions/imports.sh -set -euo pipefail - -PHP_VERSION=${PHP_VERSION-8.2-cli} -ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"} -elasticsearch_container=${elasticsearch_container-} - -echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m" -echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m" -echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m" -echo -e "\033[34;1mINFO:\033[0m CONTAINER ${elasticsearch_container}\033[0m" -echo -e "\033[34;1mINFO:\033[0m PHP_VERSION ${PHP_VERSION}\033[0m" - -echo -e "\033[1m>>>>> Build docker container >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" - -docker build \ - --no-cache \ - --file .ci/Dockerfile \ - --tag elastic/elasticsearch-php \ - --build-arg PHP_VERSION=${PHP_VERSION} \ - . - -echo -e "\033[1m>>>>> Run test:integration >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" - -repo=$(realpath $(dirname $(realpath -s $0))/../) - -docker run \ - --network=${network_name} \ - --workdir="/usr/src/app" \ - --volume=${repo}/tests:/usr/src/app/tests \ - --env STACK_VERSION=${STACK_VERSION} \ - --env TEST_SUITE=${TEST_SUITE} \ - --env PHP_VERSION=${PHP_VERSION} \ - --env ELASTICSEARCH_URL=${ELASTICSEARCH_URL} \ - --ulimit nofile=65535:65535 \ - --name elasticsearch-php \ - --rm \ - elastic/elasticsearch-php \ No newline at end of file diff --git a/.ci/run-tests b/.ci/run-tests deleted file mode 100755 index 5166c457b..000000000 --- a/.ci/run-tests +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# -# Version 1.1 -# - Moved to .ci folder and seperated out `run-repository.sh` -# - Add `$RUNSCRIPTS` env var for running Elasticsearch dependent products -script_path=$(dirname $(realpath -s $0)) -source $script_path/functions/imports.sh -set -euo pipefail - -echo -e "\033[1m>>>>> Start [$STACK_VERSION container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" -DETACH=true bash .ci/run-elasticsearch.sh - -if [[ -n "$RUNSCRIPTS" ]]; then - for RUNSCRIPT in ${RUNSCRIPTS//,/ } ; do - echo -e "\033[1m>>>>> Running run-$RUNSCRIPT.sh >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" - CONTAINER_NAME=${RUNSCRIPT} \ - DETACH=true \ - bash .ci/run-${RUNSCRIPT}.sh - done -fi - -echo -e "\033[1m>>>>> Repository specific tests >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" -bash .ci/run-repository.sh \ No newline at end of file diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml deleted file mode 100644 index 8a536a6f2..000000000 --- a/.ci/test-matrix.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -STACK_VERSION: - - 8.9-SNAPSHOT - -PHP_VERSION: - - 8.2-cli - - 8.1-cli - - 8.0-cli - - 7.4-cli - -TEST_SUITE: - - free - - platinum - -exclude: ~ diff --git a/.ci/yaml-tests.sh b/.ci/yaml-tests.sh deleted file mode 100755 index 0a83f93e2..000000000 --- a/.ci/yaml-tests.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# Checkout the YAML test from Elasticsearch tag -php util/RestSpecRunner.php - -# Generate the YAML tests for PHPUnit -php util/build_tests.php - -# Run YAML tests -vendor/bin/phpunit -c "phpunit-yaml-${TEST_SUITE}-tests.xml" \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index e59ed4a8a..101eff777 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,3 +10,5 @@ /phpunit-yaml-free-tests.xml export-ignore /phpunit-yaml-platinum-tests.xml export-ignore /phpunit.xml.dist export-ignore +#/docs export-ignore +/.buildkite export-ignore diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 000000000..ae057cebb --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1,2 @@ +tmp/ +output/ \ No newline at end of file diff --git a/.ci/make.sh b/.github/make.sh old mode 100755 new mode 100644 similarity index 87% rename from .ci/make.sh rename to .github/make.sh index 7c5dd1513..f4608e247 --- a/.ci/make.sh +++ b/.github/make.sh @@ -5,9 +5,9 @@ # Skeleton for common build entry script for all elastic # clients. Needs to be adapted to individual client usage. # -# Must be called: ./.ci/make.sh +# Must be called: ./.github/make.sh # -# Version: 1.1.0 +# Version: 1.1.1 # # Targets: # --------------------------- @@ -37,8 +37,8 @@ WORKFLOW=${WORKFLOW-staging} set -euo pipefail product="elastic/elasticsearch-php" -output_folder=".ci/output" -codegen_folder=".ci/output" +output_folder=".github/output" +codegen_folder=".github/output" OUTPUT_DIR="$repo/${output_folder}" REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}" mkdir -p "$OUTPUT_DIR" @@ -115,7 +115,7 @@ esac #echo -e "\033[34;1mINFO: building $product container\033[0m" -#docker build --file .ci/Dockerfile --tag ${product} \ +#docker build --file .github/Dockerfile --tag ${product} \ # --build-arg USER_ID="$(id -u)" \ # --build-arg GROUP_ID="$(id -g)" . @@ -140,15 +140,15 @@ esac if [[ "$CMD" == "assemble" ]]; then echo -e "\033[34;1mINFO: copy artefacts\033[0m" - rsync -ar --exclude=.ci --exclude=.git --filter=':- .gitignore' "$PWD" "${output_folder}/." + rsync -ar --exclude=.github --exclude=.git --filter=':- .gitignore' "$PWD" "${output_folder}/." - if compgen -G ".ci/output/*" > /dev/null; then + if compgen -G ".github/output/*" > /dev/null; then if [[ "$WORKFLOW" == "snapshot" ]]; then - cd $repo/.ci/output && tar -czf elasticsearch-php-$VERSION-SNAPSHOT.tar.gz * && cd - + cd $repo/.github/output && tar -czf elasticsearch-php-$VERSION-SNAPSHOT.tar.gz * && cd - else - cd $repo/.ci/output && tar -czf elasticsearch-php-$VERSION.tar.gz * && cd - + cd $repo/.github/output && tar -czf elasticsearch-php-$VERSION.tar.gz * && cd - fi - rm -Rf "${repo}/.ci/output/elasticsearch-php" + rm -Rf "${repo}/.github/output/elasticsearch-php" echo -e "\033[32;1mTARGET: successfully assembled client v$VERSION\033[0m" exit 0 else @@ -166,8 +166,8 @@ if [[ "$CMD" == "bump" ]]; then MINOR_VERSION=`echo $VERSION | grep -Eo "[0-9]+.[0-9]+"` - # Change version to .ci/test-matrix.yml - sed -i "s/[0-9]\+\.[0-9]\+-SNAPSHOT/$MINOR_VERSION-SNAPSHOT/" $repo/.ci/test-matrix.yml + # Change version to .github/pipeline.yml + sed -i "s/STACK_VERSION: [0-9]\+\.[0-9]\+-SNAPSHOT/STACK_VERSION: $MINOR_VERSION-SNAPSHOT/" $repo/.github/pipeline.yml # Change version to .github/workflows/test.yml sed -i "s/es-version: \[[0-9]\+\.[0-9]\+\.\?[0-9]\?-SNAPSHOT\]/es-version: \[$MINOR_VERSION-SNAPSHOT\]/" $repo/.github/workflows/test.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5901d7264..97f0dbfdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,63 @@ +## Release 8.11.0 + +- Added 5 new EXPERIMENTAL APIs: + - `Esql.query ` + - API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/esql.query.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html + - `Inference.deleteModel` + - API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.delete_model.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html + - `Inference.getModel` + - API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.get_model.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html + - `Inference.inference` + - API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.inference.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html + - `Inference.putModel` + - API: https://github.com/elastic/elasticsearch/blob/v8.11.0/rest-api-spec/src/main/resources/rest-api-spec/api/inference.put_model.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html + +## Release 8.10.0 + +- Added 10 new APIs: 8 EXPERIMENTAL and 2 stable: + - `QueryRuleset.list` (new EXPERIMENTAL API) + - API: https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/api/query_ruleset.list.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/list-query-rulesets.html + - `Security.getSettings` (new API) + - API: https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/api/security.get_settings.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-settings.html + - `Security.updateSettings` (new API) + - API: https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/api/security.update_settings.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-settings.html + - `Synonyms.delete` + - Removed this API in favor of `deleteSynonym`. + - `Synonyms.deleteSynonym` (new EXPERIMENTAL API) + - This API replaces `Synonyms.delete`. Removed `synonyms_set` in favor of `id` +parameter (string). The id of the synonyms set to be deleted. + - `Synonyms.deleteSynonymRule` (new EXPERIMENTAL API) + - API: https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/api/synonyms.delete_synonym_rule.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonym-rule.html + - `Synonyms.get` + - Removed this function in favor of `getSynonym`. + - `Synonyms.getSynonym` (new EXPERIMENTAL API) + - This API replaces `Synonyms.getSynonym`. Removed `synonyms_set` in favor of `id` +required parameter (string). The name of the synonyms set to be retrieved. + - `Synonyms.getSynonymRule` (new EXPERIMENTAL API) + - API: https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/api/synonyms.get_synonym_rule.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonym-rule.html + - `Synonyms.getSynonymsSets` (new EXPERIMENTAL API) + - API: https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/api/synonyms.get_synonyms_sets.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/list-synonyms-sets.html + - `Synonyms.put` + - Removed this function in favor of `putSynonym`. + - `Synonyms.putSynonym` (new EXPERIMENTAL API) + - This API replaces `Synonyms.put`. Removed `synonyms_set` in favor of `id` +required parameter (string). The id of the synonyms set to be created or updated. + - `Synonyms.putSynonymRule` (new EXPERIMENTAL API) + - API: https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/api/synonyms.put_synonym_rule.json + - Documentation: https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonym-rule.html + + ## Release 8.9.0 - Fixed issue with psr/http-message, changed PSR-7 versions to 1.1 and 2.0 diff --git a/README.md b/README.md index c50cf5dae..7ea3e7e6b 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ -Elasticsearch PHP client -======================== +# Elasticsearch PHP client [![Build status](https://github.com/elastic/elasticsearch-php/workflows/PHP%20test/badge.svg)](https://github.com/elastic/elasticsearch-php/actions) [![Latest Stable Version](https://poser.pugx.org/elasticsearch/elasticsearch/v/stable)](https://packagist.org/packages/elasticsearch/elasticsearch) [![Total Downloads](https://poser.pugx.org/elasticsearch/elasticsearch/downloads)](https://packagist.org/packages/elasticsearch/elasticsearch) -This is the official PHP client for +This is the official PHP client for [Elasticsearch](https://www.elastic.co/elasticsearch/). +**[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)** +or +**[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)** +**for a free trial of Elastic Cloud**. + ## Contents - [Installation](#installation) @@ -27,65 +31,65 @@ This is the official PHP client for Refer to the [Installation section](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_installation) of the getting started documentation. -## Connecting +## Connecting Refer to the [Connecting section](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_connecting) of the getting started documentation. ## Usage -The `elasticsearch-php` client offers 400+ endpoints for interacting with -Elasticsearch. A list of all these endpoints is available in the +The `elasticsearch-php` client offers 400+ endpoints for interacting with +Elasticsearch. A list of all these endpoints is available in the [official documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html) of Elasticsearch APIs. -Here we reported the basic operation that you can perform with the client: +Here we reported the basic operation that you can perform with the client: index, search and delete. -* [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_creating_an_index) -* [Indexing a document](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_indexing_documents) -* [Getting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_getting_documents) -* [Searching documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_searching_documents) -* [Updating documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_updating_documents) -* [Deleting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_documents) -* [Deleting an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_an_index) +- [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_creating_an_index) +- [Indexing a document](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_indexing_documents) +- [Getting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_getting_documents) +- [Searching documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_searching_documents) +- [Updating documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_updating_documents) +- [Deleting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_documents) +- [Deleting an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_an_index) ### Versioning This client is versioned and released alongside Elasticsearch server. -To guarantee compatibility, use the most recent version of this library within +To guarantee compatibility, use the most recent version of this library within the major version of the corresponding Enterprise Search implementation. -For example, for Elasticsearch `7.16`, use `7.16` of this library or above, but +For example, for Elasticsearch `7.16`, use `7.16` of this library or above, but not `8.0`. ## Backward Incompatible Changes :boom: -The 8.0.0 version of `elasticsearch-php` contains a new implementation compared -with 7.x. It supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP -messages and [PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client -communications. +The 8.0.0 version of `elasticsearch-php` contains a new implementation compared +with 7.x. It supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP +messages and [PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client +communications. -We tried to reduce the BC breaks as much as possible with `7.x` but there are +We tried to reduce the BC breaks as much as possible with `7.x` but there are some (big) differences: - we changed the namespace, now everything is under `Elastic\Elasticsearch` -- we used the - [elastic-transport-php](https://github.com/elastic/elastic-transport-php) +- we used the + [elastic-transport-php](https://github.com/elastic/elastic-transport-php) library for HTTP communications; -- we changed the `Exception` model, using the namespace - `Elastic\Elasticsearch\Exception`. All the exceptions extends the +- we changed the `Exception` model, using the namespace + `Elastic\Elasticsearch\Exception`. All the exceptions extends the `ElasticsearchException` interface, as in 7.x -- we changed the response type of each endpoints using an - [Elasticsearch](src/Response/Elasticsearch.php) response class. This class - wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the - access of the body response as array or object. This means you can access the +- we changed the response type of each endpoints using an + [Elasticsearch](src/Response/Elasticsearch.php) response class. This class + wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the + access of the body response as array or object. This means you can access the API response as in 7.x, no BC break here! :angel: -- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was +- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was ambigous since the objects are nodes (hosts) -You can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more +You can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more information. ## Mock the Elasticsearch client @@ -93,7 +97,7 @@ information. If you need to mock the Elasticsearch client you just need to mock a [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client. -For instance, you can use the +For instance, you can use the [php-http/mock-client](https://github.com/php-http/mock-client) as follows: ```php @@ -122,52 +126,52 @@ echo $result->asString(); // This is the body! ``` We are using the `ClientBuilder::setHttpClient()` to set the mock client. -You can specify the response that you want to have using the -`addResponse($response)` function. As you can see the `$response` is a PSR-7 -response object. In this example we used the `Nyholm\Psr7\Response` object from -the [nyholm/psr7](https://github.com/Nyholm/psr7) project. If you are using -[PHPUnit](https://phpunit.de/) you can even mock the `ResponseInterface` as +You can specify the response that you want to have using the +`addResponse($response)` function. As you can see the `$response` is a PSR-7 +response object. In this example we used the `Nyholm\Psr7\Response` object from +the [nyholm/psr7](https://github.com/Nyholm/psr7) project. If you are using +[PHPUnit](https://phpunit.de/) you can even mock the `ResponseInterface` as follows: ```php $response = $this->createMock('Psr\Http\Message\ResponseInterface'); ``` -**Notice**: we added a special header in the HTTP response. This is the product -check header, and it is required for guarantee that `elasticsearch-php` is +**Notice**: we added a special header in the HTTP response. This is the product +check header, and it is required for guarantee that `elasticsearch-php` is communicating with an Elasticsearch server 8.0+. -For more information you can read the -[Mock client](https://docs.php-http.org/en/latest/clients/mock-client.html) +For more information you can read the +[Mock client](https://docs.php-http.org/en/latest/clients/mock-client.html) section of PHP-HTTP documentation. ## FAQ 🔮 ### Where do I report issues with the client? -If something is not working as expected, please open an +If something is not working as expected, please open an [issue](https://github.com/elastic/elasticsearch-php/issues/new). ### Where else can I go to get help? -You can checkout the +You can checkout the [Elastic community discuss forums](https://discuss.elastic.co/). ## Contribute 🚀 We welcome contributors to the project. Before you begin, some useful info... -+ If you want to contribute to this project you need to subscribe to a +- If you want to contribute to this project you need to subscribe to a [Contributor Agreement](https://www.elastic.co/contributor-agreement). -+ Before opening a pull request, please create an issue to +- Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/elastic/elasticsearch-php/issues). -+ If you want to send a PR for version `8.0` please use the `8.0` branch, for - `8.1` use the `8.1` branch and so on. -+ Never send PR to `master` unless you want to contribute to the development +- If you want to send a PR for version `8.0` please use the `8.0` branch, for + `8.1` use the `8.1` branch and so on. +- Never send PR to `master` unless you want to contribute to the development version of the client (`master` represents the next major version). -+ Each PR should include a **unit test** using [PHPUnit](https://phpunit.de/). - If you are not familiar with PHPUnit you can have a look at the - [reference](https://phpunit.readthedocs.io/en/9.5/). +- Each PR should include a **unit test** using [PHPUnit](https://phpunit.de/). + If you are not familiar with PHPUnit you can have a look at the + [reference](https://phpunit.readthedocs.io/en/9.5/). Thanks in advance for your contribution! :heart: diff --git a/composer.json b/composer.json index df5cf70e9..96723fa91 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ "type": "library", "license": "MIT", "require": { - "php": "^7.4 || ^8.0", - "elastic/transport": "^8.7", + "php": "^8.0", + "elastic/transport": "^8.8", "psr/http-client": "^1.0", "psr/http-message": "^1.1 || ^2.0", "psr/log": "^1|^2|^3", diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc index 3544b92ad..7bbd4f8d9 100644 --- a/docs/breaking-changes.asciidoc +++ b/docs/breaking-changes.asciidoc @@ -36,7 +36,7 @@ The following functions has been removed: - `ClientBuilder::setTracer()`, you can only set a Logger using `ClientBuilder::setLogger()` - `ClientBuilder::setSerializer()` - `ClientBuilder::setConnectionParams()`, you can use `ClientBuilder::setHttpClientOptions()` instead -- `ClientBuilder::setSelector()`, you can set a `Selector` using the `setNodePool`, see [here](https://github.com/elastic/elastic-transport-php/blob/8.x/README.md#use-a-custom-selector) for more information +- `ClientBuilder::setSelector()`, you can set a `Selector` using the `setNodePool`, see https://github.com/elastic/elastic-transport-php/blob/8.x/README.md#use-a-custom-selector[here] for more information - `ClientBuilder::setSniffOnStart()` - `ClientBuilder::includePortInHostHeader()` diff --git a/docs/installation.asciidoc b/docs/installation.asciidoc index 0b3b35f3c..9766efe58 100644 --- a/docs/installation.asciidoc +++ b/docs/installation.asciidoc @@ -36,3 +36,4 @@ Client instantiation is performed with a static helper function `create()`. This creates a ClientBuilder object, which helps you to set custom configurations. When you are done configuring, call the `build()` method to generate a `Client` object. For further info, consult the <> section. + diff --git a/docs/release-notes.asciidoc b/docs/release-notes.asciidoc index 35a3c6fe7..565469310 100644 --- a/docs/release-notes.asciidoc +++ b/docs/release-notes.asciidoc @@ -1,6 +1,8 @@ [[release-notes]] == Release notes +* <> +* <> * <> * <> * <> @@ -41,6 +43,21 @@ * <> * <> +[discrete] +[[rn-8-11-0]] +=== 8.11.0 + +* Updated the API endpoints to Elasticserach 8.11.0 +* Fixed path in hosts configuration is ignored + https://github.com/elastic/elasticsearch-php/issues/1377[#1377] + + +[discrete] +[[rn-8-10-0]] +=== 8.10.0 + +* Updated the API endpoints to Elasticserach 8.10.0 + [discrete] [[rn-8-9-0]] === 8.9.0 diff --git a/src/Client.php b/src/Client.php index e4fa85116..d7063596f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -28,7 +28,7 @@ final class Client implements ClientInterface { const CLIENT_NAME = 'es'; - const VERSION = '8.10.0'; + const VERSION = '8.12.0'; const API_COMPATIBILITY_HEADER = '%s/vnd.elasticsearch+%s; compatible-with=8'; use ClientEndpointsTrait; diff --git a/src/Endpoints/SynonymsSets.php b/src/Endpoints/Esql.php similarity index 73% rename from src/Endpoints/SynonymsSets.php rename to src/Endpoints/Esql.php index b341604ff..c19392459 100644 --- a/src/Endpoints/SynonymsSets.php +++ b/src/Endpoints/Esql.php @@ -26,22 +26,23 @@ /** * @generated This file is generated, please do not edit */ -class SynonymsSets extends AbstractEndpoint +class Esql extends AbstractEndpoint { /** - * Retrieves a summary of all defined synonym sets + * Executes an ESQL request * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-synonyms.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * from: int, // Starting offset - * size: int, // specifies a max number of results to get + * format: string, // a short version of the Accept header, e.g. json, yaml + * delimiter: string, // The character to use between values within a CSV row. Only valid for the csv format. * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) * human: boolean, // Return human readable values for statistics. (DEFAULT: true) * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. * filter_path: list, // A comma-separated list of filters used to reduce the response. + * body: array, // (REQUIRED) Use the `query` element to start a query. Use `time_zone` to specify an execution time zone and `columnar` to format the answer. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -50,14 +51,16 @@ class SynonymsSets extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function query(array $params = []) { - $url = '/_synonyms'; - $method = 'GET'; + $this->checkRequiredParameters(['body'], $params); + $url = '/_query'; + $method = 'POST'; - $url = $this->addQueryString($url, $params, ['from','size','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['format','delimiter','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', + 'Content-Type' => 'application/json', ]; return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); } diff --git a/src/Endpoints/Indices.php b/src/Endpoints/Indices.php index 6b229c1ee..a1c2fab40 100644 --- a/src/Endpoints/Indices.php +++ b/src/Endpoints/Indices.php @@ -425,13 +425,13 @@ public function deleteAlias(array $params = []) /** - * Deletes the data lifecycle of the selected data streams. + * Deletes the data stream lifecycle of the selected data streams. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-delete-lifecycle.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * name: list, // (REQUIRED) A comma-separated list of data streams of which the data lifecycle will be deleted; use `*` to get all data streams + * name: list, // (REQUIRED) A comma-separated list of data streams of which the data stream lifecycle will be deleted; use `*` to get all data streams * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) * timeout: time, // Explicit timestamp for the document * master_timeout: time, // Specify timeout for connection to master @@ -502,7 +502,7 @@ public function deleteDataStream(array $params = []) /** * Deletes an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template.html * * @param array{ * name: string, // (REQUIRED) The name of the template @@ -539,7 +539,7 @@ public function deleteIndexTemplate(array $params = []) /** * Deletes an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-template-v1.html * * @param array{ * name: string, // (REQUIRED) The name of the template @@ -741,7 +741,7 @@ public function existsAlias(array $params = []) /** * Returns information about whether a particular index template exists. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/index-templates.html * * @param array{ * name: string, // (REQUIRED) The name of the template @@ -779,7 +779,7 @@ public function existsIndexTemplate(array $params = []) /** * Returns information about whether a particular index template exists. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-template-exists-v1.html * * @param array{ * name: list, // (REQUIRED) The comma separated names of the index templates @@ -1070,7 +1070,7 @@ public function getAlias(array $params = []) /** - * Returns the data lifecycle of the selected data streams. + * Returns the data stream lifecycle of the selected data streams. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-get-lifecycle.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release @@ -1194,7 +1194,7 @@ public function getFieldMapping(array $params = []) /** * Returns an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template.html * * @param array{ * name: string, // A pattern that returned template names must match @@ -1328,7 +1328,7 @@ public function getSettings(array $params = []) /** * Returns an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-template-v1.html * * @param array{ * name: list, // The comma separated names of the index templates @@ -1552,7 +1552,7 @@ public function putAlias(array $params = []) /** - * Updates the data lifecycle of the selected data streams. + * Updates the data stream lifecycle of the selected data streams. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-put-lifecycle.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release @@ -1567,7 +1567,7 @@ public function putAlias(array $params = []) * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. * filter_path: list, // A comma-separated list of filters used to reduce the response. - * body: array, // The data lifecycle configuration that consist of the data retention + * body: array, // The data stream lifecycle configuration that consist of the data retention * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1594,7 +1594,7 @@ public function putDataLifecycle(array $params = []) /** * Creates or updates an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-template.html * * @param array{ * name: string, // (REQUIRED) The name of the template @@ -1724,7 +1724,7 @@ public function putSettings(array $params = []) /** * Creates or updates an index template. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates-v1.html * * @param array{ * name: string, // (REQUIRED) The name of the template @@ -1850,6 +1850,7 @@ public function refresh(array $params = []) * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * resource: string, // changed resource to reload analyzers from if applicable * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) * human: boolean, // Return human readable values for statistics. (DEFAULT: true) * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) @@ -1870,7 +1871,7 @@ public function reloadSearchAnalyzers(array $params = []) $url = '/' . $this->encode($params['index']) . '/_reload_search_analyzers'; $method = empty($params['body']) ? 'GET' : 'POST'; - $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','resource','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -2087,7 +2088,7 @@ public function shrink(array $params = []) /** * Simulate matching the given index name against the index templates in the system * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-index.html * * @param array{ * name: string, // (REQUIRED) The name of the index (it must be a concrete index name) @@ -2128,7 +2129,7 @@ public function simulateIndexTemplate(array $params = []) /** * Simulate resolving the given template name or body * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-template.html * * @param array{ * name: string, // The name of the index template diff --git a/src/Endpoints/Inference.php b/src/Endpoints/Inference.php new file mode 100644 index 000000000..835d59c49 --- /dev/null +++ b/src/Endpoints/Inference.php @@ -0,0 +1,181 @@ +checkRequiredParameters(['task_type','model_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + + /** + * Get a model in the Inference API + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * task_type: string, // (REQUIRED) The model task type + * model_id: string, // (REQUIRED) The model Id + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function getModel(array $params = []) + { + $this->checkRequiredParameters(['task_type','model_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + + /** + * Perform inference on a model + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * task_type: string, // (REQUIRED) The model task type + * model_id: string, // (REQUIRED) The model Id + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * body: array, // The inference payload + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function inference(array $params = []) + { + $this->checkRequiredParameters(['task_type','model_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + + /** + * Configure a model for use in the Inference API + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * task_type: string, // (REQUIRED) The model task type + * model_id: string, // (REQUIRED) The model Id + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * body: array, // The model's task and service settings + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putModel(array $params = []) + { + $this->checkRequiredParameters(['task_type','model_id'], $params); + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } +} diff --git a/src/Endpoints/QueryRuleset.php b/src/Endpoints/QueryRuleset.php index 008eb5540..ef2857cec 100644 --- a/src/Endpoints/QueryRuleset.php +++ b/src/Endpoints/QueryRuleset.php @@ -100,6 +100,41 @@ public function get(array $params = []) } + /** + * Lists query rulesets. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-query-rulesets.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * from: int, // Starting offset (default: 0) + * size: int, // specifies a max number of results to get (default: 100) + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function list(array $params = []) + { + $url = '/_query_rules'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['from','size','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Creates or updates a query ruleset. * diff --git a/src/Endpoints/Security.php b/src/Endpoints/Security.php index f6d64d3ee..8c7536587 100644 --- a/src/Endpoints/Security.php +++ b/src/Endpoints/Security.php @@ -389,7 +389,6 @@ public function createApiKey(array $params = []) * Creates a cross-cluster API key for API key based remote cluster access. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-cross-cluster-api-key.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) @@ -1118,6 +1117,39 @@ public function getServiceCredentials(array $params = []) } + /** + * Retrieve settings for the security system indices + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-settings.html + * + * @param array{ + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function getSettings(array $params = []) + { + $url = '/_security/settings'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Creates a bearer token for access without requiring basic authentication. * @@ -2017,7 +2049,6 @@ public function updateApiKey(array $params = []) * Updates attributes of an existing cross-cluster API key. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-cross-cluster-api-key.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * id: string, // (REQUIRED) The ID of the cross-cluster API key to update @@ -2051,6 +2082,41 @@ public function updateCrossClusterApiKey(array $params = []) } + /** + * Update settings for the security system index + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-settings.html + * + * @param array{ + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * body: array, // (REQUIRED) An object with the new settings for each index, if any + * } $params + * + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function updateSettings(array $params = []) + { + $this->checkRequiredParameters(['body'], $params); + $url = '/_security/settings'; + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Update application specific data for the user profile of the given unique ID. * diff --git a/src/Endpoints/SynonymRule.php b/src/Endpoints/SynonymRule.php deleted file mode 100644 index dcd4d638f..000000000 --- a/src/Endpoints/SynonymRule.php +++ /dev/null @@ -1,68 +0,0 @@ -checkRequiredParameters(['synonyms_set','synonym_rule','body'], $params); - $url = '/_synonyms/' . $this->encode($params['synonyms_set']) . '/' . $this->encode($params['synonym_rule']); - $method = 'PUT'; - - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); - $headers = [ - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); - } -} diff --git a/src/Endpoints/Synonyms.php b/src/Endpoints/Synonyms.php index e81fe973d..2256b4f09 100644 --- a/src/Endpoints/Synonyms.php +++ b/src/Endpoints/Synonyms.php @@ -31,11 +31,11 @@ class Synonyms extends AbstractEndpoint /** * Deletes a synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonyms.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonyms-set.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * synonyms_set: string, // (REQUIRED) The name of the synonyms set to be deleted + * id: string, // (REQUIRED) The id of the synonyms set to be deleted * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) * human: boolean, // Return human readable values for statistics. (DEFAULT: true) * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) @@ -50,10 +50,10 @@ class Synonyms extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function deleteSynonym(array $params = []) { - $this->checkRequiredParameters(['synonyms_set'], $params); - $url = '/_synonyms/' . $this->encode($params['synonyms_set']); + $this->checkRequiredParameters(['id'], $params); + $url = '/_synonyms/' . $this->encode($params['id']); $method = 'DELETE'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -64,14 +64,52 @@ public function delete(array $params = []) } + /** + * Deletes a synonym rule in a synonym set + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonym-rule.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * set_id: string, // (REQUIRED) The id of the synonym set to be updated + * rule_id: string, // (REQUIRED) The id of the synonym rule to be deleted + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function deleteSynonymRule(array $params = []) + { + $this->checkRequiredParameters(['set_id','rule_id'], $params); + $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Retrieves a synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonyms.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonyms-set.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * synonyms_set: string, // (REQUIRED) The name of the synonyms set to be retrieved + * id: string, // (REQUIRED) The name of the synonyms set to be retrieved * from: int, // Starting offset * size: int, // specifies a max number of results to get * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) @@ -88,10 +126,83 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function getSynonym(array $params = []) + { + $this->checkRequiredParameters(['id'], $params); + $url = '/_synonyms/' . $this->encode($params['id']); + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['from','size','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + + /** + * Retrieves a synonym rule from a synonym set + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonym-rule.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * set_id: string, // (REQUIRED) The id of the synonym set to retrieve the synonym rule from + * rule_id: string, // (REQUIRED) The id of the synonym rule to retrieve + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function getSynonymRule(array $params = []) + { + $this->checkRequiredParameters(['set_id','rule_id'], $params); + $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + + /** + * Retrieves a summary of all defined synonym sets + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-synonyms-sets.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * from: int, // Starting offset + * size: int, // specifies a max number of results to get + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * } $params + * + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function getSynonymsSets(array $params = []) { - $this->checkRequiredParameters(['synonyms_set'], $params); - $url = '/_synonyms/' . $this->encode($params['synonyms_set']); + $url = '/_synonyms'; $method = 'GET'; $url = $this->addQueryString($url, $params, ['from','size','pretty','human','error_trace','source','filter_path']); @@ -105,11 +216,11 @@ public function get(array $params = []) /** * Creates or updates a synonyms set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonyms.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonyms-set.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * synonyms_set: string, // (REQUIRED) The name of the synonyms set to be created or updated + * id: string, // (REQUIRED) The id of the synonyms set to be created or updated * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) * human: boolean, // Return human readable values for statistics. (DEFAULT: true) * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) @@ -125,10 +236,49 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function put(array $params = []) + public function putSynonym(array $params = []) + { + $this->checkRequiredParameters(['id','body'], $params); + $url = '/_synonyms/' . $this->encode($params['id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + + /** + * Creates or updates a synonym rule in a synonym set + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonym-rule.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * set_id: string, // (REQUIRED) The id of the synonym set to be updated with the synonym rule + * rule_id: string, // (REQUIRED) The id of the synonym rule to be updated or created + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * filter_path: list, // A comma-separated list of filters used to reduce the response. + * body: array, // (REQUIRED) Synonym rule + * } $params + * + * @throws MissingParameterException if a required parameter is missing + * @throws NoNodeAvailableException if all the hosts are offline + * @throws ClientResponseException if the status code of response is 4xx + * @throws ServerResponseException if the status code of response is 5xx + * + * @return Elasticsearch|Promise + */ + public function putSynonymRule(array $params = []) { - $this->checkRequiredParameters(['synonyms_set','body'], $params); - $url = '/_synonyms/' . $this->encode($params['synonyms_set']); + $this->checkRequiredParameters(['set_id','rule_id','body'], $params); + $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); $method = 'PUT'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); diff --git a/src/Response/Elasticsearch.php b/src/Response/Elasticsearch.php index a8fe29dc7..164d999fa 100644 --- a/src/Response/Elasticsearch.php +++ b/src/Response/Elasticsearch.php @@ -196,6 +196,8 @@ public function offsetExists($offset): bool * ArrayAccess interface * * @see https://www.php.net/manual/en/class.arrayaccess.php + * + * @return mixed */ #[\ReturnTypeWillChange] public function offsetGet($offset) diff --git a/src/Traits/NamespaceTrait.php b/src/Traits/NamespaceTrait.php index 2e9463a2c..857f7ace8 100644 --- a/src/Traits/NamespaceTrait.php +++ b/src/Traits/NamespaceTrait.php @@ -24,11 +24,13 @@ use Elastic\Elasticsearch\Endpoints\DanglingIndices; use Elastic\Elasticsearch\Endpoints\Enrich; use Elastic\Elasticsearch\Endpoints\Eql; +use Elastic\Elasticsearch\Endpoints\Esql; use Elastic\Elasticsearch\Endpoints\Features; use Elastic\Elasticsearch\Endpoints\Fleet; use Elastic\Elasticsearch\Endpoints\Graph; use Elastic\Elasticsearch\Endpoints\Ilm; use Elastic\Elasticsearch\Endpoints\Indices; +use Elastic\Elasticsearch\Endpoints\Inference; use Elastic\Elasticsearch\Endpoints\Ingest; use Elastic\Elasticsearch\Endpoints\License; use Elastic\Elasticsearch\Endpoints\Logstash; @@ -46,9 +48,7 @@ use Elastic\Elasticsearch\Endpoints\Snapshot; use Elastic\Elasticsearch\Endpoints\Sql; use Elastic\Elasticsearch\Endpoints\Ssl; -use Elastic\Elasticsearch\Endpoints\SynonymRule; use Elastic\Elasticsearch\Endpoints\Synonyms; -use Elastic\Elasticsearch\Endpoints\SynonymsSets; use Elastic\Elasticsearch\Endpoints\Tasks; use Elastic\Elasticsearch\Endpoints\TextStructure; use Elastic\Elasticsearch\Endpoints\Transform; @@ -136,6 +136,15 @@ public function eql(): Eql } + public function esql(): Esql + { + if (!isset($this->namespace['Esql'])) { + $this->namespace['Esql'] = new Esql($this); + } + return $this->namespace['Esql']; + } + + public function features(): Features { if (!isset($this->namespace['Features'])) { @@ -181,6 +190,15 @@ public function indices(): Indices } + public function inference(): Inference + { + if (!isset($this->namespace['Inference'])) { + $this->namespace['Inference'] = new Inference($this); + } + return $this->namespace['Inference']; + } + + public function ingest(): Ingest { if (!isset($this->namespace['Ingest'])) { @@ -334,15 +352,6 @@ public function ssl(): Ssl } - public function synonymRule(): SynonymRule - { - if (!isset($this->namespace['SynonymRule'])) { - $this->namespace['SynonymRule'] = new SynonymRule($this); - } - return $this->namespace['SynonymRule']; - } - - public function synonyms(): Synonyms { if (!isset($this->namespace['Synonyms'])) { @@ -352,15 +361,6 @@ public function synonyms(): Synonyms } - public function synonymsSets(): SynonymsSets - { - if (!isset($this->namespace['SynonymsSets'])) { - $this->namespace['SynonymsSets'] = new SynonymsSets($this); - } - return $this->namespace['SynonymsSets']; - } - - public function tasks(): Tasks { if (!isset($this->namespace['Tasks'])) { diff --git a/tests/Utility.php b/tests/Utility.php index f8c46134e..45ea0a562 100644 --- a/tests/Utility.php +++ b/tests/Utility.php @@ -514,7 +514,7 @@ private static function wipeAllIndices(Client $client): void } try { $client->indices()->delete([ - 'index' => '*,-.ds-ilm-history-*', + 'index' => '*,-.ds-ilm-history-*,-.ds-.slm-history-*', 'expand_wildcards' => $expand ]); } catch (ClientResponseException $e) { @@ -648,6 +648,9 @@ private static function wipeClusterSettings(Client $client): void */ private static function isXPackTemplate(string $name): bool { + if (strpos($name, '@') !== false) { + return true; + } if (strpos($name, '.monitoring-') !== false) { return true; } @@ -678,6 +681,10 @@ private static function isXPackTemplate(string $name): bool if (strpos($name, 'elastic-connectors') !== false) { return true; } + if (strpos($name, 'apm-') === 0 || strpos($name, 'traces-apm') === 0 || + strpos($name, 'metrics-apm') === 0 || strpos($name, 'logs-apm') === 0) { + return true; + } switch ($name) { case ".watches": case "security_audit_log": @@ -699,7 +706,6 @@ private static function isXPackTemplate(string $name): bool case "logstash-index-template": case "security-index-template": case "data-streams-mappings": - case "ecs@dynamic_templates": case "search-acl-filter": case ".kibana-reporting": return true; @@ -721,14 +727,24 @@ private static function preserveILMPolicyIds(): array "watch-history-ilm-policy", "watch-history-ilm-policy-16", "ml-size-based-ilm-policy", - "logs", + "logs", + "logs@lifecycle", "metrics", + "metrics@lifecycle", + "profiling", + "profiling@lifecycle", "synthetics", + "synthetics@lifecycle", "7-days-default", + "7-days@lifecycle", "30-days-default", + "30-days@lifecycle", "90-days-default", + "90-days@lifecycle", "180-days-default", + "180-days@lifecycle", "365-days-default", + "365-days@lifecycle", ".fleet-files-ilm-policy", ".fleet-file-data-ilm-policy", ".fleet-actions-results-ilm-policy", diff --git a/util/ActionTest.php b/util/ActionTest.php index 7c8677442..67bdda131 100644 --- a/util/ActionTest.php +++ b/util/ActionTest.php @@ -175,12 +175,15 @@ private function transform_and_set(array $action): string private function set(array $action): string { - $key = key($action); - $this->variables[] = $action[$key]; - return YamlTests::render(self::TEMPLATE_SET_VARIABLE, [ - ':var' => $action[$key], - ':value' => $this->convertResponseField($key) - ]); + $output = ''; + foreach ($action as $key => $var) { + $this->variables[] = $var; + $output .= YamlTests::render(self::TEMPLATE_SET_VARIABLE, [ + ':var' => $var, + ':value' => $this->convertResponseField($key) + ]); + } + return $output; } private function warnings(array $action, array &$vars) diff --git a/util/YamlTests.php b/util/YamlTests.php index 6998f8e33..b87d8d8bc 100644 --- a/util/YamlTests.php +++ b/util/YamlTests.php @@ -56,6 +56,7 @@ class YamlTests 'Indices\PutTemplate\_10_BasicTest::PutTemplateCreate' => 'index_template [test] already exists', 'Indices\Refresh\_10_BasicTest::IndicesRefreshTestEmptyArray' => 'empty array?', 'Indices\SimulateIndexTemplate\_10_BasicTest::SimulateIndexTemplateWithIndexNotMatchingAnyTemplate' => 'Bool mismatch', + 'Search\Vectors\_90_Sparse_VectorTest::SparseVectorIn800X8110' => 'Undefined array key error', 'Snapshot\Create\_10_BasicTest::CreateASnapshot' => 'Invalid snapshot name [test_snapshot]', 'Snapshot\Create\_10_BasicTest::CreateASnapshotAndCleanUpRepository' => 'Invalid snapshot name [test_snapshot]', 'Tsdb\_20_MappingTest::UnsupportedMetricTypePosition' => 'Fixed in Elasticsearch 8.9', @@ -79,6 +80,7 @@ class YamlTests 'Ml\_Explain_Data_Frame_AnalyticsTest::TestNonemptyDataFrameGivenBody' => 'Expected a different value', 'Ml\_Get_Trained_Model_StatsTest::*' => 'Skipped all tests', 'Ml\_Get_Trained_Model_StatsTest::TestGetStatsGivenTrainedModels' => 'cannot assign model_alias', + 'Ml\_Inference_RescoreTest::*' => 'unknown field [learn_to_rank]', 'Rollup\_Put_JobTest::TestPutJobWithTemplates' => 'version not converted from variable', 'RuntimeFields\_100_Geo_PointTest::GetMapping' => 'Substring mismatch', 'RuntimeFields\_10_KeywordTest::GetMapping' => 'Substring mismatch', @@ -291,6 +293,9 @@ public function build(): array ] ); } + // Fix ${var} string interpolation deprecated for PHP 8.2 + // @see https://php.watch/versions/8.2/$%7Bvar%7D-string-interpolation-deprecated + $test = $this->fixStringInterpolationInCurlyBracket($test); file_put_contents($testDirName . '/' . $testName . '.php', $test); try { eval(substr($test, 5)); // remove testDir) + 1);