Skip to content

Commit

Permalink
Merge branch 'release-v3.6.0'
Browse files Browse the repository at this point in the history
* release-v3.6.0:
  Fix broken links
  Version translation update, fix invalid ID reference, fix StringIO compatibility
  Fix query giving unnecessary warning
  Update copyright
  Add latest CWOM identifiers Add entity actions support
  • Loading branch information
rastern committed Jun 14, 2021
2 parents 4cea5ed + 69c698a commit e69498a
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.5.3
current_version = 3.6.0
commit = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<build>\d*))?
serialize =
Expand Down
8 changes: 4 additions & 4 deletions docs/source/advancedguide.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.. # Links
.. _API: https://greencircle.vmturbo.com/community/products/pages/documentation
.. _API: https://support-turbonomic.force.com/TurbonomicCustomerCommunity/s/documentation
.. _cryptography: https://pypi.org/project/cryptography/
.. _Fernet: https://github.com/fernet/spec/blob/master/Spec.md
.. _jq: https://stedolan.github.io/jq/
.. _jq python: https://pypi.org/project/jq/
.. _jq script: https://stedolan.github.io/jq/manual/
.. _Turbonomic: https://www.turbonomic.com
.. _Requests: https://requests.readthedocs.io/en/master/
.. _proxies: https://requests.readthedocs.io/en/master/user/advanced/#proxies
.. _RFC 2732: https://tools.ietf.org/html/rfc2732
.. _Requests: https://docs.python-requests.org/en/master/
.. _proxies: https://docs.python-requests.org/en/master/user/advanced/#proxies
.. _RFC 2732: https://datatracker.ietf.org/doc/html/rfc2732

==============
Advanced Usage
Expand Down
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@

# General information about the project.
project = u'vmt-connect'
copyright = u'2017-2020'
copyright = u'2017-2021'
author = u'R.A. Stern'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'3.5.3'
version = u'3.6.0'
# The full version, including alpha/beta/rc tags.
release = u'3.5.3'
release = u'3.6.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sphinx-quickstart on Tue Jul 18 10:49:54 2017.
.. # Links
.. _APIs: https://greencircle.vmturbo.com/community/products/pages/documentation
.. _APIs: https://support-turbonomic.force.com/TurbonomicCustomerCommunity/s/documentation
.. _Turbonomic: https://www.turbonomic.com

==================================
Expand Down
11 changes: 6 additions & 5 deletions docs/source/start.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.. # Links
.. _CPython: https://www.python.org/
.. _PyPi: http://pypi.org/
.. _Requests: https://requests.readthedocs.io/en/master/
.. _Requests: https://docs.python-requests.org/en/master/
.. _IronPython: http://http://ironpython.net/
.. _GitHub: https://github.com/turbonomic/vmt-connect
.. _releases: https://github.com/turbonomic/vmt-connect/releases
.. _Apache 2.0: https://github.com/turbonomic/vmt-connect/blob/master/LICENSE
.. _Apache 2.0: https://www.apache.org/licenses/LICENSE-2.0.txt
.. _Turbonomic: https://www.turbonomic.com

===============
Expand Down Expand Up @@ -63,7 +63,7 @@ However, you may find it more useful to alias the import
Source Code
===========

*vmt-connect* is now an official Turbonomic_ Open Source project. The source code
*vmt-connect* is an official Turbonomic_ Open Source project. The source code
continues to be hosted on GitHub_.

Individual release archives may be found `here`__.
Expand All @@ -87,8 +87,9 @@ Turbonomic REST API Guides
==========================

The following published user guides are available to aid in developing against
the Turbonomic API. Additional resources are availble at https://docs.turbonomic.com/.
the Turbonomic REST API. Additional resources are available on the `Turbonomic Documentation <https://support-turbonomic.force.com/TurbonomicCustomerCommunity/s/documentation>`_ website.

* `XL 8.1.0 <https://docs.turbonomic.com/pdfdocs/Turbonomic_API_PRINT_8.1.0.pdf>`_
* `XL 8.0.1 <https://docs.turbonomic.com/docApp/doc/index.html?config=8.0.json#!/MAPPED&DEFAULT_DEDICATED_XL&showToc=1>`_
* `XL 7.22.2 <https://docs.turbonomic.com/pdfdocs/Turbonomic_User_Guide_7.21.2.pdf>`_
* `Unofficial User Guide <http://rsnyc.sdf.org/vmt/>`_ for 6.0.
Expand All @@ -99,4 +100,4 @@ License
=======

*vmt-connect* is distributed under the `Apache 2.0`_ software license, which may
also be obtained from the Apache Software Foundation, http://www.apache.org/licenses/LICENSE-2.0
also be obtained from the Apache Software Foundation, https://www.apache.org/licenses/LICENSE-2.0.txt
2 changes: 1 addition & 1 deletion docs/source/userguide.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. # Links
.. _API: https://greencircle.vmturbo.com/community/products/pages/documentation
.. _API: https://support-turbonomic.force.com/TurbonomicCustomerCommunity/s/documentation
.. _Turbonomic: https://www.turbonomic.com

================
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
here = os.path.abspath(os.path.dirname(__file__))
requires = [
'cryptography>=3,<4',
'ijson>=3.1.post0,<4',
'requests>=2.24.0,<3'
'ijson>=3.1.4,<4',
'requests>=2.25.1,<3'
]

extra_requires = {
'jq': ['jq>=1.0.2,<2']
'jq': ['jq>=1.1.3,<2']
}


