:doc:`ConfigService <../../config>` / Client / put_stored_query

****************
put_stored_query
****************



.. py:method:: ConfigService.Client.put_stored_query(**kwargs)

  

  Saves a new query or updates an existing saved query. The ``QueryName`` must be unique for a single Amazon Web Services account and a single Amazon Web Services Region. You can create upto 300 queries in a single Amazon Web Services account and a single Amazon Web Services Region.

   

  .. note::

    

    **Tags are added at creation and cannot be updated**

     

    ``PutStoredQuery`` is an idempotent API. Subsequent requests won’t create a duplicate resource if one was already created. If a following request has different ``tags`` values, Config will ignore these differences and treat it as an idempotent request of the previous. In this case, ``tags`` will not be updated, even if they are different.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/config-2014-11-12/PutStoredQuery>`_  


  **Request Syntax**
  ::

    response = client.put_stored_query(
        StoredQuery={
            'QueryId': 'string',
            'QueryArn': 'string',
            'QueryName': 'string',
            'Description': 'string',
            'Expression': 'string'
        },
        Tags=[
            {
                'Key': 'string',
                'Value': 'string'
            },
        ]
    )
    
  :type StoredQuery: dict
  :param StoredQuery: **[REQUIRED]** 

    A list of ``StoredQuery`` objects. The mandatory fields are ``QueryName`` and ``Expression``.

     

    .. note::

      

      When you are creating a query, you must provide a query name and an expression. When you are updating a query, you must provide a query name but updating the description is optional.

      

    

  
    - **QueryId** *(string) --* 

      The ID of the query.

      

    
    - **QueryArn** *(string) --* 

      Amazon Resource Name (ARN) of the query. For example, arn:partition:service:region:account-id:resource-type/resource-name/resource-id.

      

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

      The name of the query.

      

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

      A unique description for the query.

      

    
    - **Expression** *(string) --* 

      The expression of the query. For example, ``SELECT resourceId, resourceType, supplementaryConfiguration.BucketVersioningConfiguration.status WHERE resourceType = 'AWS::S3::Bucket' AND supplementaryConfiguration.BucketVersioningConfiguration.status = 'Off'.``

      

    
  
  :type Tags: list
  :param Tags: 

    A list of ``Tags`` object.

    

  
    - *(dict) --* 

      The tags for the resource. The metadata that you apply to a resource to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

      

    
      - **Key** *(string) --* 

        One part of a key-value pair that make up a tag. A key is a general label that acts like a category for more specific tag values.

        

      
      - **Value** *(string) --* 

        The optional part of a key-value pair that make up a tag. A value acts as a descriptor within a tag category (key).

        

      
    

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

    
    ::

      {
          'QueryArn': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **QueryArn** *(string) --* 

        Amazon Resource Name (ARN) of the query. For example, arn:partition:service:region:account-id:resource-type/resource-name/resource-id.

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

  
  *   :py:class:`ConfigService.Client.exceptions.TooManyTagsException`

  
  *   :py:class:`ConfigService.Client.exceptions.ResourceConcurrentModificationException`

  