103 Commits

Author SHA1 Message Date
Takashi Kajinami
cb1be57d38 Declare Python 3.10 support
... and removes the remaining code and dependency for Python < 3.8.

Change-Id: I9aa4b4fa6b73b6fbc792789b4bc63b7fb0370806
2023-10-07 12:08:28 +09:00
Zuul
b79a10f0b5 Merge "use importlib.metadata to get keyring version" 2022-04-29 17:21:37 +00:00
Doug Hellmann
6940b4ff0a use importlib.metadata to get keyring version
Importing pkg_resources has a side-effect of scanning the metadata of
all of the installed python modules to build an in-memory cache. That
cache isn't used anywhere in keystoneclient, and it can be expensive
to build.

The importlib.metadata module in the 3.8 standard library (and the
importlib_metadata library for earlier versions) provides the same
version lookup service using a more efficient scanning
implementation. Switching from pkg_resources to importlib.metadata
will help application startup time, which is especially important for
command line programs such as python-openstackclient.

Change-Id: Ia89044ff1876eeb2793cd08ed9095ce2ffe89e09
Depends-On: Ic6db7af34c87a636bfe55bacae03c42154f4b9c7
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2022-04-22 15:48:44 +00:00
Dr. Jens Harbott
ea6fe1da5d Stop using an admin endpoint by default
With V3 of the identity API, we no longer need to have a dedicated admin
endpoint, so stop requesting one by default, allowing deployments to
actually work without one.

Signed-off-by: Dr. Jens Harbott <harbott@osism.tech>
Change-Id: I96cc9c14008bcc59992d06c89f8f50895390f11e
2021-11-05 22:37:50 +01:00
David Stanek
b2e9caee38 Add Response class to return request-id to caller
This change is required to return 'request_id' from client
to log request_id mappings of cross-project requests.

Instantiating class 'keystoneclient.v3.client.Client' using
'include_metadata=True' will cause manager response to return
a new 'Response' class instead of just the data. This 'Response'
class is going to have additional metadata properties available
like 'request_ids' and the original data will be available as
property 'data' to it.

This change is backward compatible since user has to set a new
parameter 'include_metadata=True' to client in order to get the
request_id returned.

Co-author: Dinesh Bhor <dinesh.bhor@nttdata.com>
Partially Implements: blueprint return-request-id-to-caller
Change-Id: Ibefaa484158ff08bfcacc1e2802d87fc26fd76a5
2018-03-26 01:51:30 -07:00
Morgan Fainberg
4a43aa02b8 Remove use of positional decorator
The positional decorator results in poorly maintainable code in
a misguided effort to emulate python3's key-word-arg only notation
and functionality. This patch removes keystoneclient's dependance
on the positional decorator.

Change-Id: I9e691cc8b0c04992f4a8dabd67e1b413d3220d23
2017-08-07 13:14:55 -07:00
wingwj
1d5774f498 Remove log translations in python-keystoneclient
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: Ia77819cbb133903d20e821bff0c45766b11ef07b
2017-03-21 14:38:05 +08:00
Jenkins
f7c1d45a04 Merge "Fix missing service_catalog parameter in Client object" 2016-12-01 00:08:44 +00:00
zhangyanxian
e7d7ea4da2 Fix typo in httpclient.py
TrivialFix

Change-Id: I248e0548fc0242d9f164df901be3c87ae3a75413
2016-11-08 06:25:11 +00:00
Mikhail Nikolaenko
b405d71a5f Fix missing service_catalog parameter in Client object
Return None if service_catalog parameter does not exist.

service_catalog is the property and it is not initialized on object creation.
service_catalog tries to get value from auth_ref and raises AttributeError
exception if auth_ref is not initialized. It worked before we introduced
sessions, because authentication happened on client instantiation. Now,
when sessions are used, auth_ref is not initialized until the first
request. This change adds try-catch block in service_catalog property
to catch this error.

Change-Id: I58eb888f0989241f9e5626564bd48d901b324d36
Closes-Bug: #1508374
2016-08-05 15:21:17 +03:00
Jenkins
fb2fef9100 Merge "Fixing D105 PEP257" 2016-05-04 23:31:52 +00:00
Jenkins
9f217b63ad Merge "Fixing D200 PEP257 violation." 2016-05-04 23:31:46 +00:00
Jenkins
2f2fc1a071 Merge "Fixing D202 and D203 PEP257 violation." 2016-05-04 23:31:40 +00:00
Navid Pustchi
01500be7fb Fixing D105 PEP257
Currently tox ignores D105.
D105: Missing docstring in magic method.
This change removes it and make keystoneclient docstring compliant with it.

