:doc:`RecycleBin <../../rbin>` / Client / list_rules

**********
list_rules
**********



.. py:method:: RecycleBin.Client.list_rules(**kwargs)

  

  Lists the Recycle Bin retention rules in the Region.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/rbin-2021-06-15/ListRules>`_  


  **Request Syntax**
  ::

    response = client.list_rules(
        MaxResults=123,
        NextToken='string',
        ResourceType='EBS_SNAPSHOT'|'EC2_IMAGE'|'EBS_VOLUME',
        ResourceTags=[
            {
                'ResourceTagKey': 'string',
                'ResourceTagValue': 'string'
            },
        ],
        LockState='locked'|'pending_unlock'|'unlocked',
        ExcludeResourceTags=[
            {
                'ResourceTagKey': 'string',
                'ResourceTagValue': 'string'
            },
        ]
    )
    
  :type MaxResults: integer
  :param MaxResults: 

    The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned ``NextToken`` value.

    

  
  :type NextToken: string
  :param NextToken: 

    The token for the next page of results.

    

  
  :type ResourceType: string
  :param ResourceType: **[REQUIRED]** 

    The resource type retained by the retention rule. Only retention rules that retain the specified resource type are listed. Currently, only EBS volumes, EBS snapshots, and EBS-backed AMIs are supported.

     

    
    * To list retention rules that retain EBS volumes, specify ``EBS_VOLUME``.
     
    * To list retention rules that retain EBS snapshots, specify ``EBS_SNAPSHOT``.
     
    * To list retention rules that retain EBS-backed AMIs, specify ``EC2_IMAGE``.
    

    

  
  :type ResourceTags: list
  :param ResourceTags: 

    [Tag-level retention rules only] Information about the resource tags used to identify resources that are retained by the retention rule.

    

  
    - *(dict) --* 

      [Tag-level retention rules only] Information about the resource tags used to identify resources that are retained by the retention rule.

      

    
      - **ResourceTagKey** *(string) --* **[REQUIRED]** 

        The tag key.

        

      
      - **ResourceTagValue** *(string) --* 

        The tag value.

        

      
    

  :type LockState: string
  :param LockState: 

    The lock state of the retention rules to list. Only retention rules with the specified lock state are returned.

    

  
  :type ExcludeResourceTags: list
  :param ExcludeResourceTags: 

    [Region-level retention rules only] Information about the exclusion tags used to identify resources that are to be excluded, or ignored, by the retention rule.

    

  
    - *(dict) --* 

      [Tag-level retention rules only] Information about the resource tags used to identify resources that are retained by the retention rule.

      

    
      - **ResourceTagKey** *(string) --* **[REQUIRED]** 

        The tag key.

        

      
      - **ResourceTagValue** *(string) --* 

        The tag value.

        

      
    

  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'Rules': [
              {
                  'Identifier': 'string',
                  'Description': 'string',
                  'RetentionPeriod': {
                      'RetentionPeriodValue': 123,
                      'RetentionPeriodUnit': 'DAYS'
                  },
                  'LockState': 'locked'|'pending_unlock'|'unlocked',
                  'RuleArn': 'string'
              },
          ],
          'NextToken': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **Rules** *(list) --* 

        Information about the retention rules.

        
        

        - *(dict) --* 

          Information about a Recycle Bin retention rule.

          
          

          - **Identifier** *(string) --* 

            The unique ID of the retention rule.

            
          

          - **Description** *(string) --* 

            The retention rule description.

            
          

          - **RetentionPeriod** *(dict) --* 

            Information about the retention period for which the retention rule is to retain resources.

            
            

            - **RetentionPeriodValue** *(integer) --* 

              The period value for which the retention rule is to retain resources, measured in days. The supported retention periods are:

               

              
              * EBS volumes: 1 - 7 days
               
              * EBS snapshots and EBS-backed AMIs: 1 - 365 days
              

              
            

            - **RetentionPeriodUnit** *(string) --* 

              The unit of time in which the retention period is measured. Currently, only ``DAYS`` is supported.

              
        
          

          - **LockState** *(string) --* 

            [Region-level retention rules only] The lock state for the retention rule.

             

            
            * ``locked`` - The retention rule is locked and can't be modified or deleted.
             
            * ``pending_unlock`` - The retention rule has been unlocked but it is still within the unlock delay period. The retention rule can be modified or deleted only after the unlock delay period has expired.
             
            * ``unlocked`` - The retention rule is unlocked and it can be modified or deleted by any user with the required permissions.
             
            * ``null`` - The retention rule has never been locked. Once a retention rule has been locked, it can transition between the ``locked`` and ``unlocked`` states only; it can never transition back to ``null``.
            

            
          

          - **RuleArn** *(string) --* 

            The Amazon Resource Name (ARN) of the retention rule.

            
      
    
      

      - **NextToken** *(string) --* 

        The token to use to retrieve the next page of results. This value is ``null`` when there are no more results to return.

        
  
  **Exceptions**
  
  *   :py:class:`RecycleBin.Client.exceptions.ValidationException`

  
  *   :py:class:`RecycleBin.Client.exceptions.InternalServerException`

  