From 14974ad1bafd419e5525e876a6b0ebbb666c1831 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Fri, 28 Mar 2025 06:09:05 -0400 Subject: [PATCH] CDRIVER-5952 remove deprecated URI API --- NEWS | 4 +++ .../doc/mongoc_uri_get_read_prefs.rst | 33 ------------------ src/libmongoc/doc/mongoc_uri_get_service.rst | 29 ---------------- src/libmongoc/doc/mongoc_uri_get_ssl.rst | 34 ------------------- src/libmongoc/doc/mongoc_uri_t.rst | 3 -- src/libmongoc/src/mongoc/mongoc-uri.c | 19 ----------- src/libmongoc/src/mongoc/mongoc-uri.h | 8 ----- src/libmongoc/tests/test-mongoc-uri.c | 11 ++---- 8 files changed, 6 insertions(+), 135 deletions(-) delete mode 100644 src/libmongoc/doc/mongoc_uri_get_read_prefs.rst delete mode 100644 src/libmongoc/doc/mongoc_uri_get_service.rst delete mode 100644 src/libmongoc/doc/mongoc_uri_get_ssl.rst diff --git a/NEWS b/NEWS index 92af21dac0a..455866813b1 100644 --- a/NEWS +++ b/NEWS @@ -56,6 +56,10 @@ Unreleased (2.0.0) * `mongoc_index_opt_t`, `mongoc_index_opt_geo_t` `mongoc_index_opt_wt_t` are removed. Pass options using `bson_t` to `mongoc_collection_create_indexes_with_opts` instead. * `mongoc_collection_find_indexes` is removed. Use `mongoc_collection_find_indexes_with_opts` instead. * See [MongoDB documentation](https://www.mongodb.com/docs/languages/c/c-driver/current/indexes/) for working with indexes. +* Deprecated URI API has been removed: + * `mongoc_uri_get_service` is removed. Use `mongoc_uri_get_srv_hostname` instead. + * `mongoc_uri_get_read_prefs` is removed. Use `mongoc_uri_get_read_prefs_t` instead. + * `mongoc_uri_get_ssl` is removed. Use `mongoc_uri_get_tls` instead. ### Forwarding headers (`#include ` and `#include `) diff --git a/src/libmongoc/doc/mongoc_uri_get_read_prefs.rst b/src/libmongoc/doc/mongoc_uri_get_read_prefs.rst deleted file mode 100644 index 3a28e444737..00000000000 --- a/src/libmongoc/doc/mongoc_uri_get_read_prefs.rst +++ /dev/null @@ -1,33 +0,0 @@ -:man_page: mongoc_uri_get_read_prefs - -mongoc_uri_get_read_prefs() -=========================== - -.. warning:: - .. deprecated:: 1.2.0 - - Use :doc:`mongoc_uri_get_read_prefs_t() ` instead. - -Synopsis --------- - -.. code-block:: c - - const bson_t * - mongoc_uri_get_read_prefs (const mongoc_uri_t *uri); - -Parameters ----------- - -* ``uri``: A :symbol:`mongoc_uri_t`. - -Description ------------ - -Fetches a bson document containing read preference tag information from a URI. Note that this does not include the read preference mode. - -Returns -------- - -Returns a bson document that should not be modified or freed if ``uri`` has read preferences, otherwise ``NULL``. - diff --git a/src/libmongoc/doc/mongoc_uri_get_service.rst b/src/libmongoc/doc/mongoc_uri_get_service.rst deleted file mode 100644 index 8f240b5c203..00000000000 --- a/src/libmongoc/doc/mongoc_uri_get_service.rst +++ /dev/null @@ -1,29 +0,0 @@ -:man_page: mongoc_uri_get_service - -mongoc_uri_get_service() -======================== - -.. warning:: - .. deprecated:: 1.21.0 - - Use :symbol:`mongoc_uri_get_srv_hostname()` instead. - -Synopsis --------- - -.. code-block:: c - - const char * - mongoc_uri_get_service (const mongoc_uri_t *uri); - -Parameters ----------- - -* ``uri``: A :symbol:`mongoc_uri_t`. - -Returns the SRV host and domain name of a MongoDB URI. - -Returns -------- - -A string if this URI's scheme is "mongodb+srv://", or NULL if the scheme is "mongodb://". diff --git a/src/libmongoc/doc/mongoc_uri_get_ssl.rst b/src/libmongoc/doc/mongoc_uri_get_ssl.rst deleted file mode 100644 index 11f81d950e6..00000000000 --- a/src/libmongoc/doc/mongoc_uri_get_ssl.rst +++ /dev/null @@ -1,34 +0,0 @@ -:man_page: mongoc_uri_get_ssl - -mongoc_uri_get_ssl() -==================== - -.. warning:: - .. deprecated:: 1.15.0 - - Use :doc:`mongoc_uri_get_tls() ` instead. - - -Synopsis --------- - -.. code-block:: c - - bool - mongoc_uri_get_ssl (const mongoc_uri_t *uri); - -Parameters ----------- - -* ``uri``: A :symbol:`mongoc_uri_t`. - -Description ------------ - -Fetches a boolean indicating if TLS was specified for use in the URI. - -Returns -------- - -Returns a boolean, true indicating that TLS should be used. This returns true if *any* :ref:`TLS option ` is specified. - diff --git a/src/libmongoc/doc/mongoc_uri_t.rst b/src/libmongoc/doc/mongoc_uri_t.rst index b00b688aa52..7bccab2280d 100644 --- a/src/libmongoc/doc/mongoc_uri_t.rst +++ b/src/libmongoc/doc/mongoc_uri_t.rst @@ -349,12 +349,9 @@ MONGOC_URI_SAFE safe {tr mongoc_uri_get_options mongoc_uri_get_password mongoc_uri_get_read_concern - mongoc_uri_get_read_prefs mongoc_uri_get_read_prefs_t mongoc_uri_get_replica_set mongoc_uri_get_server_monitoring_mode - mongoc_uri_get_service - mongoc_uri_get_ssl mongoc_uri_get_string mongoc_uri_get_srv_hostname mongoc_uri_get_srv_service_name diff --git a/src/libmongoc/src/mongoc/mongoc-uri.c b/src/libmongoc/src/mongoc/mongoc-uri.c index fb8e91baf2f..a4ba010aa1a 100644 --- a/src/libmongoc/src/mongoc/mongoc-uri.c +++ b/src/libmongoc/src/mongoc/mongoc-uri.c @@ -2555,13 +2555,6 @@ mongoc_uri_get_srv_hostname (const mongoc_uri_t *uri) } -const char * -mongoc_uri_get_service (const mongoc_uri_t *uri) -{ - return mongoc_uri_get_srv_hostname (uri); -} - - /* Initial DNS Seedlist Discovery Spec: `srvServiceName` requires a string value * and defaults to "mongodb". */ static const char *const mongoc_default_srv_service_name = "mongodb"; @@ -2664,13 +2657,6 @@ mongoc_uri_get_string (const mongoc_uri_t *uri) } -const bson_t * -mongoc_uri_get_read_prefs (const mongoc_uri_t *uri) -{ - BSON_ASSERT (uri); - return mongoc_read_prefs_get_tags (uri->read_prefs); -} - char * mongoc_uri_unescape (const char *escaped_string) { @@ -2824,11 +2810,6 @@ mongoc_uri_get_tls (const mongoc_uri_t *uri) /* IN */ return false; } -bool -mongoc_uri_get_ssl (const mongoc_uri_t *uri) /* IN */ -{ - return mongoc_uri_get_tls (uri); -} const char * mongoc_uri_get_server_monitoring_mode (const mongoc_uri_t *uri) diff --git a/src/libmongoc/src/mongoc/mongoc-uri.h b/src/libmongoc/src/mongoc/mongoc-uri.h index 770a0049452..50ca454b918 100644 --- a/src/libmongoc/src/mongoc/mongoc-uri.h +++ b/src/libmongoc/src/mongoc/mongoc-uri.h @@ -108,9 +108,6 @@ mongoc_uri_new_for_host_port (const char *hostname, uint16_t port) BSON_GNUC_WAR MONGOC_EXPORT (const mongoc_host_list_t *) mongoc_uri_get_hosts (const mongoc_uri_t *uri); -BSON_DEPRECATED_FOR (mongoc_uri_get_srv_hostname) -MONGOC_EXPORT (const char *) mongoc_uri_get_service (const mongoc_uri_t *uri); - MONGOC_EXPORT (const char *) mongoc_uri_get_srv_hostname (const mongoc_uri_t *uri); @@ -174,9 +171,6 @@ mongoc_uri_set_option_as_bool (mongoc_uri_t *uri, const char *option, bool value MONGOC_EXPORT (bool) mongoc_uri_set_option_as_utf8 (mongoc_uri_t *uri, const char *option, const char *value); -BSON_DEPRECATED_FOR (mongoc_uri_get_read_prefs_t) -MONGOC_EXPORT (const bson_t *) mongoc_uri_get_read_prefs (const mongoc_uri_t *uri); - MONGOC_EXPORT (const char *) mongoc_uri_get_replica_set (const mongoc_uri_t *uri); @@ -219,8 +213,6 @@ mongoc_uri_get_mechanism_properties (const mongoc_uri_t *uri, bson_t *properties MONGOC_EXPORT (bool) mongoc_uri_set_mechanism_properties (mongoc_uri_t *uri, const bson_t *properties); -BSON_DEPRECATED_FOR (mongoc_uri_get_tls) MONGOC_EXPORT (bool) mongoc_uri_get_ssl (const mongoc_uri_t *uri); - MONGOC_EXPORT (bool) mongoc_uri_get_tls (const mongoc_uri_t *uri); diff --git a/src/libmongoc/tests/test-mongoc-uri.c b/src/libmongoc/tests/test-mongoc-uri.c index d1e4f41910d..d3738a944b8 100644 --- a/src/libmongoc/tests/test-mongoc-uri.c +++ b/src/libmongoc/tests/test-mongoc-uri.c @@ -2351,21 +2351,18 @@ test_mongoc_uri_tls_ssl (const char *tls, bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=foo.pem", tlsCertificateKeyFile); uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_ssl (uri)); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=foo.pem", tlsCAFile); uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_ssl (uri)); ASSERT (mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tlsAllowInvalidCertificates); uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_ssl (uri)); ASSERT (mongoc_uri_get_tls (uri)); ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false)); ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); @@ -2374,7 +2371,6 @@ test_mongoc_uri_tls_ssl (const char *tls, bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tlsAllowInvalidHostnames); uri = mongoc_uri_new (url_buffer); - ASSERT (mongoc_uri_get_ssl (uri)); ASSERT (mongoc_uri_get_tls (uri)); ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, false)); ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false)); @@ -2384,7 +2380,6 @@ test_mongoc_uri_tls_ssl (const char *tls, bson_snprintf ( url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=foo.pem", tls, tlsCertificateKeyFile); uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_ssl (uri)); ASSERT (!mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); @@ -2392,7 +2387,6 @@ test_mongoc_uri_tls_ssl (const char *tls, bson_snprintf ( url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=foo.pem", tls, tlsCertificateKeyFile); uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_ssl (uri)); ASSERT (!mongoc_uri_get_tls (uri)); mongoc_uri_destroy (uri); @@ -2400,7 +2394,6 @@ test_mongoc_uri_tls_ssl (const char *tls, bson_snprintf ( url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=true", tls, tlsAllowInvalidCertificates); uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_ssl (uri)); ASSERT (!mongoc_uri_get_tls (uri)); ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false)); ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false)); @@ -2410,7 +2403,6 @@ test_mongoc_uri_tls_ssl (const char *tls, bson_snprintf ( url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=false", tls, tlsAllowInvalidHostnames); uri = mongoc_uri_new (url_buffer); - ASSERT (!mongoc_uri_get_ssl (uri)); ASSERT (!mongoc_uri_get_tls (uri)); ASSERT (!mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, true)); ASSERT (!mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, true)); @@ -2917,7 +2909,8 @@ test_mongoc_uri_duplicates (void) RECREATE_URI (MONGOC_URI_READPREFERENCE "=secondary&" MONGOC_URI_READPREFERENCETAGS "=a:x&" MONGOC_URI_READPREFERENCETAGS "=b:y"); ASSERT_NO_CAPTURED_LOGS (mongoc_uri_get_string (uri)); - bson = mongoc_uri_get_read_prefs (uri); + rp = mongoc_uri_get_read_prefs_t (uri); + bson = mongoc_read_prefs_get_tags (rp); ASSERT_EQUAL_BSON (tmp_bson ("[{'a': 'x'}, {'b': 'y'}]"), bson); RECREATE_URI (MONGOC_URI_REPLICASET "=a&" MONGOC_URI_REPLICASET "=b");