Change-Id: I34dfc164891880425f542f8f8aa3426ec8640c96
2016-05-04 19:47:14 +00:00
Navid Pustchi
4c180e691f Fixing D200 PEP257 violation.
Currently tox ignores D200.
D200: One-line docstring should fit on one line with quotes.
This change removes D200 ignore in tox and fix violations.

Change-Id: Icbf8cc1d4f1c00daeedeffe4397369f9e468b191
2016-05-04 19:47:00 +00:00
Navid Pustchi
bca112c8ba Fixing D202 and D203 PEP257 violation.
Currently tox ignores D202 and D203.
D202: No blank lines allowed after function docstring.
D203: 1 blank required before class docstring.
This change removes D202 and D203 ignores in tox and fix violations.

Change-Id: I97ef88c9cfd56774e47f789cbbcf8ccfe85d7737
2016-05-04 19:45:30 +00:00
Julien Danjou
14900dd683 httpclient: remove unused debug kwargs
This has been deprecated for a while and is now not even used anymore.

Indeed, nothing in the code use the attribute
keystoneclient.httpclient.HTTPClient.debug_log.
Furthermore, removing the debug keyword argument from the signature of
keystoneclient.httpclient.HTTPClient.__init__ has no impact since this
signature include **kwargs, which in Python means that you it will
accept any keyword-argument. Any code that would still pass the debug
argument to that method will therefore not notice any difference and
will not fail.

Change-Id: Iaae4febf3f13f6a66ad0e792dc2347b4699f65c0
2016-05-02 22:23:54 +00:00
Navid Pustchi
20e23f3e0d Fix D400 PEP257 violation.
Currently tox ignores D400.
D400: First line should end with a period.
This change removes it and make keystoneclient docstrings compliant with it.

Change-Id: I29ecb4c58bb03c0b9a3be0b7a74d18fb06a350f2
2016-04-23 17:47:25 +00:00
Navid Pustchi
946e928b52 Fix D401 PEP257 violation.
Currently tox ignores D401.
401: First line should be in imperative mood.
This change removes it and make keystoneclient docstrings compliant with it.

Change-Id: If34ff12d18390b357342cf29f2d116dd3c86a44d
2016-04-23 06:25:20 +00:00
Christopher J Schaefer
dbf4f31646 Removing bandit.yaml in favor of defaults
Removing old configuration options for build-in defaults of latest
bandit functionality. Also, marking flagged items with _# nosec_
with a descriptive comment on why the code is acceptable as is.

Co-Authored-By: Christopher J Schaefer <cjschaef@us.ibm.com>
Co-Authored-By: Tom Cocozzello <tjcocozz@us.ibm.com>

Change-Id: I138ebd46a8be195177361a9c3306bb70423b639d
2016-04-19 10:35:00 -05:00
Jenkins
80039aaf58 Merge "Deprecate adapter" 2016-02-12 03:42:15 +00:00
Jenkins
033c30f109 Merge "Remove python 2.5 workaround" 2016-02-04 02:16:26 +00:00
Jamie Lennox
2d7fa423ff Deprecate adapter
This involves switching keystoneclient to use the adapter on
keystoneauth.

Change-Id: I02780b0c00e3865f083b4bca98bff81127ed2277
Implements: bp deprecate-to-ksa
2016-02-03 12:08:07 +11:00
Brant Knudson
cc99324694 Remove python 2.5 workaround
keystoneclient doesn't support python 2.5 so remove this workaround
code. Messing with global variables is a mistake anyways.

Change-Id: I1567508cb1931b8c5365cfe6584e5a732c459db0
2016-01-31 08:51:51 -06:00
Brant Knudson
cc3aea176c Update keyring requirements
As of commit 05c2bcef the minimum keyring version is 5.5.1,
so update the version that httpclient will use.

Change-Id: I877b9d40b8bc4f89754d64d29d82a9e3a3f2dd04
2016-01-31 08:48:05 -06:00
Steve Martinelli
81fdaabf3f use positional library instead of utils
swap instances of utils.positional with the positional library.

Change-Id: Id8a9961e68d287a802f25512fc970829e9feb5c2
2016-01-25 01:54:35 -05:00
Jenkins
1b9c9853cd Merge "Address hacking check H405" 2016-01-23 04:17:01 +00:00
lin-hua-cheng
77ed0d4d0c Address hacking check H405
Previously, there were a string of commits to keystone that addresed ignored
hacking checks. This commit does the same for H405 in keystoneclient. This
also modifies our tox.ini so that we no longer ignore H405 violations.

