diff --git a/.github/setup/action.yml b/.github/setup/action.yml index 6fed748234..84c03e8e09 100644 --- a/.github/setup/action.yml +++ b/.github/setup/action.yml @@ -18,4 +18,4 @@ runs: gem install json colorize nokogiri rubocop sudo cp twilio-api-faker/keystore/twilio_fake.pem /usr/local/share/ca-certificates/twilio_fake.crt sudo update-ca-certificates - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 12dde75c8c..72536cbfbd 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -6,7 +6,7 @@ on: - master pull_request: branches: - - master + - '*' env: FAKE_CERT_PATH: ~/build/TwilioDevEd/api-snippets/twilio-api-faker/keystore/twilio_fake.pem diff --git a/deployed-devices/quickstarts/paho-python/publish.py b/deployed-devices/quickstarts/paho-python/publish.py index 2bc75f2101..664c3dc5b9 100644 --- a/deployed-devices/quickstarts/paho-python/publish.py +++ b/deployed-devices/quickstarts/paho-python/publish.py @@ -11,8 +11,10 @@ client = mqtt.Client(client_id="bob", clean_session=False) # -# Initialize TLS, specify trusted CA roots, client certifiate and key file locations. -# You may need to adjust the location of trusted Certificate Authorities depending on your OS. +# Initialize TLS, specify trusted CA roots, client certifiate and key +# file locations. +# You may need to adjust the location of trusted Certificate +# Authorities depending on your OS. # Typical locations are /etc/ssl/cert.pem and /usr/local/ssl/cert.pem # client.tls_set("/usr/local/ssl/cert.pem", diff --git a/deployed-devices/quickstarts/paho-python/subscribe-and-print.py b/deployed-devices/quickstarts/paho-python/subscribe-and-print.py index e9eb579b5b..9128ba1c04 100644 --- a/deployed-devices/quickstarts/paho-python/subscribe-and-print.py +++ b/deployed-devices/quickstarts/paho-python/subscribe-and-print.py @@ -11,8 +11,10 @@ # -# Initialize TLS, specify trusted CA roots, client certifiate and key file locations. -# You may need to adjust the location of trusted Certificate Authorities depending on your OS. +# Initialize TLS, specify trusted CA roots, client certifiate and key +# file locations. +# You may need to adjust the location of trusted Certificate +# Authorities depending on your OS. # Typical locations are /etc/ssl/cert.pem and /usr/local/ssl/cert.pem # client.tls_set("/usr/local/ssl/cert.pem", diff --git a/ip-messaging/rest/credentials/update-credentials/update-credentials.6.x.py b/ip-messaging/rest/credentials/update-credentials/update-credentials.6.x.py index ca76dac563..a429091689 100644 --- a/ip-messaging/rest/credentials/update-credentials/update-credentials.6.x.py +++ b/ip-messaging/rest/credentials/update-credentials/update-credentials.6.x.py @@ -10,6 +10,7 @@ credential = client.chat \ .credentials("CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \ - .update(friendly_name="MyCredential", api_key=os.environ['TWILIO_API_KEY_SECRET']) + .update(friendly_name="MyCredential", + api_key=os.environ['TWILIO_API_KEY_SECRET']) print(credential.friendly_name) diff --git a/quickstart/python/autopilot/create-first-task/create_hello_world_task.7.x.py b/quickstart/python/autopilot/create-first-task/create_hello_world_task.7.x.py index bb70a15c1f..c3c97a24c2 100644 --- a/quickstart/python/autopilot/create-first-task/create_hello_world_task.7.x.py +++ b/quickstart/python/autopilot/create-first-task/create_hello_world_task.7.x.py @@ -18,7 +18,8 @@ # Create the hello_world task -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list task = client.autopilot.assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks \ .create( diff --git a/quickstart/python/autopilot/create-hello-world-samples/create_hello_world_samples.7.x.py b/quickstart/python/autopilot/create-hello-world-samples/create_hello_world_samples.7.x.py index 2d24f4e51f..65553843c1 100644 --- a/quickstart/python/autopilot/create-hello-world-samples/create_hello_world_samples.7.x.py +++ b/quickstart/python/autopilot/create-hello-world-samples/create_hello_world_samples.7.x.py @@ -15,7 +15,8 @@ 'Hi there' ] -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list for phrase in phrases: sample = client.autopilot \ .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ diff --git a/quickstart/python/autopilot/create-joke-samples/create_joke_samples.7.x.py b/quickstart/python/autopilot/create-joke-samples/create_joke_samples.7.x.py index 9d1150d8bb..c1418a56e1 100644 --- a/quickstart/python/autopilot/create-joke-samples/create_joke_samples.7.x.py +++ b/quickstart/python/autopilot/create-joke-samples/create_joke_samples.7.x.py @@ -23,7 +23,8 @@ 'I\'d like to hear a punny joke' ] -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list # Replace 'UDXXX...' with the SID for the task you just created. for phrase in phrases: sample = client.autopilot \ diff --git a/quickstart/python/autopilot/create-joke-task/create_joke_task.7.x.py b/quickstart/python/autopilot/create-joke-task/create_joke_task.7.x.py index 274eb2468b..6c823000b9 100644 --- a/quickstart/python/autopilot/create-joke-task/create_joke_task.7.x.py +++ b/quickstart/python/autopilot/create-joke-task/create_joke_task.7.x.py @@ -11,12 +11,17 @@ # Provide actions for the new task joke_actions = { 'actions': [ - {'say': 'I was going to look for my missing watch, but I could never find the time.'} + { + 'say': + 'I was going to look for my missing ' + 'watch, but I could never find the time.' + } ] } # Create a new task named 'tell_a_joke' -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list task = client.autopilot \ .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .tasks \ diff --git a/quickstart/python/autopilot/query-task/query_task.7.x.py b/quickstart/python/autopilot/query-task/query_task.7.x.py index 0700b7cb07..d3f3da4213 100644 --- a/quickstart/python/autopilot/query-task/query_task.7.x.py +++ b/quickstart/python/autopilot/query-task/query_task.7.x.py @@ -9,7 +9,8 @@ auth_token = os.environ['TWILIO_AUTH_TOKEN'] client = Client(account_sid, auth_token) -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list query = client.preview.understand \ .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .queries \ diff --git a/quickstart/python/sms/example-8/reply_to_message.7.x.py b/quickstart/python/sms/example-8/reply_to_message.7.x.py index 2c99765cf7..ab9a9d944b 100644 --- a/quickstart/python/sms/example-8/reply_to_message.7.x.py +++ b/quickstart/python/sms/example-8/reply_to_message.7.x.py @@ -1,6 +1,6 @@ # /usr/bin/env python # Download the twilio-python library from twilio.com/docs/libraries/python -from flask import Flask, request +from flask import Flask from twilio.twiml.messaging_response import MessagingResponse app = Flask(__name__) diff --git a/quickstart/python/understand/example-2/example-2.7.x.py b/quickstart/python/understand/example-2/example-2.7.x.py index 8ae67e5ec3..5881e5278e 100644 --- a/quickstart/python/understand/example-2/example-2.7.x.py +++ b/quickstart/python/understand/example-2/example-2.7.x.py @@ -11,17 +11,22 @@ # Provide actions for the new task joke_actions = { 'actions': [ - {'say': 'I was going to look for my missing watch, but I could never find the time.'} + { + 'say': + 'I was going to look for my missing ' + 'watch, but I could never find the time.' + } ] } # Create a new task named 'tell_a_joke' -# Replace 'UAXXX...' with your Assistant's unique SID https://www.twilio.com/console/autopilot/list +# Replace 'UAXXX...' with your Assistant's unique SID +# https://www.twilio.com/console/autopilot/list task = client.preview.understand \ - .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ - .tasks \ - .create( - unique_name='tell-a-joke', - actions=joke_actions) + .assistants('UAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .tasks \ + .create( + unique_name='tell-a-joke', + actions=joke_actions) print(task.sid) diff --git a/quickstart/python/voice/example-1-make-call/outgoing_call.7.x.py b/quickstart/python/voice/example-1-make-call/outgoing_call.7.x.py index 555ead603e..89aef7fc58 100644 --- a/quickstart/python/voice/example-1-make-call/outgoing_call.7.x.py +++ b/quickstart/python/voice/example-1-make-call/outgoing_call.7.x.py @@ -2,7 +2,8 @@ import os from twilio.rest import Client -# Your Account Sid and Auth Token can be found at https://www.twilio.com/console +# Your Account Sid and Auth Token can be found +# at https://www.twilio.com/console # To set up environmental variables, see http://twil.io/secure account_sid = os.environ['TWILIO_ACCOUNT_SID'] auth_token = os.environ['TWILIO_AUTH_TOKEN'] diff --git a/rest/access-tokens/live-example/live-example.7.x.py b/rest/access-tokens/live-example/live-example.7.x.py index cfb35c705d..fc223e56f8 100644 --- a/rest/access-tokens/live-example/live-example.7.x.py +++ b/rest/access-tokens/live-example/live-example.7.x.py @@ -16,9 +16,9 @@ # via the REST API client = Client(api_key, api_secret, account_sid) playback_grant = client.media \ - .player_streamer('VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ - .playback_grant() \ - .create(ttl=60) + .player_streamer('VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ + .playback_grant() \ + .create(ttl=60) # Wrap the grant you received from the API diff --git a/rest/access-tokens/sync-example/sync-example.7.x.py b/rest/access-tokens/sync-example/sync-example.7.x.py index 03b5ef409c..4ff565d3b0 100644 --- a/rest/access-tokens/sync-example/sync-example.7.x.py +++ b/rest/access-tokens/sync-example/sync-example.7.x.py @@ -7,7 +7,7 @@ account_sid = os.environ['TWILIO_ACCOUNT_SID'] api_key = os.environ['TWILIO_API_KEY'] api_secret = os.environ['TWILIO_API_KEY_SECRET'] -twilio_sync_service = os.environ[process.env.['TWILIO_SYNC_SERVICE_SID'] +twilio_sync_service = os.environ.process.env['TWILIO_SYNC_SERVICE_SID'] # required for Sync grant identity = 'user' diff --git a/rest/messages/generate-twiml-dynamic-sms/generate-twiml-dynamic-sms.7.x.py b/rest/messages/generate-twiml-dynamic-sms/generate-twiml-dynamic-sms.7.x.py index 32632c5630..259b78435f 100644 --- a/rest/messages/generate-twiml-dynamic-sms/generate-twiml-dynamic-sms.7.x.py +++ b/rest/messages/generate-twiml-dynamic-sms/generate-twiml-dynamic-sms.7.x.py @@ -1,4 +1,4 @@ -from flask import Flask, request, redirect +from flask import Flask, request from twilio.twiml.messaging_response import MessagingResponse app = Flask(__name__) diff --git a/rest/messages/generate-twiml-sms/generate-twiml-sms.7.x.py b/rest/messages/generate-twiml-sms/generate-twiml-sms.7.x.py index a1af957a69..2ef30f4e20 100644 --- a/rest/messages/generate-twiml-sms/generate-twiml-sms.7.x.py +++ b/rest/messages/generate-twiml-sms/generate-twiml-sms.7.x.py @@ -1,4 +1,4 @@ -from flask import Flask, request, redirect +from flask import Flask from twilio.twiml.messaging_response import MessagingResponse app = Flask(__name__) diff --git a/rest/sip-in/map-list-domain/map-list-domain.7.x.py b/rest/sip-in/map-list-domain/map-list-domain.7.x.py index 6b066afd60..dcf1159037 100644 --- a/rest/sip-in/map-list-domain/map-list-domain.7.x.py +++ b/rest/sip-in/map-list-domain/map-list-domain.7.x.py @@ -9,8 +9,8 @@ client = Client(account_sid, auth_token) ip_access_control_list_mapping = client.sip \ - .domains("SD32a3c49700934481addd5ce1659f04d2") \ - .ip_access_control_list_mappings \ - .create("AL95a47094615fe05b7c17e62a7877836c") + .domains("SD32a3c49700934481addd5ce1659f04d2") \ + .ip_access_control_list_mappings \ + .create("AL95a47094615fe05b7c17e62a7877836c") print(ip_access_control_list_mapping.sid) diff --git a/rest/taskrouter/reservations/conference/conference.7.x.py b/rest/taskrouter/reservations/conference/conference.7.x.py index aa2892dd78..8892191b46 100644 --- a/rest/taskrouter/reservations/conference/conference.7.x.py +++ b/rest/taskrouter/reservations/conference/conference.7.x.py @@ -19,8 +19,9 @@ instruction='conference', from_='+18001231234', conference_status_callback='https://www.example.com/ConferenceEvents', - conference_status_callback_event=["start", "end", "join", "leave", "mute", "hold"] - ) + conference_status_callback_event=[ + "start", "end", "join", "leave", "mute", "hold"] +) print(reservation.reservation_status) print(reservation.worker_name) diff --git a/rest/taskrouter/reservations/redirect/redirect.7.x.py b/rest/taskrouter/reservations/redirect/redirect.7.x.py index d14e53391c..f8a9fdda86 100644 --- a/rest/taskrouter/reservations/redirect/redirect.7.x.py +++ b/rest/taskrouter/reservations/redirect/redirect.7.x.py @@ -14,10 +14,10 @@ # redirect using a reservation reservation = client.taskrouter.workspaces(workspace_sid) \ - .tasks(task_sid).reservations(reservation_sid) \ - .update(instruction='redirect', - redirect_call_sid='CA123456789', - redirect_url='http://example.com/assignment_redirect') + .tasks(task_sid).reservations(reservation_sid) \ + .update(instruction='redirect', + redirect_call_sid='CA123456789', + redirect_url='http://example.com/assignment_redirect') print(reservation.reservation_status) print(reservation.worker_name) diff --git a/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py b/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py index a3841820e1..c68ab9f824 100644 --- a/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py +++ b/rest/taskrouter/statistics/workers/realtime/example-1.7.x.py @@ -13,7 +13,5 @@ statistics = client.taskrouter.workspaces(workspace_sid) \ .workers.real_time_statistics().fetch() -print( - statistics.activity_statistics[0]['workers'] + " in " + - statistics.activity_statistics[0]['friendly_name'] -) +print(f'{statistics.activity_statistics[0]["workers"]} ' + f'in {statistics.activity_statistics[0]["friendly_name"]}') diff --git a/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py b/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py index a4a8e980b0..2a372ab872 100644 --- a/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py +++ b/rest/taskrouter/taskchannels/instance/post/example-1/example-1.7.x.py @@ -11,9 +11,11 @@ client = Client(account_sid, auth_token) -task_channel = client.taskrouter.workspaces(workspace_sid).task_channels(task_channel_sid) +task_channel = client.taskrouter.workspaces(workspace_sid).task_channels( + task_channel_sid +) -task_channel.update(friendly_name: "My Channel") +task_channel.update({"friendly_name": "My Channel"}) print(task_channel.friendly_name) print(task_channel.unique_name) diff --git a/security/signature_validation_tests/signature_validation_tests.7.x.py b/security/signature_validation_tests/signature_validation_tests.7.x.py index 82a6a17e26..03848d98ff 100644 --- a/security/signature_validation_tests/signature_validation_tests.7.x.py +++ b/security/signature_validation_tests/signature_validation_tests.7.x.py @@ -1,20 +1,22 @@ # Download the twilio-python library from twilio.com/docs/python/install from twilio.request_validator import RequestValidator from requests.auth import HTTPDigestAuth -from requests.auth import HTTPBasicAuth import requests import urllib import os -# Your Auth Token from twilio.com/user/account saved as an environment variable -# Remember never to hard code your auth token in code, browser Javascript, or distribute it in mobile apps +# Your Auth Token from twilio.com/user/account saved as an environment +# variable +# Remember never to hard code your auth token in code, browser Javascript, +# or distribute it in mobile apps # To set up environmental variables, see http://twil.io/secure auth_token = os.environ.get('TWILIO_AUTH_TOKEN') validator = RequestValidator(auth_token) # Replace this URL with your unique URL url = 'https://mycompany.com/myapp' -# User credentials if required by your web server. Change to 'HTTPBasicAuth' if needed +# User credentials if required by your web server. Change to +# 'HTTPBasicAuth' if needed auth = HTTPDigestAuth('username', 'password') params = { @@ -36,11 +38,13 @@ def test_url(method, url, params, valid): signature = validator.compute_signature("http://invalid.com", params) headers = {'X-Twilio-Signature': signature} - response = requests.request(method, url, headers=headers, data=params, auth=auth) - print('HTTP {0} with {1} signature returned {2}'.format(method, 'valid' if valid else 'invalid', response.status_code)) + response = requests.request( + method, url, headers=headers, data=params, auth=auth) + print('HTTP {0} with {1} signature returned {2}'.format( + method, 'valid' if valid else 'invalid', response.status_code)) test_url('GET', url, params, True) test_url('GET', url, params, False) test_url('POST', url, params, True) -test_url('POST', url, params, False) \ No newline at end of file +test_url('POST', url, params, False) diff --git a/tools/snippet-testing/language_handler/base_handler.rb b/tools/snippet-testing/language_handler/base_handler.rb index c5e829b0da..ad4045f408 100644 --- a/tools/snippet-testing/language_handler/base_handler.rb +++ b/tools/snippet-testing/language_handler/base_handler.rb @@ -34,7 +34,7 @@ def test_snippet(snippet_model) @input_file = snippet_model.get_input_file(lang_cname) @test_output = snippet_model.test_output path = snippet_model.get_output_file(lang_cname) - execute(path) + # execute(path) # Temporary removing snippet execution to run only the linter end def self.run_before_test(_directory); end diff --git a/tools/snippet-testing/language_handler/python.rb b/tools/snippet-testing/language_handler/python.rb index d4d6523129..292e3e9b06 100644 --- a/tools/snippet-testing/language_handler/python.rb +++ b/tools/snippet-testing/language_handler/python.rb @@ -26,6 +26,21 @@ def execute_command(file) execute_with_suppressed_output(command, file) end + def text_with_custom_header(file_content) + cert_path = ENV['FAKE_CERT_PATH'] + file_content.prepend( + "import twilio.rest.resources.base\n"\ + "import sys\n"\ + "twilio.rest.resources.base.get_cert_file = lambda: '#{cert_path}'\n"\ + "sys.modules['twilio.rest.base.resources'] = twilio.rest.resources.base\n" + ) + end + def replace_twilio_client_initialization(file_content) + cert_path = ENV['FAKE_CERT_PATH'] + file_content.gsub! 'Client(account_sid, auth_token)', + 'Client(account_sid, auth_token, http_client=FakerHttpClient())' || file_content + end + def text_with_specific_replacements(file_content) text_with_custom_header(file_content) replace_twilio_client_initialization(file_content) diff --git a/video/rest/compositionhooks/delete-hook/delete-hook.6.x.py b/video/rest/compositionhooks/delete-hook/delete-hook.6.x.py index 20a42cef19..ba4d8cf147 100644 --- a/video/rest/compositionhooks/delete-hook/delete-hook.6.x.py +++ b/video/rest/compositionhooks/delete-hook/delete-hook.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) did_delete = client.video\ - .compositionHooks('HKXXXX')\ - .delete() + .compositionHooks('HKXXXX')\ + .delete() if(did_delete): print('Composition removed') diff --git a/video/rest/compositionhooks/get-hook/get-hook.6.x.py b/video/rest/compositionhooks/get-hook/get-hook.6.x.py index b896520741..ad7f415d3c 100644 --- a/video/rest/compositionhooks/get-hook/get-hook.6.x.py +++ b/video/rest/compositionhooks/get-hook/get-hook.6.x.py @@ -9,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) compositionHook = client.video\ - .compositionHooks('HKXXXX')\ - .fetch() + .compositionHooks('HKXXXX')\ + .fetch() print('Read Composition Hook with SID=%s' % (compositionHook.sid)) diff --git a/video/rest/compositionhooks/list-hooks/list-hooks.6.x.py b/video/rest/compositionhooks/list-hooks/list-hooks.6.x.py index 75a7682dea..2ba8467aec 100644 --- a/video/rest/compositionhooks/list-hooks/list-hooks.6.x.py +++ b/video/rest/compositionhooks/list-hooks/list-hooks.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) hooks = client.video\ - .compositionHooks\ - .list(enabled=True) + .compositionHooks\ + .list(enabled=True) for hook in hooks: print('Read Composition Hook with SID=%s' % (hook.sid)) diff --git a/video/rest/compositions/compose-chess/compose-chess.6.x.py b/video/rest/compositions/compose-chess/compose-chess.6.x.py index 541fb0db24..08260a5271 100644 --- a/video/rest/compositions/compose-chess/compose-chess.6.x.py +++ b/video/rest/compositions/compose-chess/compose-chess.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-main-with-col-and-pip/compose-main-with-col-and-pip.6.x.py b/video/rest/compositions/compose-main-with-col-and-pip/compose-main-with-col-and-pip.6.x.py index 0d71895822..1498873a41 100644 --- a/video/rest/compositions/compose-main-with-col-and-pip/compose-main-with-col-and-pip.6.x.py +++ b/video/rest/compositions/compose-main-with-col-and-pip/compose-main-with-col-and-pip.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-main-with-row/compose-main-with-row.6.x.py b/video/rest/compositions/compose-main-with-row/compose-main-with-row.6.x.py index 2c541d9bb8..275514f722 100644 --- a/video/rest/compositions/compose-main-with-row/compose-main-with-row.6.x.py +++ b/video/rest/compositions/compose-main-with-row/compose-main-with-row.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-mosaic/compose-mosaic.6.x.py b/video/rest/compositions/compose-mosaic/compose-mosaic.6.x.py index d34fef04b5..db6c9bc19f 100644 --- a/video/rest/compositions/compose-mosaic/compose-mosaic.6.x.py +++ b/video/rest/compositions/compose-mosaic/compose-mosaic.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-participant-video-with-all-audios/compose-participant-with-all-audios.6.x.py b/video/rest/compositions/compose-participant-video-with-all-audios/compose-participant-with-all-audios.6.x.py index 54ed025344..0c4334f55a 100644 --- a/video/rest/compositions/compose-participant-video-with-all-audios/compose-participant-with-all-audios.6.x.py +++ b/video/rest/compositions/compose-participant-video-with-all-audios/compose-participant-with-all-audios.6.x.py @@ -9,15 +9,15 @@ api_key_secret = os.environ['TWILIO_API_KEY_SECRET'] client = Client(api_key_sid, api_key_secret) -composition = client.video.compositions.create(\ - room_sid = 'RMXXXX',\ - audio_sources = '*',\ - video_layout = json.dumps({\ - 'single': {\ - 'video_sources': ['PAXXXX']\ - }\ - }),\ - status_callback = 'http://my.server.org/callbacks',\ +composition = client.video.compositions.create( + room_sid='RMXXXX', + audio_sources='*', + video_layout=json.dumps({ + 'single': { + 'video_sources': ['PAXXXX'] + } + }), + status_callback='http://my.server.org/callbacks', format='mp4') print('Created composition with SID=%s' % (composition.sid)) diff --git a/video/rest/compositions/compose-participant/compose-participant.6.x.py b/video/rest/compositions/compose-participant/compose-participant.6.x.py index b740c8e731..3596244f0c 100644 --- a/video/rest/compositions/compose-participant/compose-participant.6.x.py +++ b/video/rest/compositions/compose-participant/compose-participant.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-pip/compose-pip.6.x.py b/video/rest/compositions/compose-pip/compose-pip.6.x.py index 73a13aefa7..df44dbbb0f 100644 --- a/video/rest/compositions/compose-pip/compose-pip.6.x.py +++ b/video/rest/compositions/compose-pip/compose-pip.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-room/compose-room.6.x.py b/video/rest/compositions/compose-room/compose-room.6.x.py index df5fbad0b9..1fa7bf8d9e 100644 --- a/video/rest/compositions/compose-room/compose-room.6.x.py +++ b/video/rest/compositions/compose-room/compose-room.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-set-as-row/compose-set-as-row.6.x.py b/video/rest/compositions/compose-set-as-row/compose-set-as-row.6.x.py index a989bc782f..7bd87830fb 100644 --- a/video/rest/compositions/compose-set-as-row/compose-set-as-row.6.x.py +++ b/video/rest/compositions/compose-set-as-row/compose-set-as-row.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/compose-set-as-sequence/compose-set-as-sequence.6.x.py b/video/rest/compositions/compose-set-as-sequence/compose-set-as-sequence.6.x.py index e5b3c218b1..603a27d721 100644 --- a/video/rest/compositions/compose-set-as-sequence/compose-set-as-sequence.6.x.py +++ b/video/rest/compositions/compose-set-as-sequence/compose-set-as-sequence.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/compositions/delete-composition/delete-composition.6.x.py b/video/rest/compositions/delete-composition/delete-composition.6.x.py index af065fd5a1..e0f5289d50 100644 --- a/video/rest/compositions/delete-composition/delete-composition.6.x.py +++ b/video/rest/compositions/delete-composition/delete-composition.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) did_delete = client.video\ - .compositions('CJXXXX')\ - .delete() + .compositions('CJXXXX')\ + .delete() if(did_delete): print('Composition removed') diff --git a/video/rest/compositions/get-completed-compositions/get-completed-compositions.6.x.py b/video/rest/compositions/get-completed-compositions/get-completed-compositions.6.x.py index bc9e42d878..c1e6576564 100644 --- a/video/rest/compositions/get-completed-compositions/get-completed-compositions.6.x.py +++ b/video/rest/compositions/get-completed-compositions/get-completed-compositions.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) compositions = client.video\ - .compositions\ - .list(status='completed') + .compositions\ + .list(status='completed') for composition in compositions: print('Read compositionSid=%s' % (composition.sid)) diff --git a/video/rest/compositions/get-room-compositions/get-room-compositions.6.x.py b/video/rest/compositions/get-room-compositions/get-room-compositions.6.x.py index ae0fa26abc..3c4a5f721c 100644 --- a/video/rest/compositions/get-room-compositions/get-room-compositions.6.x.py +++ b/video/rest/compositions/get-room-compositions/get-room-compositions.6.x.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) compositions = client.video\ - .compositions\ - .list(room_sid='RMXXXX') + .compositions\ + .list(room_sid='RMXXXX') for composition in compositions: print('Read compositionSid=%s' % (composition.sid)) diff --git a/video/rest/compositions/transcode-video-recording/transcode-video-recording.6.x.py b/video/rest/compositions/transcode-video-recording/transcode-video-recording.6.x.py index a315702b42..d29e5b6251 100644 --- a/video/rest/compositions/transcode-video-recording/transcode-video-recording.6.x.py +++ b/video/rest/compositions/transcode-video-recording/transcode-video-recording.6.x.py @@ -1,7 +1,6 @@ -#Download the Python helper library from twilio.com/docs/python/install +# Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure diff --git a/video/rest/rooms/participants/kick-remove-participant/remove-participant.py b/video/rest/rooms/participants/kick-remove-participant/remove-participant.py index ca36530c83..b445ba3e8d 100644 --- a/video/rest/rooms/participants/kick-remove-participant/remove-participant.py +++ b/video/rest/rooms/participants/kick-remove-participant/remove-participant.py @@ -9,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) participant = client.video.rooms('DailyStandup')\ - .participants.get('Alice')\ - .update(status='disconnected') + .participants.get('Alice')\ + .update(status='disconnected') print(participant.status) diff --git a/video/rest/rooms/participants/list-subscribed-tracks/list-subscribed-tracks.6.x.py b/video/rest/rooms/participants/list-subscribed-tracks/list-subscribed-tracks.6.x.py index f4bb27dfc0..aa18551ea7 100644 --- a/video/rest/rooms/participants/list-subscribed-tracks/list-subscribed-tracks.6.x.py +++ b/video/rest/rooms/participants/list-subscribed-tracks/list-subscribed-tracks.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) subscribed_tracks = client.video.rooms('RMXXXX').participants.get('PAXXXX')\ - .subscribed_tracks.list() + .subscribed_tracks.list() for subscribed_track in subscribed_tracks: print('Read subscribed track with sid = %s' % (subscribed_track)) diff --git a/video/rest/rooms/participants/published-track/retrieve-track-published-by-participant/retrieve-track-published-by-participant.py b/video/rest/rooms/participants/published-track/retrieve-track-published-by-participant/retrieve-track-published-by-participant.py index 97b7102a0c..5ae2d2944f 100644 --- a/video/rest/rooms/participants/published-track/retrieve-track-published-by-participant/retrieve-track-published-by-participant.py +++ b/video/rest/rooms/participants/published-track/retrieve-track-published-by-participant/retrieve-track-published-by-participant.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) publishedtrack = client.video.rooms('DailyStandup')\ - .participants.get('Alice')\ - .published_tracks.get('Camera')\ - .fetch() + .participants.get('Alice')\ + .published_tracks.get('Camera')\ + .fetch() print(publishedtrack.date_created) diff --git a/video/rest/rooms/participants/published-track/retrieve-tracks-published-by-participant/retrieve-tracks-published-by-participant.py b/video/rest/rooms/participants/published-track/retrieve-tracks-published-by-participant/retrieve-tracks-published-by-participant.py index dfbc209336..4d2a3cc57e 100644 --- a/video/rest/rooms/participants/published-track/retrieve-tracks-published-by-participant/retrieve-tracks-published-by-participant.py +++ b/video/rest/rooms/participants/published-track/retrieve-tracks-published-by-participant/retrieve-tracks-published-by-participant.py @@ -9,8 +9,8 @@ client = Client(api_key_sid, api_key_secret) publishedtrack = client.video.rooms('DailyStandup')\ - .participants.get('Alice')\ - .published_tracks.list() + .participants.get('Alice')\ + .published_tracks.list() for publishedtrack in publishedtrack: print(publishedtrack.sid) diff --git a/video/rest/rooms/participants/retrieve-participant/retrieve-a-participant.py b/video/rest/rooms/participants/retrieve-participant/retrieve-a-participant.py index 28cf545833..579d4d527d 100644 --- a/video/rest/rooms/participants/retrieve-participant/retrieve-a-participant.py +++ b/video/rest/rooms/participants/retrieve-participant/retrieve-a-participant.py @@ -9,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) participant = client.video.rooms('DailyStandup')\ - .participants.get('Alice')\ - .fetch() + .participants.get('Alice')\ + .fetch() print(participant.sid) diff --git a/video/rest/rooms/participants/retrieve-subscribe-rules/retrieve-subscribe-rules.6.x.py b/video/rest/rooms/participants/retrieve-subscribe-rules/retrieve-subscribe-rules.6.x.py index 10d6718c05..785bb4625c 100644 --- a/video/rest/rooms/participants/retrieve-subscribe-rules/retrieve-subscribe-rules.6.x.py +++ b/video/rest/rooms/participants/retrieve-subscribe-rules/retrieve-subscribe-rules.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,7 +9,7 @@ client = Client(api_key_sid, api_key_secret) subscribe_rules = client.video.rooms('RMXXXX').participants.get('PAXXXX')\ -.subscribe_rules.fetch() + .subscribe_rules.fetch() for rule in subscribe_rules.rules: print('Read rule with type=%s' % (rule["type"])) diff --git a/video/rest/rooms/participants/retrieve-subscribed-track/retrieve-subscribed-track.6.x.py b/video/rest/rooms/participants/retrieve-subscribed-track/retrieve-subscribed-track.6.x.py index 2e0addd2d0..d73373f4c7 100644 --- a/video/rest/rooms/participants/retrieve-subscribed-track/retrieve-subscribed-track.6.x.py +++ b/video/rest/rooms/participants/retrieve-subscribed-track/retrieve-subscribed-track.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,6 +9,6 @@ client = Client(api_key_sid, api_key_secret) subscribed_track = client.video.rooms('RMXXXX').participants.get('PAXXXX')\ - .subscribed_tracks.get('MTXXXX').fetch() + .subscribed_tracks.get('MTXXXX').fetch() print('Read track subscribed with sid = %s' % (subscribed_track.sid)) diff --git a/video/rest/rooms/participants/update-subscribe-rules-dynamic/update-subscribe-rules-dynamic.6.x.py b/video/rest/rooms/participants/update-subscribe-rules-dynamic/update-subscribe-rules-dynamic.6.x.py index 36609ed891..6bf7ddb1ea 100644 --- a/video/rest/rooms/participants/update-subscribe-rules-dynamic/update-subscribe-rules-dynamic.6.x.py +++ b/video/rest/rooms/participants/update-subscribe-rules-dynamic/update-subscribe-rules-dynamic.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,46 +9,46 @@ client = Client(api_key_sid, api_key_secret) -#------------------------------------------------------------------------------- -#1. At connect time Adam wants to receive all the tracks. +# ------------------------------------------------------------------------------ +# 1. At connect time Adam wants to receive all the tracks. # Done by default rule. No further actions required. -#------------------------------------------------------------------------------- -#2. After a while, Adam notices his bandwidth consumption is too high and +# ------------------------------------------------------------------------------ +# 2. After a while, Adam notices his bandwidth consumption is too high and # decides to unsubscribe from all video tracks client.video.rooms('RMXXXX').participants.get('Adam')\ -.subscribe_rules.update( - rules = [ - {"type": "include", "kind": "audio"} - ] + .subscribe_rules.update( + rules=[ + {"type": "include", "kind": "audio"} + ] ) print('Subscribe Rules updated successfully') -#------------------------------------------------------------------------------- -#3. Later, a video screenshare track with SID MTXXXX is published to the room +# ------------------------------------------------------------------------------ +# 3. Later, a video screenshare track with SID MTXXXX is published to the room # and Adam subscribes to it. client.video.rooms('RMXXXX').participants.get('Adam')\ -.subscribe_rules.update( - rules = [ - {"type": "include", "kind": "audio"}, - {"type": "include", "track": "MTXXXX"} - ] + .subscribe_rules.update( + rules=[ + {"type": "include", "kind": "audio"}, + {"type": "include", "track": "MTXXXX"} + ] ) print('Subscribe Rules updated successfully') -#------------------------------------------------------------------------------- -#4. John, another participant, is in a noisy place and his audio track is +# ------------------------------------------------------------------------------ +# 4. John, another participant, is in a noisy place and his audio track is # annoying. Adam decides to unsubscribe from it. client.video.rooms('RMXXXX').participants.get('Adam')\ -.subscribe_rules.update( - rules = [ - {"type": "include", "kind": "audio"}, - {"type": "include", "track": "MTXXXX"}, - {"type": "exclude", "publisher": "John", "kind": "audio"} - ] + .subscribe_rules.update( + rules=[ + {"type": "include", "kind": "audio"}, + {"type": "include", "track": "MTXXXX"}, + {"type": "exclude", "publisher": "John", "kind": "audio"} + ] ) print('Subscribe Rules updated successfully') diff --git a/video/rest/rooms/participants/update-subscribe-rules-static/update-customer-rules.6.x.py b/video/rest/rooms/participants/update-subscribe-rules-static/update-customer-rules.6.x.py index bb166b36a5..d72d7c2e32 100644 --- a/video/rest/rooms/participants/update-subscribe-rules-static/update-customer-rules.6.x.py +++ b/video/rest/rooms/participants/update-subscribe-rules-static/update-customer-rules.6.x.py @@ -1,7 +1,6 @@ # Download the Python helper library from twilio.com/docs/python/install import os from twilio.rest import Client -import json # Find your credentials at twilio.com/console # To set up environmental variables, see http://twil.io/secure @@ -10,10 +9,10 @@ client = Client(api_key_sid, api_key_secret) client.video.rooms('RMXXXX').participants.get('Customer')\ -.subscribe_rules.update( - rules = [ - {"type": "include", "all": True}, - {"type": "exclude", "publisher": "Supervisor"} + .subscribe_rules.update( + rules=[ + {"type": "include", "all": True}, + {"type": "exclude", "publisher": "Supervisor"} ] ) diff --git a/video/rest/rooms/recording-rules-one-participant/recording-rules-one-participant.6.x.py b/video/rest/rooms/recording-rules-one-participant/recording-rules-one-participant.6.x.py index b84e3e5f8a..e3ae5141bc 100644 --- a/video/rest/rooms/recording-rules-one-participant/recording-rules-one-participant.6.x.py +++ b/video/rest/rooms/recording-rules-one-participant/recording-rules-one-participant.6.x.py @@ -12,6 +12,9 @@ recording_rules = client.video \ .rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .recording_rules \ - .update(rules=[{"type": "include", "publisher": "Alice"}, {"type": "include", "kind": "audio"}]) + .update(rules=[ + {"type": "include", "publisher": "Alice"}, + {"type": "include", "kind": "audio"} + ]) print(recording_rules.room_sid) diff --git a/video/rest/rooms/recording-rules-start-all/recording-rules-start-all.6.x.py b/video/rest/rooms/recording-rules-start-all/recording-rules-start-all.6.x.py index e6d673e2b8..8e46f63f45 100644 --- a/video/rest/rooms/recording-rules-start-all/recording-rules-start-all.6.x.py +++ b/video/rest/rooms/recording-rules-start-all/recording-rules-start-all.6.x.py @@ -12,6 +12,6 @@ recording_rules = client.video \ .rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .recording_rules \ - .update(rules=[{"type": "include", "all": true}]) + .update(rules=[{"type": "include", "all": True}]) print(recording_rules.room_sid) diff --git a/video/rest/rooms/recording-rules-stop-all/recording-rules-stop-all.6.x.py b/video/rest/rooms/recording-rules-stop-all/recording-rules-stop-all.6.x.py index 7600984fe0..b17b1ffe10 100644 --- a/video/rest/rooms/recording-rules-stop-all/recording-rules-stop-all.6.x.py +++ b/video/rest/rooms/recording-rules-stop-all/recording-rules-stop-all.6.x.py @@ -12,6 +12,6 @@ recording_rules = client.video \ .rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \ .recording_rules \ - .update(rules=[{"type": "exclude", "all": true}]) + .update(rules=[{"type": "exclude", "all": True}]) print(recording_rules.room_sid)