:doc:`ECR <../../ecr>` / Client / get_repository_policy

*********************
get_repository_policy
*********************



.. py:method:: ECR.Client.get_repository_policy(**kwargs)

  

  Retrieves the repository policy for the specified repository.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/ecr-2015-09-21/GetRepositoryPolicy>`_  


  **Request Syntax**
  ::

    response = client.get_repository_policy(
        registryId='string',
        repositoryName='string'
    )
    
  :type registryId: string
  :param registryId: 

    The Amazon Web Services account ID associated with the registry that contains the repository. If you do not specify a registry, the default registry is assumed.

    

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

    The name of the repository with the policy to retrieve.

    

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

    
    ::

      {
          'registryId': 'string',
          'repositoryName': 'string',
          'policyText': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **registryId** *(string) --* 

        The registry ID associated with the request.

        
      

      - **repositoryName** *(string) --* 

        The repository name associated with the request.

        
      

      - **policyText** *(string) --* 

        The JSON repository policy text associated with the repository.

        
  
  **Exceptions**
  
  *   :py:class:`ECR.Client.exceptions.ServerException`

  
  *   :py:class:`ECR.Client.exceptions.InvalidParameterException`

  
  *   :py:class:`ECR.Client.exceptions.RepositoryNotFoundException`

  
  *   :py:class:`ECR.Client.exceptions.RepositoryPolicyNotFoundException`

  

  **Examples**

  This example obtains the repository policy for the repository named ubuntu.
  ::

    response = client.get_repository_policy(
        repositoryName='ubuntu',
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'policyText': '{\n  "Version" : "2008-10-17",\n  "Statement" : [ {\n    "Sid" : "new statement",\n    "Effect" : "Allow",\n    "Principal" : {\n     "AWS" : "arn:aws:iam::012345678901:role/CodeDeployDemo"\n    },\n"Action" : [ "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage", "ecr:BatchCheckLayerAvailability" ]\n } ]\n}',
        'registryId': '012345678901',
        'repositoryName': 'ubuntu',
        'ResponseMetadata': {
            '...': '...',
        },
    }

  