@@ -33,6 +33,27 @@ The ``kwargs`` are used to add query parameters to the URL. The ``data`` and ``f
3333are used to add a payload to the request. See :py:meth: `requests.Session.request ` for more
3434information on the allowed values for these parameters.
3535
36+ .. note ::
37+
38+ If you have a doubt or want to play with the URL mapping behavior without doing any real call,
39+ use the special method ``.url() ``. It will return the translated URL, with no side effect!
40+
41+ Spin up a Python shell and try it out right now:
42+
43+ .. testcode ::
44+
45+ from mantelo import KeycloakAdmin
46+ c = KeycloakAdmin("https://invalid.com", "my-realm", None)
47+ url = c.just_trying.some("mapping").url()
48+ print(url)
49+
50+ Yields:
51+
52+ .. testoutput ::
53+
54+ https://invalid.com/admin/realms/my-realm/just-trying/some/mapping
55+
56+ (Parameters themselves are handled by :py:mod: `requests `).
3657
3758To better understand, here are some examples of URL mapping (``c `` is the
3859:py:class: `~.KeycloakAdmin ` object):
@@ -74,10 +95,30 @@ To better understand, here are some examples of URL mapping (``c`` is the
7495 > Content-Type: application/json
7596 > {"username": ...}
7697
98+ About dashes
99+ ------------
100+
101+ Since Python doesn't allow dashes in method names, but Keycloak URLs use them in some places,
102+ Mantelo automatically converts any underscores in method names to dashes in the URL.
103+
104+ In other words, to call:
105+
106+ .. code-block :: none
107+
108+ GET /admin/realms/{realm}/client-scopes
109+
110+ You can use:
111+
112+ .. code-block :: python
113+
114+ c.client_scopes.get()
115+
116+ Note that you could also use ``c("client-scopes").get() ``, but let's admit it, it is ugly (so
117+ don't).
118+
77119Special case: working with realms
78120---------------------------------
79121
80-
81122By default, a client is bound to a realm, and has the base URL set to
82123``<server-url>/admin/realms/<realm-name> ``. Hence, to query ``GET /admin/realms/<realm-name> ``, you
83124can use :python: `c.get() ` directly (or :python: `c.post({}) ` to update its properties).
0 commit comments