""" http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from botocore.vendored import requests import boto3 import json import string import random import resource_tools def update_endpoint(mediapackage, create_endpoint, event, context): """ Update a MediaPackage channel Return the channel URL, username and password generated by MediaPackage """ endpoint_id = event["PhysicalResourceId"] try: result = delete_endpoint(mediapackage, event, context) if result['Status'] == 'SUCCESS': result = create_endpoint(mediapackage, event, context, False) except Exception as ex: print(ex) result = { 'Status': 'FAILED', 'Data': {"Exception": str(ex)}, 'ResourceId': endpoint_id } return result def delete_endpoint(mediapackage, event, context): """ Delete a MediaPackage channel Return success/failure """ endpoint_id = event["PhysicalResourceId"] try: response = mediapackage.delete_origin_endpoint(Id=endpoint_id) result = { 'Status': 'SUCCESS', 'Data': response, 'ResourceId': endpoint_id } except Exception as ex: print(ex) result = { 'Status': 'FAILED', 'Data': {"Exception": str(ex)}, 'ResourceId': endpoint_id } return result