3232from .resources import (
3333 Active ,
3434 Resource ,
35- ResourceParameters ,
3635 Resources ,
3736 _Resource ,
38- _ResourcePatch ,
3937 _ResourceSequence ,
4038 _ResourceUpdatePatchMixin ,
4139)
4644if TYPE_CHECKING :
4745 from .context import Context
4846 from .jobs import Jobs
49- from .packages import _ContentPackages
47+ from .packages import ContentPackages
5048 from .tasks import Task
5149
5250
@@ -115,13 +113,13 @@ def update(
115113
116114
117115class ContentItemOAuth (Resource ):
118- def __init__ (self , params : ResourceParameters , content_guid : str ) -> None :
119- super ().__init__ (params )
116+ def __init__ (self , ctx : Context , content_guid : str ) -> None :
117+ super ().__init__ (ctx )
120118 self ["content_guid" ] = content_guid
121119
122120 @property
123121 def associations (self ) -> ContentItemAssociations :
124- return ContentItemAssociations (self .params , content_guid = self ["content_guid" ])
122+ return ContentItemAssociations (self ._ctx , content_guid = self ["content_guid" ])
125123
126124
127125class ContentItemOwner (Resource ):
@@ -208,12 +206,12 @@ def __init__(
208206 def __getitem__ (self , key : Any ) -> Any :
209207 v = super ().__getitem__ (key )
210208 if key == "owner" and isinstance (v , dict ):
211- return ContentItemOwner (params = self .params , ** v )
209+ return ContentItemOwner (self ._ctx , ** v )
212210 return v
213211
214212 @property
215213 def oauth (self ) -> ContentItemOAuth :
216- return ContentItemOAuth (self .params , content_guid = self ["guid" ])
214+ return ContentItemOAuth (self ._ctx , content_guid = self ["guid" ])
217215
218216 @property
219217 def repository (self ) -> ContentItemRepository | None :
@@ -270,8 +268,7 @@ def create_repository(self, /, **attributes) -> ContentItemRepository:
270268 def delete (self ) -> None :
271269 """Delete the content item."""
272270 path = f"v1/content/{ self ['guid' ]} "
273- url = self ._ctx .url + path
274- self ._ctx .session .delete (url )
271+ self ._ctx .client .delete (path )
275272
276273 def deploy (self ) -> tasks .Task :
277274 """Deploy the content.
@@ -290,10 +287,9 @@ def deploy(self) -> tasks.Task:
290287 None
291288 """
292289 path = f"v1/content/{ self ['guid' ]} /deploy"
293- url = self ._ctx .url + path
294- response = self ._ctx .session .post (url , json = {"bundle_id" : None })
290+ response = self ._ctx .client .post (path , json = {"bundle_id" : None })
295291 result = response .json ()
296- ts = tasks .Tasks (self .params )
292+ ts = tasks .Tasks (self ._ctx )
297293 return ts .get (result ["task_id" ])
298294
299295 def render (self ) -> Task :
@@ -346,8 +342,8 @@ def restart(self) -> None:
346342 self .environment_variables .create (key , unix_epoch_in_seconds )
347343 self .environment_variables .delete (key )
348344 # GET via the base Connect URL to force create a new worker thread.
349- url = posixpath . join ( dirname ( self . _ctx . url ), f" content/{ self ['guid' ]} ")
350- self ._ctx .session .get (url )
345+ path = f"../ content/{ self ['guid' ]} "
346+ self ._ctx .client .get (path )
351347 return None
352348 else :
353349 raise ValueError (
@@ -417,23 +413,22 @@ def update(
417413 -------
418414 None
419415 """
420- url = self ._ctx .url + f"v1/content/{ self ['guid' ]} "
421- response = self ._ctx .session .patch (url , json = attrs )
416+ response = self ._ctx .client .patch (f"v1/content/{ self ['guid' ]} " , json = attrs )
422417 super ().update (** response .json ())
423418
424419 # Relationships
425420
426421 @property
427422 def bundles (self ) -> Bundles :
428- return Bundles (self .params , self ["guid" ])
423+ return Bundles (self ._ctx , self ["guid" ])
429424
430425 @property
431426 def environment_variables (self ) -> EnvVars :
432- return EnvVars (self .params , self ["guid" ])
427+ return EnvVars (self ._ctx , self ["guid" ])
433428
434429 @property
435430 def permissions (self ) -> Permissions :
436- return Permissions (self .params , self ["guid" ])
431+ return Permissions (self ._ctx , self ["guid" ])
437432
438433 @property
439434 def owner (self ) -> dict :
@@ -450,7 +445,7 @@ def owner(self) -> dict:
450445
451446 @property
452447 def _variants (self ) -> Variants :
453- return Variants (self .params , self ["guid" ])
448+ return Variants (self ._ctx , self ["guid" ])
454449
455450 @property
456451 def is_interactive (self ) -> bool :
@@ -494,7 +489,7 @@ def jobs(self) -> Jobs:
494489
495490 @property
496491 @requires (version = "2024.11.0" )
497- def packages (self ) -> _ContentPackages :
492+ def packages (self ) -> ContentPackages :
498493 path = posixpath .join (self ._path , "packages" )
499494 return _ResourceSequence (self ._ctx , path , uid = "name" )
500495
@@ -518,7 +513,7 @@ def __init__(
518513 * ,
519514 owner_guid : str | None = None ,
520515 ) -> None :
521- super ().__init__ (ctx . client . resource_params )
516+ super ().__init__ (ctx )
522517 self .owner_guid = owner_guid
523518 self ._ctx = ctx
524519
@@ -594,9 +589,7 @@ def create(
594589 -------
595590 ContentItem
596591 """
597- path = "v1/content"
598- url = self ._ctx .url + path
599- response = self ._ctx .session .post (url , json = attrs )
592+ response = self ._ctx .client .post ("v1/content" , json = attrs )
600593 return ContentItem (self ._ctx , ** response .json ())
601594
602595 @overload
@@ -682,9 +675,7 @@ def find(self, include: Optional[str | list[Any]] = None, **conditions) -> List[
682675 if self .owner_guid :
683676 conditions ["owner_guid" ] = self .owner_guid
684677
685- path = "v1/content"
686- url = self ._ctx .url + path
687- response = self ._ctx .session .get (url , params = conditions )
678+ response = self ._ctx .client .get ("v1/content" , params = conditions )
688679 return [
689680 ContentItem (
690681 self ._ctx ,
@@ -855,7 +846,5 @@ def get(self, guid: str) -> ContentItem:
855846 -------
856847 ContentItem
857848 """
858- path = f"v1/content/{ guid } "
859- url = self ._ctx .url + path
860- response = self ._ctx .session .get (url )
849+ response = self ._ctx .client .get (f"v1/content/{ guid } " )
861850 return ContentItem (self ._ctx , ** response .json ())
0 commit comments