def suspend_channel()

in serverless/ivs_moderation/lambdas/lambda_api/lib/api_handler.py [0:0]


    def suspend_channel(self, arn):
        """ Function to suspend the channel """

        try:
            ivs_client = boto3.client('ivs')
            if ivs_client.get_stream(channelArn=arn)['stream']['state'] == 'LIVE':
                # Stopping the channel
                ivs_client.stop_stream(channelArn = arn)
            # Get the stream key
            stream_key = ivs_client.list_stream_keys(channelArn = arn)['streamKeys'][0]['arn']
            # Delete the streamkey
            ivs_client.delete_stream_key(arn = stream_key)
            response = 'Channel suspended'
        
        except ClientError as error:
            self.log.error('Server error %s', error)
            response = "Channel suspension failed"
        
        return response