Change-Id: I2af152e5425a0e9c82314039fdbb90d661c22680
Closes-Bug: 1482773
2016-01-13 13:03:51 -08:00
Jamie Lennox
65b348e945 Deprecate the baseclient.Client
We don't want to support other clients subclassing this. Deprecate it
for removal.

As far as I know noone else is using this class.

Change-Id: Iad0ea860bd07c657d7094018c037b003ea92dc28
Implements: bp deprecate-to-ksa
2015-12-17 12:04:17 +11:00
Brant Knudson
e76423f783 Proper deprecation for httpclient.USER_AGENT
httpclient's USER_AGENT constant wasn't properly deprecated since
the deprecation was only a comment. Proper deprecation requires use
of warnings/debtcollector and documentation, but since this is a
module symbol there's no way to put out a warning, so it's just
documentation in this case.

bp deprecations

Change-Id: I02c77c690a31eea40935d2756748382abec86867
2015-08-29 11:28:01 -05:00
Brant Knudson
42bd016e1f Deprecate create HTTPClient without session
The comments indicated that creating a HTTPClient without a
session is deprecated, but there was no warning generated.

bp deprecations

Change-Id: I44796cbff95a7bbdd6e7a58e5cfb8360bdae5477
2015-08-29 11:28:01 -05:00
Brant Knudson
58cc453b20 Proper deprecation for Session.construct()
Session.construct() wasn't properly deprecated since the deprecation
was only mentioned in the docstring. Proper deprecation requires use
of warnings/debtcollector and documentation.

bp deprecations

Change-Id: Ieff238aff9d39cfbbb80381b2392c33d0359acb3
2015-08-13 18:59:31 -05:00
Brant Knudson
803eb235d5 Deprecate ServiceCatalog(region_name)
There was a FIXME to deprecate ServiceCatalog's region_name
parameter and property. This is now deprecated.

Note that debtcollector isn't used here since the deprecation
happens on ServiceCatalog's __init__() to catch use in
subclasses of ServiceCatalog. ServiceCatalog also has a
factory function that constructs the correct instance and
the factory function always passes region_name, so it's
always using the deprecated kwarg even when region_name
isn't passed to the factory. It's not worth figuring out
how to do this with debtcollector.

bp deprecations

Change-Id: I0e64712474ca2767f3c0ade919359132450f6776
2015-08-13 18:57:31 -05:00
Brant Knudson
b54d9f122c Stop using .keys() on dicts where not needed
Iterating over a dict results in the keys.

Using the 'in' operator on a dict checks if it's a key.

Change-Id: I6affbfa1a79a9e8c0b5b304078a7a8e4e792eecd
2015-08-06 14:44:12 -05:00
Brant Knudson
eaa7ddd744 Proper deprecation for HTTPClient session and adapter properties
HTTPClient's forwarded session and adapter properties weren't
properly deprecated since the deprecations was only mentioned in
the docstring. Proper deprecation requires use of warnings/
debtcollector and documentation.

bp deprecations

Change-Id: Iea76d7bbc3bdeb13f7fdb097f13e007b4dd85c8d
2015-08-04 09:56:44 -05:00
Brant Knudson
0c2fef51d2 Proper deprecation for HTTPClient.request methods
HTTPClient.request and related methods weren't properly
deprecated since they were only mentioned in the docstrings.
Proper deprecation requires use of warnings/debtcollector and
documentation.

Also, fixed places where the deprecated request method was called.

bp deprecations

Change-Id: I0a16933252937ca046793bb6eb2e5cc5da03c9ae
2015-08-04 09:56:44 -05:00
Brant Knudson
ada04acf4d Proper deprecation for HTTPClient.tenant_id|name
HTTPClient tenant_id and tenant_name properties weren't properly
deprecated since they were only mentioned in the docstring. Proper
deprecation requires use of warnings/debtcollector and
documentation.

bp deprecations

Change-Id: I3c2f87df14bc9f8ffd82b99919fd1048123d0669
2015-08-04 09:56:44 -05:00
Brant Knudson
1721e01743 Proper deprecation for HTTPClient tenant_id, tenant_name parameters
HTTPClient() tenant_id and tenant_name parameters weren't properly
deprecated since they were only mentioned in the docstring. Proper
deprecation requires use of warnings/debtcollector and documentation.

Also fixed a bunch of places in the tests where tenant_id and
tenant_name were still being used despite being deprecated.