Expand Down
4 changes: 2 additions & 2 deletions vmtconnect/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

__title__ = 'vmtconnect'
__description__ = 'Turbonomic API Client'
__version__ = '3.5.3'
__version__ = '3.6.0'
__author__ = 'R.A. Stern'
__author_email__ = 'richard.stern@turbonomic.com'
__license__ = 'Apache 2.0'
__copyright__ = 'Copyright 2017-2020 R.A. Stern'
__copyright__ = 'Copyright 2017-2021 R.A. Stern'
40 changes: 33 additions & 7 deletions vmtconnect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017-2020 R.A. Stern
# Copyright 2017-2021 R.A. Stern
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -657,7 +657,7 @@ class Connection:
Each of these override the connection global property, and will be safely
ignored if the endpoint does not support, or does not require paging the
results. Additionally, you may pass :py:class:`requests.Request` keyword
arguments to each call if required (e.g. `timeout <https://requests.readthedocs.io/en/master/user/quickstart/#timeouts>`_).
arguments to each call if required (e.g. `timeout <https://docs.python-requests.org/en/master/user/quickstart/#timeouts>`_).
Care should be taken, as some parameters will break *vmt-connect* calls if they
conflict with existing headers, or alter expected results.
Expand Down Expand Up @@ -857,8 +857,12 @@ def version(self):

def __login(self):
u, p = (base64.b64decode(self.__basic_auth)).decode().split(':', maxsplit=1)
body = {'username': (None, u), 'password': (None, p)}
self.request('login', 'POST', disable_hateoas=False, content_type=None, files=body, allow_redirects=False)
self.request('login',
'POST',
disable_hateoas=False,
content_type=None,
files={'username': (None, u), 'password': (None, p)},
allow_redirects=False)

def __use_session(self, value):
if value:
Expand Down Expand Up @@ -1067,7 +1071,7 @@ def request(self, path, method='GET', query='', dto=None, **kwargs):
except KeyError:
pass

if isinstance(query, str):
if query and isinstance(query, str):
msg = 'Query parameters should be passed in as a dictionary.'
warnings.warn(msg, DeprecationWarning)

Expand Down Expand Up @@ -1172,7 +1176,7 @@ def get_cached_inventory(self, id, uuid=None, **kwargs):
elif id == '__group_members':
self.__inventory_cache[id]['data'] = self.request(f'groups/{uuid}/members', **kwargs)
else:
self.__inventory_cache[id]['data'] = self.request(f'markets/{id}/entities', fetch_all=True, **kwargs)
self.__inventory_cache[id]['data'] = self.request(f'markets/{uuid}/entities', fetch_all=True, **kwargs)

delta = datetime.timedelta(seconds=self.__inventory_cache_timeout)
self.__inventory_cache[id]['expires'] = datetime.datetime.now() + delta
Expand Down Expand Up @@ -1411,6 +1415,17 @@ def get_entity_cluster(self, uuid, cache=False, **kwargs):
if uuid == vm['uuid']:
return c

def get_entity_actions(self, uuid, **kwargs):
"""Returns a list of entity actions.
Args:
uuid (str): Entity UUID.
Returns:
A list containing all actions for the given the entity.
"""
return self.request(f'entities/{uuid}/actions', **kwargs)

def get_entity_groups(self, uuid, **kwargs):
"""Returns a list of groups the entity belongs to.
Expand Down Expand Up @@ -1511,7 +1526,7 @@ def get_groups(self, uuid=None, cache=False, **kwargs):

return self.request('groups', uuid=uuid, **kwargs)

def get_group_actions(self, uuid=None, **kwargs):
def get_group_actions(self, uuid, **kwargs):
"""Returns a list of group actions.
Args:
Expand Down Expand Up @@ -1654,6 +1669,17 @@ def get_targets(self, uuid=None, **kwargs):
"""
return self.request('targets', uuid=uuid, **kwargs)

def get_target_actions(self, uuid, **kwargs):
"""Returns a list actions on a target.
Args:
uuid (str): Entity UUID.
Returns:
A list containing all actions for entities of the given the target.
"""
return self.request(f'targets/{uuid}/actions', **kwargs)

def get_target_for_entity(self, uuid=None, name=None,
type='VirtualMachine', **kwargs):
"""Returns a list of templates.
Expand Down
5 changes: 3 additions & 2 deletions vmtconnect/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from collections import defaultdict
from copy import deepcopy
from decimal import Decimal
from io import StringIO
from io import StringIO, BytesIO
import re


Expand Down Expand Up @@ -237,7 +237,8 @@ def apply(_s, _f):
out = [None] * size
idx = 0

for x in ijson.items(StringIO(source), 'item', use_float=use_float):
# to remove ijson BytesIO warning
for x in ijson.items(BytesIO(source.encode('utf-8')), 'item', use_float=use_float):
if idx >= len(out):
out.extend([None] * size)

Expand Down
8 changes: 7 additions & 1 deletion vmtconnect/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
'2.3.26': '6.4.30',
'2.3.27': '6.4.31',
'2.3.28': '6.4.32',
'2.3.29': '6.4.33'
'2.3.29': '6.4.33',
'2.3.30': '6.4.34',
'2.3.31': '6.4.35',
'2.3.32': '6.4.36',
'2.3.33': '6.4.37',
'2.3.34': '6.4.38',
'3.0.1': '8.2.1'
}
}

0 comments on commit e69498a

Please sign in to comment.