Skip to content

Commit

Permalink
Merge pull request #432 from SimonRichardson/release-2.8.2
Browse files Browse the repository at this point in the history
#432

The following updates the schema as described by[1]. Additionally with
the new schema changes, I've also wired up schema method description to
the output of the client methods. The methods should be now more user
friendly towards developers.

Additional work around bumping version numbers and releases.

1. https://discourse.juju.is/t/python-libjuju/1553
  • Loading branch information
jujubot authored Jul 14, 2020
2 parents 252dc15 + 0950e91 commit 65b53c1
Show file tree
Hide file tree
Showing 20 changed files with 57,840 additions and 518 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BIN := .tox/py3/bin
PY := $(BIN)/python
PIP := $(BIN)/pip
PY := $(BIN)/python3
PIP := $(BIN)/pip3
VERSION=$(shell cat VERSION)

.PHONY: clean
Expand All @@ -15,7 +15,8 @@ clean:
tox -r --notest

.PHONY: client
client: .tox
client:
tox -r --notest -e lint,py38
$(PY) -m juju.client.facade -s "juju/client/schemas*" -o juju/client/

.PHONY: test
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.1
2.8.2
10 changes: 10 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
---------

2.8.2
^^^^^

Tuesday July 14 2020

* Update facade methods for Juju 2.8.1
* Add documentation to the client API methods (using the 2.8.1 changes)
* Bug fix -Fixes application status being reported as unset (#430)
* Bug fix - Handle Network Unreachable OSErrors (#426)

2.8.1
^^^^^

Expand Down
17 changes: 15 additions & 2 deletions juju/client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from juju.client._definitions import *

from juju.client import _client2, _client1, _client3, _client4, _client5, _client8, _client7, _client9, _client10, _client6, _client12, _client11, _client13, _client15
from juju.client import _client2, _client1, _client3, _client4, _client5, _client8, _client7, _client9, _client10, _client6, _client12, _client11, _client13, _client15, _client16


CLIENTS = {
Expand All @@ -20,7 +20,8 @@
"12": _client12,
"11": _client11,
"13": _client13,
"15": _client15
"15": _client15,
"16": _client16
}


Expand Down Expand Up @@ -92,6 +93,10 @@ class ActionPrunerFacade(TypeFactory):
pass


class AdminFacade(TypeFactory):
pass


class AgentFacade(TypeFactory):
pass

Expand Down Expand Up @@ -152,6 +157,10 @@ class CAASFirewallerFacade(TypeFactory):
pass


class CAASModelOperatorFacade(TypeFactory):
pass


class CAASOperatorFacade(TypeFactory):
pass

Expand Down Expand Up @@ -228,6 +237,10 @@ class ExternalControllerUpdaterFacade(TypeFactory):
pass


class FacadeVersions(TypeFactory):
pass


class FanConfigurerFacade(TypeFactory):
pass

Expand Down
1,876 changes: 1,715 additions & 161 deletions juju/client/_client1.py

Large diffs are not rendered by default.

2,417 changes: 2,417 additions & 0 deletions juju/client/_client11.py

Large diffs are not rendered by default.

1,870 changes: 1,870 additions & 0 deletions juju/client/_client12.py

Large diffs are not rendered by default.

3,821 changes: 3,821 additions & 0 deletions juju/client/_client16.py

Large diffs are not rendered by default.

2,290 changes: 2,127 additions & 163 deletions juju/client/_client2.py

Large diffs are not rendered by default.

191 changes: 190 additions & 1 deletion juju/client/_client3.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,187 @@ async def RunOnAllMachines(self, applications=None, commands=None, machines=None



class AdminFacade(Type):
name = 'Admin'
version = 3
schema = {'definitions': {'Address': {'additionalProperties': False,
'properties': {'scope': {'type': 'string'},
'space-id': {'type': 'string'},
'space-name': {'type': 'string'},
'type': {'type': 'string'},
'value': {'type': 'string'}},
'required': ['value', 'type', 'scope'],
'type': 'object'},
'AuthUserInfo': {'additionalProperties': False,
'properties': {'controller-access': {'type': 'string'},
'credentials': {'type': 'string'},
'display-name': {'type': 'string'},
'identity': {'type': 'string'},
'last-connection': {'format': 'date-time',
'type': 'string'},
'model-access': {'type': 'string'}},
'required': ['display-name',
'identity',
'controller-access',
'model-access'],
'type': 'object'},
'FacadeVersions': {'additionalProperties': False,
'properties': {'name': {'type': 'string'},
'versions': {'items': {'type': 'integer'},
'type': 'array'}},
'required': ['name', 'versions'],
'type': 'object'},
'HostPort': {'additionalProperties': False,
'properties': {'Address': {'$ref': '#/definitions/Address'},
'port': {'type': 'integer'},
'scope': {'type': 'string'},
'space-id': {'type': 'string'},
'space-name': {'type': 'string'},
'type': {'type': 'string'},
'value': {'type': 'string'}},
'required': ['value',
'type',
'scope',
'Address',
'port'],
'type': 'object'},
'LoginRequest': {'additionalProperties': False,
'properties': {'auth-tag': {'type': 'string'},
'bakery-version': {'type': 'integer'},
'cli-args': {'type': 'string'},
'credentials': {'type': 'string'},
'macaroons': {'items': {'items': {'$ref': '#/definitions/Macaroon'},
'type': 'array'},
'type': 'array'},
'nonce': {'type': 'string'},
'user-data': {'type': 'string'}},
'required': ['auth-tag',
'credentials',
'nonce',
'macaroons',
'user-data'],
'type': 'object'},
'LoginResult': {'additionalProperties': False,
'properties': {'bakery-discharge-required': {'$ref': '#/definitions/Macaroon'},
'controller-tag': {'type': 'string'},
'discharge-required': {'$ref': '#/definitions/Macaroon'},
'discharge-required-error': {'type': 'string'},
'facades': {'items': {'$ref': '#/definitions/FacadeVersions'},
'type': 'array'},
'model-tag': {'type': 'string'},
'public-dns-name': {'type': 'string'},
'server-version': {'type': 'string'},
'servers': {'items': {'items': {'$ref': '#/definitions/HostPort'},
'type': 'array'},
'type': 'array'},
'user-info': {'$ref': '#/definitions/AuthUserInfo'}},
'type': 'object'},
'Macaroon': {'additionalProperties': False, 'type': 'object'},
'RedirectInfoResult': {'additionalProperties': False,
'properties': {'ca-cert': {'type': 'string'},
'servers': {'items': {'items': {'$ref': '#/definitions/HostPort'},
'type': 'array'},
'type': 'array'}},
'required': ['servers', 'ca-cert'],
'type': 'object'}},
'properties': {'Login': {'description': 'Login logs in with the provided '
'credentials. All subsequent '
'requests on the\n'
'connection will act as the '
'authenticated user.',
'properties': {'Params': {'$ref': '#/definitions/LoginRequest'},
'Result': {'$ref': '#/definitions/LoginResult'}},
'type': 'object'},
'RedirectInfo': {'description': 'RedirectInfo returns '
'redirected host information '
'for the model.\n'
'In Juju it always returns an '
'error because the Juju '
'controller\n'
'does not multiplex '
'controllers.',
'properties': {'Result': {'$ref': '#/definitions/RedirectInfoResult'}},
'type': 'object'}},
'type': 'object'}


@ReturnMapping(LoginResult)
async def Login(self, auth_tag=None, bakery_version=None, cli_args=None, credentials=None, macaroons=None, nonce=None, user_data=None):
'''
Login logs in with the provided credentials. All subsequent requests on the
connection will act as the authenticated user.
auth_tag : str
bakery_version : int
cli_args : str
credentials : str
macaroons : typing.Sequence[~Macaroon]
nonce : str
user_data : str
Returns -> LoginResult
'''
if auth_tag is not None and not isinstance(auth_tag, (bytes, str)):
raise Exception("Expected auth_tag to be a str, received: {}".format(type(auth_tag)))

if bakery_version is not None and not isinstance(bakery_version, int):
raise Exception("Expected bakery_version to be a int, received: {}".format(type(bakery_version)))

if cli_args is not None and not isinstance(cli_args, (bytes, str)):
raise Exception("Expected cli_args to be a str, received: {}".format(type(cli_args)))

if credentials is not None and not isinstance(credentials, (bytes, str)):
raise Exception("Expected credentials to be a str, received: {}".format(type(credentials)))

if macaroons is not None and not isinstance(macaroons, (bytes, str, list)):
raise Exception("Expected macaroons to be a Sequence, received: {}".format(type(macaroons)))

if nonce is not None and not isinstance(nonce, (bytes, str)):
raise Exception("Expected nonce to be a str, received: {}".format(type(nonce)))

if user_data is not None and not isinstance(user_data, (bytes, str)):
raise Exception("Expected user_data to be a str, received: {}".format(type(user_data)))

# map input types to rpc msg
_params = dict()
msg = dict(type='Admin',
request='Login',
version=3,
params=_params)
_params['auth-tag'] = auth_tag
_params['bakery-version'] = bakery_version
_params['cli-args'] = cli_args
_params['credentials'] = credentials
_params['macaroons'] = macaroons
_params['nonce'] = nonce
_params['user-data'] = user_data
reply = await self.rpc(msg)
return reply



@ReturnMapping(RedirectInfoResult)
async def RedirectInfo(self):
'''
RedirectInfo returns redirected host information for the model.
In Juju it always returns an error because the Juju controller
does not multiplex controllers.
Returns -> RedirectInfoResult
'''

# map input types to rpc msg
_params = dict()
msg = dict(type='Admin',
request='RedirectInfo',
version=3,
params=_params)

reply = await self.rpc(msg)
return reply



class ApplicationFacade(Type):
name = 'Application'
version = 3
Expand Down Expand Up @@ -3061,13 +3242,21 @@ async def WatchUnits(self, entities=None):
class ImageMetadataFacade(Type):
name = 'ImageMetadata'
version = 3
schema = {'properties': {'UpdateFromPublishedImages': {'type': 'object'}},
schema = {'properties': {'UpdateFromPublishedImages': {'description': 'UpdateFromPublishedImages '
'is now a no-op.\n'
'It is retained '
'for '
'compatibility.',
'type': 'object'}},
'type': 'object'}


@ReturnMapping(None)
async def UpdateFromPublishedImages(self):
'''
UpdateFromPublishedImages is now a no-op.
It is retained for compatibility.
Returns -> None
'''
Expand Down
Loading

0 comments on commit 65b53c1

Please sign in to comment.