@@ -274,6 +274,49 @@ def pending(self, entity_id, **kwargs) -> 'Account':
274274 return self .set_state (entity_id = entity_id , state = 'make_pending' , ** kwargs )
275275
276276
277+ class ServiceSubscriptions (DefaultClient ):
278+
279+ def __init__ (self , * args , entity_name = 'service_subscription' ,
280+ entity_collection = 'service_subscriptions' , ** kwargs ):
281+ super ().__init__ (* args , entity_name = entity_name ,
282+ entity_collection = entity_collection , ** kwargs )
283+
284+ @property
285+ def url (self ) -> str :
286+ return self .parent .url + '/service_subscriptions'
287+
288+ def approve (self , entity_id : int , ** kwargs ):
289+ url = self .url + f"/{ entity_id } /approve.json"
290+ response = self .rest .put (url = url , ** kwargs )
291+ instance = utils .extract_response (response = response )
292+ return instance
293+
294+ def change_plan (self , entity_id : int , plan_id : int , ** kwargs ):
295+ params = {"plan_id" : plan_id }
296+ url = self .url + f"/{ entity_id } /change_plan.json"
297+ response = self .rest .put (url = url , json = params , ** kwargs )
298+ instance = utils .extract_response (response = response )
299+ return instance
300+
301+
302+ class ServicePlans (DefaultClient ):
303+
304+ def __init__ (self , * args , entity_name = 'service_plan' ,
305+ entity_collection = 'service_plans' , ** kwargs ):
306+ super ().__init__ (* args , entity_name = entity_name ,
307+ entity_collection = entity_collection , ** kwargs )
308+
309+ @property
310+ def url (self ) -> str :
311+ return self .parent .url + '/service_plans'
312+
313+ def service_plan_set_default (self , entity_id : int , ** kwargs ):
314+ url = self .url + f"/{ entity_id } /default"
315+ response = self .rest .put (url = url , ** kwargs )
316+ instance = self ._create_instance (response = response )
317+ return instance
318+
319+
277320class Applications (DefaultStateClient ):
278321 def __init__ (self , * args , entity_name = 'application' , entity_collection = 'applications' ,
279322 per_page = None , ** kwargs ):
@@ -1139,6 +1182,18 @@ def backend(self) -> 'Backend':
11391182 return self .metric .parent
11401183
11411184
1185+ class ServiceSubscription (DefaultResource ):
1186+
1187+ def __init__ (self , ** kwargs ):
1188+ super ().__init__ (** kwargs )
1189+
1190+ def approve (self , ** kwargs ):
1191+ return self .client .approve (entity_id = self .entity_id , ** kwargs )
1192+
1193+ def change_plan (self , ** kwargs ):
1194+ return self .client .change_plan (entity_id = self .entity_id , ** kwargs )
1195+
1196+
11421197class Metric (DefaultResource ):
11431198 def __init__ (self , entity_name = 'system_name' , ** kwargs ):
11441199 super ().__init__ (entity_name = entity_name , ** kwargs )
@@ -1249,6 +1304,10 @@ def app_plans(self) -> ApplicationPlans:
12491304 def metrics (self ) -> Metrics :
12501305 return Metrics (parent = self , instance_klass = Metric )
12511306
1307+ @property
1308+ def service_plans (self ) -> ServicePlans :
1309+ return ServicePlans (parent = self , instance_klass = ServicePlan )
1310+
12521311 @property
12531312 def proxy (self ) -> 'Proxies' :
12541313 return Proxies (parent = self , instance_klass = Proxy )
@@ -1456,6 +1515,15 @@ def test_request(self, relpath=None, verify: bool = None):
14561515 return client .get (relpath )
14571516
14581517
1518+ class ServicePlan (DefaultResource ):
1519+
1520+ def __init__ (self , ** kwargs ):
1521+ super ().__init__ (** kwargs )
1522+
1523+ def set_default (self , ** kwargs ):
1524+ return self .client .service_plan_set_default (entity_id = self .entity_id , ** kwargs )
1525+
1526+
14591527class ApplicationKey (DefaultResource ):
14601528 def __init__ (self , entity_name = '' , ** kwargs ):
14611529 super ().__init__ (entity_name = entity_name , ** kwargs )
@@ -1473,6 +1541,10 @@ def applications(self) -> Applications:
14731541 def users (self ) -> AccountUsers :
14741542 return AccountUsers (parent = self , instance_klass = AccountUser )
14751543
1544+ @property
1545+ def service_subscriptions (self ) -> ServiceSubscriptions :
1546+ return ServiceSubscriptions (parent = self , instance_klass = ServiceSubscription )
1547+
14761548 def credit_card_set (self , params : dict = None , ** kwargs ):
14771549 url = self .url + "/credit_card"
14781550 response = self .client .rest .put (url = url , json = params , ** kwargs )
0 commit comments