Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix_orgs_api' into fix_orgs_api
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed Dec 4, 2024
2 parents 059e135 + e32f3b6 commit 47d2dd7
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 12 deletions.
72 changes: 62 additions & 10 deletions src/main/resources/twilio-python/context.handlebars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class {{apiName}}Context(InstanceContext):

{{#if nestedModels}}{{>modelClasses}}{{/if}}
def __init__(self, version: Version{{#instancePathParams}}, {{paramName}}: {{{dataType}}}{{/instancePathParams}}):
"""
Initialize the {{apiName}}Context
Expand Down Expand Up @@ -30,9 +30,17 @@ class {{apiName}}Context(InstanceContext):
data = values.of({ {{#allParams}}{{#isFormParam}}
'{{{baseName}}}': {{#if vendorExtensions.x-serialize}}{{vendorExtensions.x-serialize}}({{paramName}}{{#if isArray}}, lambda e: e){{else}}){{/if}}{{else}}{{paramName}}{{/if}},{{/isFormParam}}{{/allParams}}
})
{{#allParams}}{{#isHeaderParam}}headers = values.of({'{{{baseName}}}': {{paramName}}, }){{/isHeaderParam}}{{/allParams}}

payload = self._version.update(method='{{vendorExtensions.x-http-method}}', uri=self._uri, data=data,{{#allParams}}{{#if isFormParam}}{{else}}{{#if isHeaderParam}} headers=headers{{/if}}{{/if}}{{/allParams}})
headers = values.of({})
{{#allParams}}{{#isHeaderParam}}headers['{{{baseName}}}'] = {{paramName}}{{/isHeaderParam}}{{/allParams}}
{{#consumes}}
headers["Content-Type"] = "{{{mediaType}}}"
{{/consumes}}
{{#produces}}
headers["Accept"] = "{{{mediaType}}}"
{{/produces}}

payload = self._version.update(method='{{vendorExtensions.x-http-method}}', uri=self._uri, data=data, headers=headers)

return {{instanceName}}(
self._version,
Expand All @@ -51,9 +59,16 @@ class {{apiName}}Context(InstanceContext):
data = values.of({ {{#allParams}}{{#isFormParam}}
'{{{baseName}}}': {{#if vendorExtensions.x-serialize}}{{vendorExtensions.x-serialize}}({{paramName}}{{#if isArray}}, lambda e: e){{else}}){{/if}}{{else}}{{paramName}}{{/if}},{{/isFormParam}}{{/allParams}}
})
{{#allParams}}{{#isHeaderParam}}headers = values.of({'{{{baseName}}}': {{paramName}}, }){{/isHeaderParam}}{{/allParams}}
headers = values.of({})
{{#allParams}}{{#isHeaderParam}}headers['{{{baseName}}}'] = {{paramName}}{{/isHeaderParam}}{{/allParams}}
{{#consumes}}
headers["Content-Type"] = "{{{mediaType}}}"
{{/consumes}}
{{#produces}}
headers["Accept"] = "{{{mediaType}}}"
{{/produces}}

payload = await self._version.update_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, data=data,{{#allParams}}{{#if isFormParam}}{{else}}{{#if isHeaderParam}} headers=headers{{/if}}{{/if}}{{/allParams}})
payload = await self._version.update_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, data=data, headers=headers)

return {{instanceName}}(
self._version,
Expand All @@ -63,7 +78,7 @@ class {{apiName}}Context(InstanceContext):
{{/vendorExtensions.x-twilio.ignoreOperation}}{{/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}}:
"""
Fetch the {{instanceName}}
Fetch1 the {{instanceName}}
{{#allParams}}
:param {{paramName}}: {{{description}}}{{/allParams}}

Expand All @@ -73,9 +88,18 @@ class {{apiName}}Context(InstanceContext):
data = values.of({ {{#allParams}}{{#if vendorExtensions.x-prefixed-collapsible-map}}{{else}}
'{{{baseName}}}': {{#if vendorExtensions.x-serialize}}{{vendorExtensions.x-serialize}}({{paramName}}{{#if isArray}}, lambda e: e){{else}}){{/if}}{{else}}{{paramName}}{{/if}},{{/if}}{{/allParams}}
})

{{#allParams}}{{#if vendorExtensions.x-prefixed-collapsible-map}}data.update({{vendorExtensions.x-serialize}}({{paramName}}, '{{vendorExtensions.x-prefixed-collapsible-map}}'))
{{/if}}{{/allParams}}{{/if}}
payload = self._version.fetch(method='{{vendorExtensions.x-http-method}}', uri=self._uri, {{#if allParams}}params=data{{/if}})

headers = values.of({})
{{#consumes}}
headers["Content-Type"] = "{{{mediaType}}}"
{{/consumes}}
{{#produces}}
headers["Accept"] = "{{{mediaType}}}"
{{/produces}}
payload = self._version.fetch(method='{{vendorExtensions.x-http-method}}', uri=self._uri {{#if allParams}}, params=data{{/if}} , headers=headers)

return {{instanceName}}(
self._version,
Expand All @@ -96,9 +120,18 @@ class {{apiName}}Context(InstanceContext):
data = values.of({ {{#allParams}}{{#if vendorExtensions.x-prefixed-collapsible-map}}{{else}}
'{{{baseName}}}': {{#if vendorExtensions.x-serialize}}{{vendorExtensions.x-serialize}}({{paramName}}{{#if isArray}}, lambda e: e){{else}}){{/if}}{{else}}{{paramName}}{{/if}},{{/if}}{{/allParams}}
})

{{#allParams}}{{#if vendorExtensions.x-prefixed-collapsible-map}}data.update({{vendorExtensions.x-serialize}}({{paramName}}, '{{vendorExtensions.x-prefixed-collapsible-map}}'))
{{/if}}{{/allParams}}{{/if}}
payload = await self._version.fetch_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, {{#if allParams}}params=data{{/if}})

headers = values.of({})
{{#consumes}}
headers["Content-Type"] = "{{{mediaType}}}"
{{/consumes}}
{{#produces}}
headers["Accept"] = "{{{mediaType}}}"
{{/produces}}
payload = await self._version.fetch_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri {{#if allParams}}, params=data{{/if}}, headers=headers)

return {{instanceName}}(
self._version,
Expand All @@ -117,7 +150,17 @@ class {{apiName}}Context(InstanceContext):
"""{{#if allParams}}
headers = values.of({{#allParams}}{'{{{baseName}}}': {{paramName}}, }{{/allParams}})
{{/if}}
return self._version.delete(method='{{vendorExtensions.x-http-method}}', uri=self._uri,{{#if allParams}} headers=headers{{/if}})

{{^if allParams}}
headers = values.of({})
{{/if}}
{{#consumes}}
headers["Content-Type"] = "{{{mediaType}}}"
{{/consumes}}
{{#produces}}
headers["Accept"] = "{{{mediaType}}}"
{{/produces}}
return self._version.delete(method='{{vendorExtensions.x-http-method}}', uri=self._uri, headers=headers)

async def {{vendorExtensions.x-name-lower}}_async(self{{#allParams}}, {{paramName}}: {{#if required}}{{{dataType}}}{{else}}Union[{{{dataType}}}, object]=values.unset{{/if}}{{/allParams}}) -> bool:
"""
Expand All @@ -129,7 +172,16 @@ class {{apiName}}Context(InstanceContext):
"""{{#if allParams}}
headers = values.of({{#allParams}}{'{{{baseName}}}': {{paramName}}, }{{/allParams}})
{{/if}}
return await self._version.delete_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri,{{#if allParams}} headers=headers{{/if}})
{{^if allParams}}
headers = values.of({})
{{/if}}
{{#consumes}}
headers["Content-Type"] = "{{{mediaType}}}"
{{/consumes}}
{{#produces}}
headers["Accept"] = "{{{mediaType}}}"
{{/produces}}
return await self._version.delete_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, headers=headers)
{{/vendorExtensions.x-twilio.ignoreOperation}}{{/vendorExtensions.x-is-delete-operation}}{{#vendorExtensions.x-is-create-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}}:
"""
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/twilio-python/instance.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class {{instanceName}}(InstanceResource):
{{#if nestedModels}}{{>modelClasses}}{{/if}}
{{>model}}
"""{{#vars}}
:ivar {{name}}: {{{description}}}{{/vars}}
Expand Down
26 changes: 24 additions & 2 deletions src/main/resources/twilio-python/listOperations.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,18 @@
'PageSize': page_size,
})

response = self._version.page(method='{{vendorExtensions.x-http-method}}', uri=self._uri, params=data)
headers = values.of({
{{#headerParams}}'{{{baseName}}}': {{paramName}},
{{/headerParams}}'Content-Type': 'application/x-www-form-urlencoded'
})
{{#consumes}}
headers["Content-Type"] = "{{{mediaType}}}"
{{/consumes}}
{{#produces}}
headers["Accept"] = "{{{mediaType}}}"
{{/produces}}

response = self._version.page(method='{{vendorExtensions.x-http-method}}', uri=self._uri, params=data, headers=headers)
return {{apiName}}Page(self._version, response{{#if listPathParams}}, self._solution{{/if}})

async def page_async(self, {{#allParams}}
Expand All @@ -381,7 +392,18 @@
'PageSize': page_size,
})

response = await self._version.page_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, params=data)
headers = values.of({
{{#headerParams}}'{{{baseName}}}': {{paramName}},
{{/headerParams}}'Content-Type': 'application/x-www-form-urlencoded'
})
{{#consumes}}
headers["Content-Type"] = "{{{mediaType}}}"
{{/consumes}}
{{#produces}}
headers["Accept"] = "{{{mediaType}}}"
{{/produces}}

response = await self._version.page_async(method='{{vendorExtensions.x-http-method}}', uri=self._uri, params=data, headers=headers)
return {{apiName}}Page(self._version, response{{#if listPathParams}}, self._solution{{/if}})

def get_page(self, target_url: str) -> {{apiName}}Page:
Expand Down

0 comments on commit 47d2dd7

Please sign in to comment.