Skip to content

Commit 5e7d1eb

Browse files
committed
Add some docstrings for model.py
1 parent 9db01d8 commit 5e7d1eb

1 file changed

Lines changed: 41 additions & 4 deletions

File tree

juju/model.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,17 +1675,15 @@ async def deploy(
16751675
'24/lxd/3' - place in container 3 on machine 24
16761676
16771677
If None, a new machine is provisioned.
1678+
:param devices: charm device constraints
16781679
:param bool trust: Trust signifies that the charm should be deployed
16791680
with access to trusted credentials. Hooks run by the charm can access
16801681
cloud credentials and other trusted access credentials.
16811682
16821683
:param str[] attach_storage: Existing storage to attach to the deployed unit
16831684
(not available on k8s models)
1684-
TODO::
1685-
1686-
- support local file resources
1687-
16881685
"""
1686+
16891687
if storage:
16901688
storage = {
16911689
k: client.Constraints(**v)
@@ -1817,6 +1815,15 @@ async def deploy(
18171815
)
18181816

18191817
async def _add_charm(self, charm_url, origin):
1818+
"""_add_charm sends the given origin and the url to the Juju API too add the charm to the
1819+
state. Either calls the CharmsFacade.AddCharm for (> version 2), or the
1820+
ClientFacade.AddCharm (for older versions).
1821+
1822+
:param str charm_url: the url of the charm to be added
1823+
:param client.CharmOrigin origin: the origin for the charm to be added
1824+
1825+
:returns client.CharmOriginResult
1826+
"""
18201827
# client facade is deprecated with in Juju, and smaller, more focused
18211828
# facades have been created and we'll use that if it's available.
18221829
charms_cls = client.CharmsFacade
@@ -1880,6 +1887,12 @@ async def _resolve_charm(self, url, origin, force=False, series=None, model_conf
18801887
return str(charm_url), resolved_origin
18811888

18821889
async def _resolve_architecture(self, url):
1890+
"""_resolve_architecture returns the architecture for a given charm url.
1891+
:param str url: the client.URL to determine the arch for
1892+
1893+
:returns str architecture for the given url
1894+
"""
1895+
18831896
if url.architecture:
18841897
return url.architecture
18851898

@@ -1893,6 +1906,16 @@ async def _add_charmhub_resources(self, application,
18931906
entity_url,
18941907
origin,
18951908
overrides=None):
1909+
"""_add_charmhub_resources is called by the deploy to add pending resources requested by
1910+
the charm being deployed. It calls the ResourcesFacade.AddPendingResources.
1911+
1912+
:param str application: the name of the application
1913+
:param client.CharmURL entity_url: url for the charm that we add resources for
1914+
:param client.CharmOrigin origin: origin for the charm that we add resources for
1915+
1916+
:returns [string]string resource_map that is a map of resources to their assigned
1917+
pendingIDs.
1918+
"""
18961919
charm_facade = client.CharmsFacade.from_connection(self.connection())
18971920
res = await charm_facade.CharmInfo(entity_url)
18981921

@@ -1936,6 +1959,20 @@ async def _add_charmhub_resources(self, application,
19361959
return resource_map
19371960

19381961
async def add_local_resources(self, application, entity_url, metadata, resources):
1962+
"""_add_local_resources is called by the deploy to add pending local resources requested by
1963+
the charm being deployed. It calls the ResourcesFacade.AddPendingResources. After getting
1964+
the pending IDs from the controller it sends an HTTP PUT request to actually upload local
1965+
resources.
1966+
1967+
:param str application: the name of the application
1968+
:param client.CharmURL entity_url: url for the charm that we add resources for
1969+
:param [string]string metadata: metadata for the charm that we add resources for
1970+
:param [string] resources: the paths for the local files (or oci-images) to be added as
1971+
local resources
1972+
1973+
:returns [string]string resource_map that is a map of resources to their assigned
1974+
pendingIDs.
1975+
"""
19391976
if not resources:
19401977
return None
19411978

0 commit comments

Comments
 (0)