:doc:`IAM <../../iam>` / Client / list_policy_versions

********************
list_policy_versions
********************



.. py:method:: IAM.Client.list_policy_versions(**kwargs)

  

  Lists information about the versions of the specified managed policy, including the version that is currently set as the policy's default version.

   

  For more information about managed policies, see `Managed policies and inline policies <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html>`__ in the *IAM User Guide*.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/iam-2010-05-08/ListPolicyVersions>`_  


  **Request Syntax**
  ::

    response = client.list_policy_versions(
        PolicyArn='string',
        Marker='string',
        MaxItems=123
    )
    
  :type PolicyArn: string
  :param PolicyArn: **[REQUIRED]** 

    The Amazon Resource Name (ARN) of the IAM policy for which you want the versions.

     

    For more information about ARNs, see `Amazon Resource Names (ARNs) <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html>`__ in the *Amazon Web Services General Reference*.

    

  
  :type Marker: string
  :param Marker: 

    Use this parameter only when paginating results and only after you receive a response indicating that the results are truncated. Set it to the value of the ``Marker`` element in the response that you received to indicate where the next call should start.

    

  
  :type MaxItems: integer
  :param MaxItems: 

    Use this only when paginating results to indicate the maximum number of items you want in the response. If additional items exist beyond the maximum you specify, the ``IsTruncated`` response element is ``true``.

     

    If you do not include this parameter, the number of items defaults to 100. Note that IAM might return fewer results, even when there are more results available. In that case, the ``IsTruncated`` response element returns ``true``, and ``Marker`` contains a value to include in the subsequent call that tells the service where to continue from.

    

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

    
    ::

      {
          'Versions': [
              {
                  'Document': 'string',
                  'VersionId': 'string',
                  'IsDefaultVersion': True|False,
                  'CreateDate': datetime(2015, 1, 1)
              },
          ],
          'IsTruncated': True|False,
          'Marker': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 

      Contains the response to a successful `ListPolicyVersions <https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListPolicyVersions.html>`__ request.

      
      

      - **Versions** *(list) --* 

        A list of policy versions.

         

        For more information about managed policy versions, see `Versioning for managed policies <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html>`__ in the *IAM User Guide*.

        
        

        - *(dict) --* 

          Contains information about a version of a managed policy.

           

          This data type is used as a response element in the `CreatePolicyVersion <https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreatePolicyVersion.html>`__, `GetPolicyVersion <https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetPolicyVersion.html>`__, `ListPolicyVersions <https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListPolicyVersions.html>`__, and `GetAccountAuthorizationDetails <https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetAccountAuthorizationDetails.html>`__ operations.

           

          For more information about managed policies, refer to `Managed policies and inline policies <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html>`__ in the *IAM User Guide*.

          
          

          - **Document** *(string) --* 

            The policy document.

             

            The policy document is returned in the response to the `GetPolicyVersion <https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetPolicyVersion.html>`__ and `GetAccountAuthorizationDetails <https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetAccountAuthorizationDetails.html>`__ operations. It is not returned in the response to the `CreatePolicyVersion <https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreatePolicyVersion.html>`__ or `ListPolicyVersions <https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListPolicyVersions.html>`__ operations.

             

            The policy document returned in this structure is URL-encoded compliant with `RFC 3986 <https://tools.ietf.org/html/rfc3986>`__. You can use a URL decoding method to convert the policy back to plain JSON text. For example, if you use Java, you can use the ``decode`` method of the ``java.net.URLDecoder`` utility class in the Java SDK. Other languages and SDKs provide similar functionality.

            
          

          - **VersionId** *(string) --* 

            The identifier for the policy version.

             

            Policy version identifiers always begin with ``v`` (always lowercase). When a policy is created, the first policy version is ``v1``.

            
          

          - **IsDefaultVersion** *(boolean) --* 

            Specifies whether the policy version is set as the policy's default version.

            
          

          - **CreateDate** *(datetime) --* 

            The date and time, in `ISO 8601 date-time format <http://www.iso.org/iso/iso8601>`__, when the policy version was created.

            
      
    
      

      - **IsTruncated** *(boolean) --* 

        A flag that indicates whether there are more items to return. If your results were truncated, you can make a subsequent pagination request using the ``Marker`` request parameter to retrieve more items. Note that IAM might return fewer than the ``MaxItems`` number of results even when there are more results available. We recommend that you check ``IsTruncated`` after every call to ensure that you receive all your results.

        
      

      - **Marker** *(string) --* 

        When ``IsTruncated`` is ``true``, this element is present and contains the value to use for the ``Marker`` parameter in a subsequent pagination request.

        
  
  **Exceptions**
  
  *   :py:class:`IAM.Client.exceptions.NoSuchEntityException`

  
  *   :py:class:`IAM.Client.exceptions.InvalidInputException`

  
  *   :py:class:`IAM.Client.exceptions.ServiceFailureException`

  