@@ -0,0 +1,2423 @@
+%22%22%22%0AThis example:%0A%0A1. Connects to the current model.%0A2. Deploys a charm and waits until it reports itself active.%0A3. Demonstrates exposing application endpoints to space and CIDR combinations.%0A3. Demonstrates unexposing application endpoints.%0A%0ANOTE: this test must be run against a 2.9 controller.%0A%22%22%22%0Afrom juju import loop%0Afrom juju.model import Model%0Afrom juju.application import ExposedEndpoint%0A%0Aimport logging%0A%0Aasync def main():%0A    model = Model()%0A    print('Connecting to model')%0A    # connect to current model with current user, per Juju CLI%0A    await model.connect()%0A%0A    try:%0A        print('Deploying ubuntu')%0A        application = await model.deploy(%0A            'cs:~jameinel/ubuntu-lite-7',%0A            application_name='ubuntu',%0A            series='trusty',%0A            channel='stable',%0A        )%0A%0A        print('Waiting for active')%0A        await model.block_until(%0A            lambda: all(unit.workload_status == 'active'%0A                        for unit in application.units))%0A%0A        print('Expose all opened port ranges')%0A        await application.expose()%0A%0A        print('Expose all opened port ranges to the CIDRs that correspond to a list of spaces')%0A        await application.expose(exposed_endpoints=%7B%0A            %22%22: ExposedEndpoint(to_spaces=%5B%22alpha%22%5D)%0A        %7D)%0A%0A        print('Expose all opened port ranges to a list of CIDRs')%0A        await application.expose(exposed_endpoints=%7B%0A            %22%22: ExposedEndpoint(to_cidrs=%5B%2210.0.0.0/24%22%5D)%0A        %7D)%0A%0A        print('Expose all opened port ranges to a list of spaces and CIDRs')%0A        await application.expose(exposed_endpoints=%7B%0A            %22%22: ExposedEndpoint(to_spaces=%5B%22alpha%22%5D, to_cidrs=%5B%2210.0.0.0/24%22%5D)%0A        %7D)%0A%0A        print('Expose individual endpoints to different space/CIDR combinations')%0A        await application.expose(exposed_endpoints=%7B%0A            %22%22: ExposedEndpoint(to_spaces=%5B%22alpha%22%5D, to_cidrs=%5B%2210.0.0.0/24%22%5D),%0A            %22ubuntu%22: ExposedEndpoint(to_cidrs=%5B%2210.42.42.0/24%22%5D)%0A        %7D)%0A%0A        print('Unexpose individual endpoints (other endpoints remain exposed)')%0A        await application.unexpose(exposed_endpoints=%5B%22ubuntu%22%5D)%0A%0A        print('Unexpose application')%0A        await application.unexpose()%0A%0A        print('Removing ubuntu')%0A        await application.remove()%0A    finally:%0A        print('Disconnecting from model')%0A        await model.disconnect()%0A%0A%0Aif __name__ == '__main__':%0A    loop.run(main())%0A

Add example for the expose/unexpose methods