+
+ TODO::
+
+ - entity_url must have a revision; look up latest automatically if
+ not provided by caller
+ - service_name is required; fill this in automatically if not
+ provided by caller
+ - series is required; how do we pick a default?
+
+ """
+ if constraints:
+ constraints = client.Value(**constraints)
+
+ if to:
+ placement = [
+ client.Placement(**p) for p in to
+ ]
+ else:
+ placement = []
+
+ if storage:
+ storage = {
+ k: client.Constraints(**v)
+ for k, v in storage.items()
+ }
+
+ app_facade = client.ApplicationFacade()
+ client_facade = client.ClientFacade()
+ app_facade.connect(self.connection)
+ client_facade.connect(self.connection)
+
+ log.debug(
+ 'Deploying %s', entity_url)
+
+ await client_facade.AddCharm(channel, entity_url)
+ app = client.ApplicationDeploy(
+ application=service_name,
+ channel=channel,
+ charm_url=entity_url,
+ config=config,
+ constraints=constraints,
+ endpoint_bindings=bind,
+ num_units=num_units,
+ placement=placement,
+ resources=resources,
+ series=series,
+ storage=storage,
+ )
+
+ return await app_facade.Deploy([app])