How to manage offers
> See also: juju:offer
This document shows how to manage offers.
Create an offer
> Who: User with juju:user-access-offer-admin
To create an offer, use the create_offer() method on a connected Model object.
# Assume a deployed mysql application
await my_model.deploy('mysql')
# Expose the database endpoint of the mysql application
await my_model.create_offer('mysql:database', offer_name='hosted-mysql')
> See more: create_offer()
Control access to an offer
> Who: User with juju:user-access-offer-admin
The access levels for offers can be applied in the same way the model or controller access for a given user. Use the grant() and revoke() methods on a User object to grant or revoke access to an offer.
# Grant Bob consume access to an offer
await user_bob.grant('consume', offer_name='admin/default.hosted-mysql')
# Revoke Bob's consume access (he will be left with read access)
await user_bob.revoke('consume', offer_name='admin/default.hosted-mysql')
> See more: User (object)
Integrate with an offer
> Who: User with juju:user-access-offer-consume
To integrate with an offer, on a connected model, use the Model.integrate() method with a consumed offer url. For example:
# Integrate via offer url
await my_model.integrate('mediawiki:db', 'admin/default.hosted-mysql')
# Integrate via an offer alias created when consumed
await my_model.consume('admin/prod.hosted_mysql', application_alias="mysql-alias")
await my_model.integrate('mediawiki:db', 'mysql-alias')
# Remove a consumed offer:
await my_model.remove_saas('mysql-alias')
> See more: Model.integrate(), Model.consume(), Model.remove_saas()
Inspect integrations with an offer
> Who: User with juju:user-access-offer-admin
To see all connections to one or more offers, use the list_offers() method on a connected Model object.
await my_model.list_offers()
> See more: list_offers()
Remove an offer
> Who: User with juju:user-access-offer-admin
To remove an offer, use the remove_offer() method on a connected Model. If the offer is used in an integration, then the force=True parameter is required to remove the offer, in which case the integration is also removed.
await my_model.remove_offer('admin/mymodel.ubuntu', force=True)
> See more: remove_offer()