Skip to content

Commit 65b53c1

Browse files
authored
Merge pull request #432 from SimonRichardson/release-2.8.2
#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
2 parents 252dc15 + 0950e91 commit 65b53c1

20 files changed

Lines changed: 57840 additions & 518 deletions

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BIN := .tox/py3/bin
2-
PY := $(BIN)/python
3-
PIP := $(BIN)/pip
2+
PY := $(BIN)/python3
3+
PIP := $(BIN)/pip3
44
VERSION=$(shell cat VERSION)
55

66
.PHONY: clean
@@ -15,7 +15,8 @@ clean:
1515
tox -r --notest
1616

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

2122
.PHONY: test

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.8.1
1+
2.8.2

docs/changelog.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
---------
33

4+
2.8.2
5+
^^^^^
6+
7+
Tuesday July 14 2020
8+
9+
* Update facade methods for Juju 2.8.1
10+
* Add documentation to the client API methods (using the 2.8.1 changes)
11+
* Bug fix -Fixes application status being reported as unset (#430)
12+
* Bug fix - Handle Network Unreachable OSErrors (#426)
13+
414
2.8.1
515
^^^^^
616

juju/client/_client.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from juju.client._definitions import *
55

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

88

99
CLIENTS = {
@@ -20,7 +20,8 @@
2020
"12": _client12,
2121
"11": _client11,
2222
"13": _client13,
23-
"15": _client15
23+
"15": _client15,
24+
"16": _client16
2425
}
2526

2627

@@ -92,6 +93,10 @@ class ActionPrunerFacade(TypeFactory):
9293
pass
9394

9495

96+
class AdminFacade(TypeFactory):
97+
pass
98+
99+
95100
class AgentFacade(TypeFactory):
96101
pass
97102

@@ -152,6 +157,10 @@ class CAASFirewallerFacade(TypeFactory):
152157
pass
153158

154159

160+
class CAASModelOperatorFacade(TypeFactory):
161+
pass
162+
163+
155164
class CAASOperatorFacade(TypeFactory):
156165
pass
157166

@@ -228,6 +237,10 @@ class ExternalControllerUpdaterFacade(TypeFactory):
228237
pass
229238

230239

240+
class FacadeVersions(TypeFactory):
241+
pass
242+
243+
231244
class FanConfigurerFacade(TypeFactory):
232245
pass
233246

juju/client/_client1.py

Lines changed: 1715 additions & 161 deletions
Large diffs are not rendered by default.

juju/client/_client11.py

Lines changed: 2417 additions & 0 deletions
Large diffs are not rendered by default.

juju/client/_client12.py

Lines changed: 1870 additions & 0 deletions
Large diffs are not rendered by default.

juju/client/_client16.py

Lines changed: 3821 additions & 0 deletions
Large diffs are not rendered by default.

juju/client/_client2.py

Lines changed: 2127 additions & 163 deletions
Large diffs are not rendered by default.

juju/client/_client3.py

Lines changed: 190 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,187 @@ async def RunOnAllMachines(self, applications=None, commands=None, machines=None
451451

452452

453453

454+
class AdminFacade(Type):
455+
name = 'Admin'
456+
version = 3
457+
schema = {'definitions': {'Address': {'additionalProperties': False,
458+
'properties': {'scope': {'type': 'string'},
459+
'space-id': {'type': 'string'},
460+
'space-name': {'type': 'string'},
461+
'type': {'type': 'string'},
462+
'value': {'type': 'string'}},
463+
'required': ['value', 'type', 'scope'],
464+
'type': 'object'},
465+
'AuthUserInfo': {'additionalProperties': False,
466+
'properties': {'controller-access': {'type': 'string'},
467+
'credentials': {'type': 'string'},
468+
'display-name': {'type': 'string'},
469+
'identity': {'type': 'string'},
470+
'last-connection': {'format': 'date-time',
471+
'type': 'string'},
472+
'model-access': {'type': 'string'}},
473+
'required': ['display-name',
474+
'identity',
475+
'controller-access',
476+
'model-access'],
477+
'type': 'object'},
478+
'FacadeVersions': {'additionalProperties': False,
479+
'properties': {'name': {'type': 'string'},
480+
'versions': {'items': {'type': 'integer'},
481+
'type': 'array'}},
482+
'required': ['name', 'versions'],
483+
'type': 'object'},
484+
'HostPort': {'additionalProperties': False,
485+
'properties': {'Address': {'$ref': '#/definitions/Address'},
486+
'port': {'type': 'integer'},
487+
'scope': {'type': 'string'},
488+
'space-id': {'type': 'string'},
489+
'space-name': {'type': 'string'},
490+
'type': {'type': 'string'},
491+
'value': {'type': 'string'}},
492+
'required': ['value',
493+
'type',
494+
'scope',
495+
'Address',
496+
'port'],
497+
'type': 'object'},
498+
'LoginRequest': {'additionalProperties': False,
499+
'properties': {'auth-tag': {'type': 'string'},
500+
'bakery-version': {'type': 'integer'},
501+
'cli-args': {'type': 'string'},
502+
'credentials': {'type': 'string'},
503+
'macaroons': {'items': {'items': {'$ref': '#/definitions/Macaroon'},
504+
'type': 'array'},
505+
'type': 'array'},
506+
'nonce': {'type': 'string'},
507+
'user-data': {'type': 'string'}},
508+
'required': ['auth-tag',
509+
'credentials',
510+
'nonce',
511+
'macaroons',
512+
'user-data'],
513+
'type': 'object'},
514+
'LoginResult': {'additionalProperties': False,
515+
'properties': {'bakery-discharge-required': {'$ref': '#/definitions/Macaroon'},
516+
'controller-tag': {'type': 'string'},
517+
'discharge-required': {'$ref': '#/definitions/Macaroon'},
518+
'discharge-required-error': {'type': 'string'},
519+
'facades': {'items': {'$ref': '#/definitions/FacadeVersions'},
520+
'type': 'array'},
521+
'model-tag': {'type': 'string'},
522+
'public-dns-name': {'type': 'string'},
523+
'server-version': {'type': 'string'},
524+
'servers': {'items': {'items': {'$ref': '#/definitions/HostPort'},
525+
'type': 'array'},
526+
'type': 'array'},
527+
'user-info': {'$ref': '#/definitions/AuthUserInfo'}},
528+
'type': 'object'},
529+
'Macaroon': {'additionalProperties': False, 'type': 'object'},
530+
'RedirectInfoResult': {'additionalProperties': False,
531+
'properties': {'ca-cert': {'type': 'string'},
532+
'servers': {'items': {'items': {'$ref': '#/definitions/HostPort'},
533+
'type': 'array'},
534+
'type': 'array'}},
535+
'required': ['servers', 'ca-cert'],
536+
'type': 'object'}},
537+
'properties': {'Login': {'description': 'Login logs in with the provided '
538+
'credentials. All subsequent '
539+
'requests on the\n'
540+
'connection will act as the '
541+
'authenticated user.',
542+
'properties': {'Params': {'$ref': '#/definitions/LoginRequest'},
543+
'Result': {'$ref': '#/definitions/LoginResult'}},
544+
'type': 'object'},
545+
'RedirectInfo': {'description': 'RedirectInfo returns '
546+
'redirected host information '
547+
'for the model.\n'
548+
'In Juju it always returns an '
549+
'error because the Juju '
550+
'controller\n'
551+
'does not multiplex '
552+
'controllers.',
553+
'properties': {'Result': {'$ref': '#/definitions/RedirectInfoResult'}},
554+
'type': 'object'}},
555+
'type': 'object'}
556+
557+
558+
@ReturnMapping(LoginResult)
559+
async def Login(self, auth_tag=None, bakery_version=None, cli_args=None, credentials=None, macaroons=None, nonce=None, user_data=None):
560+
'''
561+
Login logs in with the provided credentials. All subsequent requests on the
562+
connection will act as the authenticated user.
563+
564+
auth_tag : str
565+
bakery_version : int
566+
cli_args : str
567+
credentials : str
568+
macaroons : typing.Sequence[~Macaroon]
569+
nonce : str
570+
user_data : str
571+
Returns -> LoginResult
572+
'''
573+
if auth_tag is not None and not isinstance(auth_tag, (bytes, str)):
574+
raise Exception("Expected auth_tag to be a str, received: {}".format(type(auth_tag)))
575+
576+
if bakery_version is not None and not isinstance(bakery_version, int):
577+
raise Exception("Expected bakery_version to be a int, received: {}".format(type(bakery_version)))
578+
579+
if cli_args is not None and not isinstance(cli_args, (bytes, str)):
580+
raise Exception("Expected cli_args to be a str, received: {}".format(type(cli_args)))
581+
582+
if credentials is not None and not isinstance(credentials, (bytes, str)):
583+
raise Exception("Expected credentials to be a str, received: {}".format(type(credentials)))
584+
585+
if macaroons is not None and not isinstance(macaroons, (bytes, str, list)):
586+
raise Exception("Expected macaroons to be a Sequence, received: {}".format(type(macaroons)))
587+
588+
if nonce is not None and not isinstance(nonce, (bytes, str)):
589+
raise Exception("Expected nonce to be a str, received: {}".format(type(nonce)))
590+
591+
if user_data is not None and not isinstance(user_data, (bytes, str)):
592+
raise Exception("Expected user_data to be a str, received: {}".format(type(user_data)))
593+
594+
# map input types to rpc msg
595+
_params = dict()
596+
msg = dict(type='Admin',
597+
request='Login',
598+
version=3,
599+
params=_params)
600+
_params['auth-tag'] = auth_tag
601+
_params['bakery-version'] = bakery_version
602+
_params['cli-args'] = cli_args
603+
_params['credentials'] = credentials
604+
_params['macaroons'] = macaroons
605+
_params['nonce'] = nonce
606+
_params['user-data'] = user_data
607+
reply = await self.rpc(msg)
608+
return reply
609+
610+
611+
612+
@ReturnMapping(RedirectInfoResult)
613+
async def RedirectInfo(self):
614+
'''
615+
RedirectInfo returns redirected host information for the model.
616+
In Juju it always returns an error because the Juju controller
617+
does not multiplex controllers.
618+
619+
620+
Returns -> RedirectInfoResult
621+
'''
622+
623+
# map input types to rpc msg
624+
_params = dict()
625+
msg = dict(type='Admin',
626+
request='RedirectInfo',
627+
version=3,
628+
params=_params)
629+
630+
reply = await self.rpc(msg)
631+
return reply
632+
633+
634+
454635
class ApplicationFacade(Type):
455636
name = 'Application'
456637
version = 3
@@ -3061,13 +3242,21 @@ async def WatchUnits(self, entities=None):
30613242
class ImageMetadataFacade(Type):
30623243
name = 'ImageMetadata'
30633244
version = 3
3064-
schema = {'properties': {'UpdateFromPublishedImages': {'type': 'object'}},
3245+
schema = {'properties': {'UpdateFromPublishedImages': {'description': 'UpdateFromPublishedImages '
3246+
'is now a no-op.\n'
3247+
'It is retained '
3248+
'for '
3249+
'compatibility.',
3250+
'type': 'object'}},
30653251
'type': 'object'}
30663252

30673253

30683254
@ReturnMapping(None)
30693255
async def UpdateFromPublishedImages(self):
30703256
'''
3257+
UpdateFromPublishedImages is now a no-op.
3258+
It is retained for compatibility.
3259+
30713260
30723261
Returns -> None
30733262
'''

0 commit comments

Comments
 (0)