bp deprecations

Change-Id: I9c4f596b8ff10aede6c417886638a942cb18044c
2015-08-04 09:56:43 -05:00
Brant Knudson
9f17732308 Proper deprecation for httpclient.request()
httpclient.request() wasn't properly deprecated since it was only
mentioned in a comment. Proper deprecation requires use of
warnings/debtcollector and documentation.

bp deprecations

Change-Id: Id35d64a8b2d536c5de90e398b2a7680fa30881d6
2015-07-26 06:54:23 -05:00
Brant Knudson
66fd1eb748 Stop using deprecated AccessInfo.auth_url and management_url
The comments for the auth_url and management_url properties say
that they're deprecated and to use the service catalog, but
internal code was using the deprecated function. The
code needs to be changed to use non-deprecated function.

bp deprecations

Change-Id: I6ada821fe305650d22e58a55192332f0f4986537
2015-07-24 11:04:04 -05:00
Brant Knudson
86018ca864 tox env for Bandit
A tox env is created for the Bandit static code analyzer for
security.

bp bandit

Change-Id: I8c0178befec77fe3d29b411a15ceed9a020820b5
2015-06-03 21:01:18 -05:00
Brant Knudson
99e3b48a21 Adapter version is a tuple
The docstring for Adapter says that the version is a tuple like
(3,0), but the HttpClient was passing a string like "v3".

Closes-Bug: 1450272
Change-Id: I74b009d68f5601bda3ae92b3c8de1ecef00d8316
2015-04-30 01:28:34 +00:00
Brant Knudson
86ac254fee Change oslo.serialization to oslo_serialization
The oslo libraries are moving away from namespace packages.

bp drop-namespace-packages

Change-Id: I76dc9f733b222144f0274f8854877587c3501d1e
2015-01-31 08:03:37 -06:00
Jamie Lennox
4cc1631665 Allow fetching user_id/project_id from auth
This would ideally not be required however when building certain URLs
the current user_id is needed. And when communicating with certain
services we need to have access to the current project id. It seems
better to allow plugins to give up the information if they have it than
do various hacks to try and get it from them.

Change-Id: Ib61b0628702806268be623a9987a922a60b04165
Closes-Bug: #1364724
2015-01-05 09:56:40 +10:00
Jamie Lennox
28ea0a8e36 Pass all adapter parameters through to adapter
We can't simply pass through kwargs to the adapter for compatibility
reasons however make sure that we accept the appropriate arguments and
pass them to adapter.

Also add some notes to try and keep them up to date.

Closes-Bug: #1399492
Change-Id: If72295590483bb52fcf5a0d59cf95f3e49ea69c8
2014-12-05 14:21:39 +10:00
Brant Knudson
3c8d35247e Correct documenting constructor parameters
When the docs are rendered to HTML, any docs on __init__ are not
displayed. The parameters to the constructor have to be documented on
the class rather than on the __init__ method.

Also, corrected other minor issues in the same areas.

Change-Id: Ic56da33f6b99fe5efb636c289e3c4e1569f0c84c
2014-12-04 19:04:15 -06:00
Jamie Lennox
b0e68b06b3 Make keystoneclient use an adapter
Apart from making keystoneclient follow the same patterns of using an
adapter that we are trying to push onto other clients this severs the
cyclical dependency between managers and the client object.

There are a few changes that have had to be rolled into one to make the
transition work. These can't be separated unfortunately as they are
interdependent.

* managers are now passed the adapter instead of the client. They
  therefore don't have reference to the other managers on the client.
* The adapter has been subclassed to provide user_id as there are some
  managers that require user_id be provided for changing passwords etc.
* client.auth_url has been replaced with a call to get_endpoint which is
  supported by the adapter.
* management=True has been removed from all the managers and they now
  correctly set the interface they want.

Change-Id: I49fbd50571f0c1484e1cbc3dcb2159d25b21b1bc
2014-11-21 08:03:23 +10:00
Jenkins
2e900a9347 Merge "Cleanup docs - raises class" 2014-11-18 19:18:13 +00:00
Brant Knudson
fece74ca3e I18n
Keystoneclient didn't provide translated messages. With this
change, the messages are marked for translation.

DocImpact

Implements: blueprint keystoneclient-i18n

Change-Id: I85263a71671a1dffed524185266e6bb7ae559630
2014-10-28 20:33:19 +00:00
Jenkins
1750d14907 Merge "Prevent AttributeError if no authorization" 2014-10-27 00:20:37 +00:00