From 724074a178c7531a4fd5dfdb053dfecbf78b73fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 28 Aug 2020 12:16:17 +0300 Subject: [PATCH 1/2] Update REST API tutorial The relationship deletion in it was not done correctly. --- Documentation/Tutorials/REST-API-Tutorial.md | 28 ++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Documentation/Tutorials/REST-API-Tutorial.md b/Documentation/Tutorials/REST-API-Tutorial.md index 7eaa0d2f1..2e9468eaa 100644 --- a/Documentation/Tutorials/REST-API-Tutorial.md +++ b/Documentation/Tutorials/REST-API-Tutorial.md @@ -317,11 +317,26 @@ In our example we are linking the `server1` server to the `RW-Split-Router` service. As was seen with the previous example, the easiest way to do this is to store the result, edit it and then send it back with a HTTP PATCH. -If we want to remove a server from _all_ services, we can set the -`relationships` field to `{}`. The REST API interprets this as an instruction -to remove the server from all services and monitors. This is useful if you want -to delete the server which can only be done if it has no relationships to other -objects. +If we want to remove a server from _all_ services and monitors, we can set the +`data` member of the `services` and `monitors` relationships to an empty array: + +``` +{ + "data": { + "relationships": { + "services": { + "data": [] + }, + "monitors": { + "data": [] + } + } + } +} +``` + +This is useful if you want to delete the server which can only be done if it has +no relationships to other objects. ## Deleting Objects @@ -333,6 +348,9 @@ following command. curl -X DELETE 127.0.0.1:8989/v1/servers/server1 ``` +In order to delete an object, it must not have any relationships to other +objects. + ## Further Reading The full list of all available endpoints in MaxScale can be found in the From c8983886f2612e4101c193b68cfd612cb1be9b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 31 Aug 2020 10:15:48 +0300 Subject: [PATCH 2/2] Use TLS with the Connection class This fixes the problem where an encrypted connection would not be created even though the option for it was there. Also made it configurable outside of the constructor to make it easier to use in tests. --- .../maxtest/include/maxtest/mariadb_func.h | 14 ++++---------- system-test/maxtest/src/mariadb_func.cc | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/system-test/maxtest/include/maxtest/mariadb_func.h b/system-test/maxtest/include/maxtest/mariadb_func.h index 8a2a3d08d..428ac0373 100644 --- a/system-test/maxtest/include/maxtest/mariadb_func.h +++ b/system-test/maxtest/include/maxtest/mariadb_func.h @@ -305,19 +305,13 @@ public: mysql_close(m_conn); } - bool connect() + void ssl(bool value) { - mysql_close(m_conn); - m_conn = mysql_init(NULL); - - // MXS-2568: This fixes mxs1828_double_local_infile - mysql_optionsv(m_conn, MYSQL_OPT_LOCAL_INFILE, (void*)"1"); - - return mysql_real_connect(m_conn, m_host.c_str(), m_user.c_str(), m_pw.c_str(), m_db.c_str(), m_port, - NULL, CLIENT_MULTI_STATEMENTS) - && mysql_errno(m_conn) == 0; + m_ssl = value; } + bool connect(); + void disconnect() { mysql_close(m_conn); diff --git a/system-test/maxtest/src/mariadb_func.cc b/system-test/maxtest/src/mariadb_func.cc index af0cb8148..9c2cd4054 100644 --- a/system-test/maxtest/src/mariadb_func.cc +++ b/system-test/maxtest/src/mariadb_func.cc @@ -592,3 +592,21 @@ int get_int_version(std::string version) str >> major >> dot >> minor >> dot >> patch; return major * 10000 + minor * 100 + patch; } + +bool Connection::connect() +{ + mysql_close(m_conn); + m_conn = mysql_init(NULL); + + // MXS-2568: This fixes mxs1828_double_local_infile + mysql_optionsv(m_conn, MYSQL_OPT_LOCAL_INFILE, (void*)"1"); + + if (m_ssl) + { + set_ssl(m_conn); + } + + return mysql_real_connect(m_conn, m_host.c_str(), m_user.c_str(), m_pw.c_str(), m_db.c_str(), m_port, + NULL, CLIENT_MULTI_STATEMENTS) + && mysql_errno(m_conn) == 0; +}