diff --git a/scripts/build_twilio_library.py b/scripts/build_twilio_library.py index 3861ae2c6..43555fd66 100644 --- a/scripts/build_twilio_library.py +++ b/scripts/build_twilio_library.py @@ -21,7 +21,7 @@ generateForLanguages = { 'twilio_iam_organizations.json' : ['java', 'csharp'] } -dynamic_languages = ['node', 'python'] +dynamic_languages = ['node'] CLEANUP_IMPORT_LANGUAGES = ['java', 'php'] REMOVE_DUPLICATE_IMPORT_LANGUAGES = ['node'] CONFIG_FOLDER = 'tmp' diff --git a/src/main/resources/twilio-python/context.handlebars b/src/main/resources/twilio-python/context.handlebars index 08a7a6b89..1f52ea3ed 100644 --- a/src/main/resources/twilio-python/context.handlebars +++ b/src/main/resources/twilio-python/context.handlebars @@ -61,10 +61,9 @@ class {{apiName}}Context(InstanceContext): {{paramName}}=self._solution['{{paramName}}']{{/instancePathParams}} ) {{/vendorExtensions.x-is-update-operation}}{{#vendorExtensions.x-is-fetch-operation}} - {{#vendorExtensions.x-twilio.ignoreOperation}} def {{vendorExtensions.x-name-lower}}(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> {{instanceName}}: """ - Fetch1 the {{instanceName}} + Fetch the {{instanceName}} {{#allParams}} :param {{paramName}}: {{{description}}}{{/allParams}} @@ -107,7 +106,6 @@ class {{apiName}}Context(InstanceContext): {{#instancePathParams}}{{paramName}}=self._solution['{{paramName}}'], {{/instancePathParams}} ) - {{/vendorExtensions.x-twilio.ignoreOperation}} {{/vendorExtensions.x-is-fetch-operation}}{{#vendorExtensions.x-is-delete-operation}} def {{vendorExtensions.x-name-lower}}(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> bool: """ diff --git a/src/main/resources/twilio-python/instance.handlebars b/src/main/resources/twilio-python/instance.handlebars index 92bb65b45..f9e8dc750 100644 --- a/src/main/resources/twilio-python/instance.handlebars +++ b/src/main/resources/twilio-python/instance.handlebars @@ -38,6 +38,7 @@ class {{instanceName}}(InstanceResource): :returns: The updated {{instanceName}} """ return self._proxy.update({{#allParams}}{{paramName}}={{paramName}}, {{/allParams}}) + async def {{vendorExtensions.x-name-lower}}_async(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> "{{instanceName}}": """ Asynchronous coroutine to update the {{instanceName}} @@ -48,10 +49,9 @@ class {{instanceName}}(InstanceResource): """ return await self._proxy.update_async({{#allParams}}{{paramName}}={{paramName}}, {{/allParams}}) {{/vendorExtensions.x-is-update-operation}}{{#vendorExtensions.x-is-fetch-operation}} - {{#vendorExtensions.x-twilio.ignoreOperation}} def {{vendorExtensions.x-name-lower}}(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> "{{instanceName}}": """ - Fetch2 the {{instanceName}} + Fetch the {{instanceName}} {{#allParams}} :param {{paramName}}: {{{description}}}{{/allParams}} @@ -68,7 +68,6 @@ class {{instanceName}}(InstanceResource): :returns: The fetched {{instanceName}} """ return await self._proxy.fetch_async({{#allParams}}{{paramName}}={{paramName}}, {{/allParams}}) - {{/vendorExtensions.x-twilio.ignoreOperation}} {{/vendorExtensions.x-is-fetch-operation}}{{#vendorExtensions.x-is-delete-operation}} def {{vendorExtensions.x-name-lower}}(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> bool: """ @@ -108,8 +107,7 @@ class {{instanceName}}(InstanceResource): """ return await self._proxy.create_async({{#allParams}}{{paramName}}{{#if required}}{{else}}={{paramName}}{{/if}}, {{/allParams}}) {{/vendorExtensions.x-is-create-operation}}{{/vendorExtensions.x-is-context-operation}}{{/operations}}{{#dependents}}{{#instanceDependent}} - - @property + @property def {{mountName}}(self) -> {{listName}}: """ Access the {{mountName}} diff --git a/src/main/resources/twilio-python/listOperations.handlebars b/src/main/resources/twilio-python/listOperations.handlebars index cb722d82c..92713c7ec 100644 --- a/src/main/resources/twilio-python/listOperations.handlebars +++ b/src/main/resources/twilio-python/listOperations.handlebars @@ -1,6 +1,5 @@ {{#operations}} {{#vendorExtensions.x-is-create-operation}} - {{^vendorExtensions.x-twilio.ignoreOperation}} def create(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> {{instanceName}}: """ Create the {{instanceName}} @@ -52,8 +51,7 @@ payload = await self._version.create_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, {{#hasParams}}data=data,{{/hasParams}} headers=headers{{#queryParams.0}}, params=params{{/queryParams.0}}) return {{instanceName}}(self._version, payload{{#listPathParams}}, {{paramName}}=self._solution['{{paramName}}']{{/listPathParams}}) - {{/vendorExtensions.x-twilio.ignoreOperation}}{{/vendorExtensions.x-is-create-operation}}{{^instancePath}}{{#vendorExtensions.x-is-fetch-operation}} - {{^vendorExtensions.x-twilio.ignoreOperation}} + {{/vendorExtensions.x-is-create-operation}}{{^instancePath}}{{#vendorExtensions.x-is-fetch-operation}} def fetch(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> {{instanceName}}: """ Asynchronously fetch the {{instanceName}} @@ -94,7 +92,7 @@ {{/queryParams.0}} payload = await self._version.fetch_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, headers=headers{{#queryParams.0}}, params=params{{/queryParams.0}}) - return {{instanceName}}(self._version, payload{{#listPathParams}}, {{paramName}}=self._solution['{{paramName}}']{{/listPathParams}}){{/vendorExtensions.x-twilio.ignoreOperation}}{{/vendorExtensions.x-is-fetch-operation}}{{#vendorExtensions.x-is-delete-operation}}{{^vendorExtensions.x-twilio.ignoreOperation}} + return {{instanceName}}(self._version, payload{{#listPathParams}}, {{paramName}}=self._solution['{{paramName}}']{{/listPathParams}}){{/vendorExtensions.x-is-fetch-operation}}{{#vendorExtensions.x-is-delete-operation}} def delete(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> bool: """ Asynchronously delete the {{instanceName}} @@ -129,7 +127,7 @@ {{#queryParams}}'{{{baseName}}}': {{paramName}}, {{/queryParams}} }){{/queryParams.0}} - return await self._version.delete_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, headers=headers{{#queryParams.0}}, params=params{{/queryParams.0}}){{/vendorExtensions.x-twilio.ignoreOperation}}{{/vendorExtensions.x-is-delete-operation}}{{#vendorExtensions.x-is-update-operation}}{{^vendorExtensions.x-twilio.ignoreOperation}} + return await self._version.delete_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, headers=headers{{#queryParams.0}}, params=params{{/queryParams.0}}){{/vendorExtensions.x-is-delete-operation}}{{#vendorExtensions.x-is-update-operation}} def update(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> {{instanceName}}: """ @@ -181,7 +179,7 @@ {{/queryParams.0}} payload = await self._version.update_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, {{#hasParams}}data=data,{{/hasParams}} headers=headers{{#queryParams.0}}, params=params{{/queryParams.0}}) - return {{instanceName}}(self._version, payload{{#listPathParams}}, {{paramName}}=self._solution['{{paramName}}']{{/listPathParams}}){{/vendorExtensions.x-twilio.ignoreOperation}}{{/vendorExtensions.x-is-update-operation}}{{/instancePath}}{{#vendorExtensions.x-is-read-operation}}{{^vendorExtensions.x-twilio.ignoreOperation}} + return {{instanceName}}(self._version, payload{{#listPathParams}}, {{paramName}}=self._solution['{{paramName}}']{{/listPathParams}}){{/vendorExtensions.x-is-update-operation}}{{/instancePath}}{{#vendorExtensions.x-is-read-operation}} def stream(self, {{#allParams}} {{#startsWith paramName text='page_size'}}{{else}}{{paramName}}: Union[{{{dataType}}}, object] = values.unset,{{/startsWith}}{{/allParams}} limit: Optional[int] = None, @@ -375,5 +373,4 @@ target_url ) return {{apiName}}Page(self._version, response{{#if listPathParams}}, self._solution{{/if}}) - {{/vendorExtensions.x-twilio.ignoreOperation}} {{/vendorExtensions.x-is-read-operation}}{{/operations}} diff --git a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java index 4d1406359..12f8f1af5 100644 --- a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java +++ b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java @@ -28,7 +28,14 @@ public class TwilioGeneratorTest { @Parameterized.Parameters public static Collection generators() { - return Arrays.asList(Generator.TWILIO_PYTHON); + return Arrays.asList(Generator.TWILIO_CSHARP, + Generator.TWILIO_GO, + Generator.TWILIO_JAVA, + Generator.TWILIO_NODE, + Generator.TWILIO_PHP, + Generator.TWILIO_PYTHON, + Generator.TWILIO_RUBY, + Generator.TWILIO_TERRAFORM); } private final Generator generator; @@ -40,7 +47,7 @@ public static void setUp() { @Test public void launchGenerator() { - final String pathname = "/Users/asabu/di/codehq2024/PythonOAI/twilio-oai/spec/json/twilio_iam_organization_versionless.json"; + final String pathname = "examples/spec/twilio_api_v2010.yaml"; File filesList[] ; File directoryPath = new File(pathname); if (directoryPath.isDirectory()) {