11import os
22import shutil
3+ from typing import Union , List , Optional
34
45from openbrokerapi .errors import ErrInstanceAlreadyExists , ErrAsyncRequired , \
56 ErrBindingAlreadyExists , ErrBadRequest , ErrInstanceDoesNotExist
6- from openbrokerapi .service_broker import *
7+ from openbrokerapi .service_broker import ServiceBroker , Service , \
8+ ProvisionDetails , ProvisionedServiceSpec , ProvisionState , GetBindingSpec , \
9+ BindDetails , Binding , BindState , UnbindDetails , UnbindSpec , \
10+ UpdateDetails , UpdateServiceSpec , DeprovisionDetails , \
11+ DeprovisionServiceSpec , LastOperation
712
8- from .meta import load_instance_meta , load_binding_meta , dump_binding_meta
13+ from .meta import load_instance_meta , load_binding_meta
914from .utils import get_instance_path , get_chart_path , get_plan_path , \
1015 get_addon_path , get_addon_name , get_addon_updateable , get_addon_bindable
1116from .tasks import provision , bind , deprovision , update
@@ -27,12 +32,12 @@ def provision(self,
2732 ** kwargs ) -> ProvisionedServiceSpec :
2833 instance_path = get_instance_path (instance_id )
2934 if os .path .exists (instance_path ):
30- raise ErrInstanceAlreadyExists ("Instance %s already exists" % instance_id )
35+ raise ErrInstanceAlreadyExists ("Instance %s already exists" % instance_id ) # noqa
3136 if not async_allowed :
3237 raise ErrAsyncRequired ()
3338 os .makedirs (instance_path , exist_ok = True )
34- chart_path , plan_path = get_chart_path (instance_id ), get_plan_path (instance_id )
35- addon_chart_path , addon_plan_path = get_addon_path (details .service_id , details .plan_id )
39+ chart_path , plan_path = get_chart_path (instance_id ), get_plan_path (instance_id ) # noqa
40+ addon_chart_path , addon_plan_path = get_addon_path (details .service_id , details .plan_id ) # noqa
3641 shutil .copy (addon_chart_path , chart_path )
3742 shutil .copy (addon_plan_path , plan_path )
3843 provision .delay (instance_id , details )
@@ -61,15 +66,15 @@ def bind(self,
6166 instance_meta = load_instance_meta (instance_id )
6267 if not (instance_meta and
6368 instance_meta ['last_operation' ]['state' ] == 'Ready' ):
64- raise ErrBadRequest (msg = "This instance %s is not ready" % instance_id )
69+ raise ErrBadRequest (msg = "This instance %s is not ready" % instance_id ) # noqa
6570 if not async_allowed :
6671 raise ErrAsyncRequired ()
6772 instance_path = get_instance_path (instance_id )
6873 if os .path .exists (f'{ instance_path } /bind.yaml' ):
6974 raise ErrBindingAlreadyExists ()
70- chart_path , plan_path = get_chart_path (instance_id ), get_plan_path (instance_id )
75+ chart_path , plan_path = get_chart_path (instance_id ), get_plan_path (instance_id ) # noqa
7176 addon_name = get_addon_name (details .service_id )
72- shutil .copy (f'{ plan_path } /bind.yaml' , f'{ chart_path } /{ addon_name } /templates' )
77+ shutil .copy (f'{ plan_path } /bind.yaml' , f'{ chart_path } /{ addon_name } /templates' ) # noqa
7378 bind .delay (instance_id , binding_id , details , async_allowed , ** kwargs )
7479 return Binding (state = BindState .IS_ASYNC )
7580
@@ -96,13 +101,13 @@ def update(self,
96101 raise ErrBadRequest ("Instance %s does not exist" % instance_id )
97102 is_plan_updateable = get_addon_updateable (instance_id )
98103 if not is_plan_updateable :
99- raise ErrBadRequest ("Instance %s does not updateable" % instance_id )
104+ raise ErrBadRequest ("Instance %s does not updateable" % instance_id ) # noqa
100105 if not async_allowed :
101106 raise ErrAsyncRequired ()
102107 plan_path = get_plan_path (instance_id )
103108 # delete the pre plan
104109 shutil .rmtree (plan_path )
105- _ , addon_plan_path = get_addon_path (details .service_id , details .plan_id )
110+ _ , addon_plan_path = get_addon_path (details .service_id , details .plan_id ) # noqa
106111 # add the new plan
107112 shutil .copy (addon_plan_path , plan_path )
108113 update .delay (instance_id , details )
@@ -115,7 +120,7 @@ def deprovision(self,
115120 ** kwargs ) -> DeprovisionServiceSpec :
116121 instance_path = get_instance_path (instance_id )
117122 if not os .path .exists (instance_path ):
118- raise ErrInstanceDoesNotExist ("Instance %s not exists" % instance_id )
123+ raise ErrInstanceDoesNotExist ("Instance %s not exists" % instance_id ) # noqa
119124 if not async_allowed :
120125 raise ErrAsyncRequired ()
121126
0 commit comments