Skip to content

Commit

Permalink
Merge pull request #931 from cderici/update-3.2-facade-clients
Browse files Browse the repository at this point in the history
#931

#### Description

This does 3 things:

1. Adds a tiny fix to suppress redundant warning messages about facade versions to be emitted in case the facade in question is not yet known to the pylibjuju client.
2. Adds the `AgentLifeFlag` to known facades ([reported in a nightly build](https://github.com/cderici/python-libjuju/actions/runs/5779670269/job/15662283086#step:8:383))
3. While we're at the facades, this adds the latest schema json from juju 3.2 branch and rebuilds the clients to keep the compatibility.

#### QA Steps

All CI tests need to pass.
  • Loading branch information
jujubot authored Aug 8, 2023
2 parents e4ea8ab + 0553044 commit 16b9c9b
Show file tree
Hide file tree
Showing 7 changed files with 52,483 additions and 71 deletions.
205 changes: 201 additions & 4 deletions juju/client/_client1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11451,7 +11451,46 @@ async def rpc(self, msg):
class UndertakerFacade(Type):
name = 'Undertaker'
version = 1
schema = {'definitions': {'EntityStatusArgs': {'additionalProperties': False,
schema = {'definitions': {'CloudCredential': {'additionalProperties': False,
'properties': {'attrs': {'patternProperties': {'.*': {'type': 'string'}},
'type': 'object'},
'auth-type': {'type': 'string'},
'redacted': {'items': {'type': 'string'},
'type': 'array'}},
'required': ['auth-type'],
'type': 'object'},
'CloudSpec': {'additionalProperties': False,
'properties': {'cacertificates': {'items': {'type': 'string'},
'type': 'array'},
'credential': {'$ref': '#/definitions/CloudCredential'},
'endpoint': {'type': 'string'},
'identity-endpoint': {'type': 'string'},
'is-controller-cloud': {'type': 'boolean'},
'name': {'type': 'string'},
'region': {'type': 'string'},
'skip-tls-verify': {'type': 'boolean'},
'storage-endpoint': {'type': 'string'},
'type': {'type': 'string'}},
'required': ['type', 'name'],
'type': 'object'},
'CloudSpecResult': {'additionalProperties': False,
'properties': {'error': {'$ref': '#/definitions/Error'},
'result': {'$ref': '#/definitions/CloudSpec'}},
'type': 'object'},
'CloudSpecResults': {'additionalProperties': False,
'properties': {'results': {'items': {'$ref': '#/definitions/CloudSpecResult'},
'type': 'array'}},
'type': 'object'},
'Entities': {'additionalProperties': False,
'properties': {'entities': {'items': {'$ref': '#/definitions/Entity'},
'type': 'array'}},
'required': ['entities'],
'type': 'object'},
'Entity': {'additionalProperties': False,
'properties': {'tag': {'type': 'string'}},
'required': ['tag'],
'type': 'object'},
'EntityStatusArgs': {'additionalProperties': False,
'properties': {'data': {'patternProperties': {'.*': {'additionalProperties': True,
'type': 'object'}},
'type': 'object'},
Expand Down Expand Up @@ -11485,6 +11524,7 @@ class UndertakerFacade(Type):
'type': 'object'}},
'required': ['config'],
'type': 'object'},
'ModelTag': {'additionalProperties': False, 'type': 'object'},
'NotifyWatchResult': {'additionalProperties': False,
'properties': {'NotifyWatcherId': {'type': 'string'},
'error': {'$ref': '#/definitions/Error'}},
Expand Down Expand Up @@ -11519,8 +11559,19 @@ class UndertakerFacade(Type):
'result': {'$ref': '#/definitions/UndertakerModelInfo'}},
'required': ['result'],
'type': 'object'}},
'properties': {'ModelConfig': {'description': 'ModelConfig returns the '
"model's configuration.",
'properties': {'CloudSpec': {'description': "CloudSpec returns the model's "
'cloud spec.',
'properties': {'Params': {'$ref': '#/definitions/Entities'},
'Result': {'$ref': '#/definitions/CloudSpecResults'}},
'type': 'object'},
'GetCloudSpec': {'description': 'GetCloudSpec constructs the '
'CloudSpec for a validated and '
'authorized model.',
'properties': {'Params': {'$ref': '#/definitions/ModelTag'},
'Result': {'$ref': '#/definitions/CloudSpecResult'}},
'type': 'object'},
'ModelConfig': {'description': 'ModelConfig returns the '
"current model's configuration.",
'properties': {'Result': {'$ref': '#/definitions/ModelConfigResult'}},
'type': 'object'},
'ModelInfo': {'description': 'ModelInfo returns information on '
Expand All @@ -11545,6 +11596,39 @@ class UndertakerFacade(Type):
'properties': {'Params': {'$ref': '#/definitions/SetStatus'},
'Result': {'$ref': '#/definitions/ErrorResults'}},
'type': 'object'},
'WatchCloudSpecsChanges': {'description': 'WatchCloudSpecsChanges '
'returns a watcher '
'for cloud spec '
'changes.',
'properties': {'Params': {'$ref': '#/definitions/Entities'},
'Result': {'$ref': '#/definitions/NotifyWatchResults'}},
'type': 'object'},
'WatchForModelConfigChanges': {'description': 'WatchForModelConfigChanges '
'returns a '
'NotifyWatcher '
'that observes\n'
'changes to the '
'model '
'configuration.\n'
'Note that '
'although the '
'NotifyWatchResult '
'contains an '
'Error field,\n'
"it's not used "
'because we are '
'only returning '
'a single '
'watcher,\n'
'so we use the '
'regular error '
'return.',
'properties': {'Result': {'$ref': '#/definitions/NotifyWatchResult'}},
'type': 'object'},
'WatchModel': {'description': 'WatchModel creates a watcher '
'for the current model.',
'properties': {'Result': {'$ref': '#/definitions/NotifyWatchResults'}},
'type': 'object'},
'WatchModelResources': {'description': 'WatchModelResources '
'creates watchers for '
'changes to the '
Expand All @@ -11557,10 +11641,54 @@ class UndertakerFacade(Type):
'type': 'object'}


@ReturnMapping(CloudSpecResults)
async def CloudSpec(self, entities=None):
'''
CloudSpec returns the model's cloud spec.

entities : typing.Sequence[~Entity]
Returns -> CloudSpecResults
'''
if entities is not None and not isinstance(entities, (bytes, str, list)):
raise Exception("Expected entities to be a Sequence, received: {}".format(type(entities)))

# map input types to rpc msg
_params = dict()
msg = dict(type='Undertaker',
request='CloudSpec',
version=1,
params=_params)
_params['entities'] = entities
reply = await self.rpc(msg)
return reply



@ReturnMapping(CloudSpecResult)
async def GetCloudSpec(self):
'''
GetCloudSpec constructs the CloudSpec for a validated and authorized model.


Returns -> CloudSpecResult
'''

# map input types to rpc msg
_params = dict()
msg = dict(type='Undertaker',
request='GetCloudSpec',
version=1,
params=_params)

reply = await self.rpc(msg)
return reply



@ReturnMapping(ModelConfigResult)
async def ModelConfig(self):
'''
ModelConfig returns the model's configuration.
ModelConfig returns the current model's configuration.


Returns -> ModelConfigResult
Expand Down Expand Up @@ -11665,6 +11793,75 @@ async def SetStatus(self, entities=None):



@ReturnMapping(NotifyWatchResults)
async def WatchCloudSpecsChanges(self, entities=None):
'''
WatchCloudSpecsChanges returns a watcher for cloud spec changes.

entities : typing.Sequence[~Entity]
Returns -> NotifyWatchResults
'''
if entities is not None and not isinstance(entities, (bytes, str, list)):
raise Exception("Expected entities to be a Sequence, received: {}".format(type(entities)))

# map input types to rpc msg
_params = dict()
msg = dict(type='Undertaker',
request='WatchCloudSpecsChanges',
version=1,
params=_params)
_params['entities'] = entities
reply = await self.rpc(msg)
return reply



@ReturnMapping(NotifyWatchResult)
async def WatchForModelConfigChanges(self):
'''
WatchForModelConfigChanges returns a NotifyWatcher that observes
changes to the model configuration.
Note that although the NotifyWatchResult contains an Error field,
it's not used because we are only returning a single watcher,
so we use the regular error return.


Returns -> NotifyWatchResult
'''

# map input types to rpc msg
_params = dict()
msg = dict(type='Undertaker',
request='WatchForModelConfigChanges',
version=1,
params=_params)

reply = await self.rpc(msg)
return reply



@ReturnMapping(NotifyWatchResults)
async def WatchModel(self):
'''
WatchModel creates a watcher for the current model.


Returns -> NotifyWatchResults
'''

# map input types to rpc msg
_params = dict()
msg = dict(type='Undertaker',
request='WatchModel',
version=1,
params=_params)

reply = await self.rpc(msg)
return reply



@ReturnMapping(NotifyWatchResults)
async def WatchModelResources(self):
'''
Expand Down
13 changes: 9 additions & 4 deletions juju/client/_client18.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ class ApplicationFacade(Type):
'properties': {'ApplicationOfferDetails': {'$ref': '#/definitions/ApplicationOfferDetails'},
'application-alias': {'type': 'string'},
'application-description': {'type': 'string'},
'auth-token': {'type': 'string'},
'bindings': {'patternProperties': {'.*': {'type': 'string'}},
'type': 'object'},
'endpoints': {'items': {'$ref': '#/definitions/RemoteEndpoint'},
Expand Down Expand Up @@ -2539,8 +2538,9 @@ class UniterFacade(Type):
'type': 'object'},
'SecretBackendArgs': {'additionalProperties': False,
'properties': {'backend-ids': {'items': {'type': 'string'},
'type': 'array'}},
'required': ['backend-ids'],
'type': 'array'},
'for-drain': {'type': 'boolean'}},
'required': ['for-drain', 'backend-ids'],
'type': 'object'},
'SecretBackendConfig': {'additionalProperties': False,
'properties': {'params': {'patternProperties': {'.*': {'additionalProperties': True,
Expand Down Expand Up @@ -4597,23 +4597,28 @@ async def GetRawK8sSpec(self, entities=None):


@ReturnMapping(SecretBackendConfigResults)
async def GetSecretBackendConfigs(self, backend_ids=None):
async def GetSecretBackendConfigs(self, backend_ids=None, for_drain=None):
'''
GetSecretBackendConfigs gets the config needed to create a client to secret backends.
backend_ids : typing.Sequence[str]
for_drain : bool
Returns -> SecretBackendConfigResults
'''
if backend_ids is not None and not isinstance(backend_ids, (bytes, str, list)):
raise Exception("Expected backend_ids to be a Sequence, received: {}".format(type(backend_ids)))

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

# map input types to rpc msg
_params = dict()
msg = dict(type='Uniter',
request='GetSecretBackendConfigs',
version=18,
params=_params)
_params['backend-ids'] = backend_ids
_params['for-drain'] = for_drain
reply = await self.rpc(msg)
return reply

Expand Down
Loading

0 comments on commit 16b9c9b

Please sign in to comment.