:doc:`IoTAnalytics <../../iotanalytics>` / Client / create_channel

**************
create_channel
**************



.. py:method:: IoTAnalytics.Client.create_channel(**kwargs)

  

  Used to create a channel. A channel collects data from an MQTT topic and archives the raw, unprocessed messages before publishing the data to a pipeline.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/iotanalytics-2017-11-27/CreateChannel>`_  


  **Request Syntax**
  ::

    response = client.create_channel(
        channelName='string',
        channelStorage={
            'serviceManagedS3': {}
            ,
            'customerManagedS3': {
                'bucket': 'string',
                'keyPrefix': 'string',
                'roleArn': 'string'
            }
        },
        retentionPeriod={
            'unlimited': True|False,
            'numberOfDays': 123
        },
        tags=[
            {
                'key': 'string',
                'value': 'string'
            },
        ]
    )
    
  :type channelName: string
  :param channelName: **[REQUIRED]** 

    The name of the channel.

    

  
  :type channelStorage: dict
  :param channelStorage: 

    Where channel data is stored. You can choose one of ``serviceManagedS3`` or ``customerManagedS3`` storage. If not specified, the default is ``serviceManagedS3``. You can't change this storage option after the channel is created.

    

  
    - **serviceManagedS3** *(dict) --* 

      Used to store channel data in an S3 bucket managed by IoT Analytics. You can't change the choice of S3 storage after the data store is created.

      

    
    
    - **customerManagedS3** *(dict) --* 

      Used to store channel data in an S3 bucket that you manage. If customer managed storage is selected, the ``retentionPeriod`` parameter is ignored. You can't change the choice of S3 storage after the data store is created.

      

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

        The name of the S3 bucket in which channel data is stored.

        

      
      - **keyPrefix** *(string) --* 

        (Optional) The prefix used to create the keys of the channel data objects. Each object in an S3 bucket has a key that is its unique identifier in the bucket. Each object in a bucket has exactly one key. The prefix must end with a forward slash (/).

        

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

        The ARN of the role that grants IoT Analytics permission to interact with your Amazon S3 resources.

        

      
    
  
  :type retentionPeriod: dict
  :param retentionPeriod: 

    How long, in days, message data is kept for the channel. When ``customerManagedS3`` storage is selected, this parameter is ignored.

    

  
    - **unlimited** *(boolean) --* 

      If true, message data is kept indefinitely.

      

    
    - **numberOfDays** *(integer) --* 

      The number of days that message data is kept. The ``unlimited`` parameter must be false.

      

    
  
  :type tags: list
  :param tags: 

    Metadata which can be used to manage the channel.

    

  
    - *(dict) --* 

      A set of key-value pairs that are used to manage the resource.

      

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

        The tag's key.

        

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

        The tag's value.

        

      
    

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

    
    ::

      {
          'channelName': 'string',
          'channelArn': 'string',
          'retentionPeriod': {
              'unlimited': True|False,
              'numberOfDays': 123
          }
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **channelName** *(string) --* 

        The name of the channel.

        
      

      - **channelArn** *(string) --* 

        The ARN of the channel.

        
      

      - **retentionPeriod** *(dict) --* 

        How long, in days, message data is kept for the channel.

        
        

        - **unlimited** *(boolean) --* 

          If true, message data is kept indefinitely.

          
        

        - **numberOfDays** *(integer) --* 

          The number of days that message data is kept. The ``unlimited`` parameter must be false.

          
    
  
  **Exceptions**
  
  *   :py:class:`IoTAnalytics.Client.exceptions.InvalidRequestException`

  
  *   :py:class:`IoTAnalytics.Client.exceptions.ResourceAlreadyExistsException`

  
  *   :py:class:`IoTAnalytics.Client.exceptions.InternalFailureException`

  
  *   :py:class:`IoTAnalytics.Client.exceptions.ServiceUnavailableException`

  
  *   :py:class:`IoTAnalytics.Client.exceptions.ThrottlingException`

  
  *   :py:class:`IoTAnalytics.Client.exceptions.LimitExceededException`

  