55
66import json
77from ..common import Parameter
8+ from ..entry_variants .entry_variants import EntryVariants
89
910class Entry (Parameter ):
1011 """
@@ -421,13 +422,58 @@ def unpublish(self, data):
421422 data = json .dumps (data )
422423 return self .client .post (url , headers = self .client .headers , data = data , params = self .params )
423424
424-
425-
426-
427-
425+ def variants (self , variant_uid : str = None ):
426+ """
427+ Returns an EntryVariants instance for managing variant entries.
428+
429+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
430+ the variant. It is used to specify which variant to work with
431+ :type variant_uid: str
432+ :return: EntryVariants instance for managing variant entries
433+ -------------------------------
434+ [Example:]
428435
429-
436+ >>> import contentstack_management
437+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
438+ >>> # Get all variant entries
439+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants().query().find().json()
440+ >>> # Get specific variant entry
441+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants('variant_uid').fetch().json()
430442
443+ -------------------------------
444+ """
445+
446+ return EntryVariants (self .client , self .content_type_uid , self .entry_uid , variant_uid )
431447
448+ def includeVariants (self , include_variants : str = 'true' , variant_uid : str = None , params : dict = None ):
449+ """
450+ The includeVariants method retrieves the details of a specific base entry with variant details.
451+
452+ :param include_variants: The `include_variants` parameter is a string that specifies whether to include variants
453+ :type include_variants: str
454+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
455+ the variant. It is used to specify which variant to include
456+ :type variant_uid: str
457+ :param params: The `params` parameter is a dictionary that contains query parameters to be sent with the request
458+ :type params: dict
459+ :return: the result of the GET request made to the specified URL.
460+ -------------------------------
461+ [Example:]
432462
463+ >>> import contentstack_management
464+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
465+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').includeVariants('true', 'variant_uid').json()
466+ >>> # With parameters
467+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').includeVariants('true', 'variant_uid', params={'locale': 'en-us'}).json()
433468
469+ -------------------------------
470+ """
471+ if self .entry_uid is None :
472+ raise Exception ('Entry uid is required' )
473+ if params is not None :
474+ self .params .update (params )
475+ self .params ['include_variants' ] = include_variants
476+ if variant_uid is not None and variant_uid != '' :
477+ self .params ['variant_uid' ] = variant_uid
478+ url = f"content_types/{ self .content_type_uid } /entries/{ self .entry_uid } "
479+ return self .client .get (url , headers = self .client .headers , params = self .params )
0 commit comments