mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
generated python wordnik.com api client
This commit is contained in:
parent
22ebb85c35
commit
39659d8c36
243
samples/client/wordnik-api/python/wordnik/AccountApi.py
Normal file
243
samples/client/wordnik-api/python/wordnik/AccountApi.py
Normal file
@ -0,0 +1,243 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
WordAPI.py
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
from models import *
|
||||
|
||||
|
||||
class AccountApi(object):
|
||||
|
||||
def __init__(self, apiClient):
|
||||
self.apiClient = apiClient
|
||||
|
||||
|
||||
def authenticate(self, username, password, **kwargs):
|
||||
"""Authenticates a User
|
||||
|
||||
Args:
|
||||
username, str: A confirmed Wordnik username (required)
|
||||
password, str: The user's password (required)
|
||||
|
||||
Returns: AuthenticationToken
|
||||
"""
|
||||
|
||||
allParams = ['username', 'password']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method authenticate" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/account.{format}/authenticate/{username}'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('password' in params):
|
||||
queryParams['password'] = self.apiClient.toPathValue(params['password'])
|
||||
if ('username' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['username']))
|
||||
resourcePath = resourcePath.replace('{' + 'username' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'AuthenticationToken')
|
||||
return responseObject
|
||||
|
||||
|
||||
def authenticatePost(self, username, body, **kwargs):
|
||||
"""Authenticates a user
|
||||
|
||||
Args:
|
||||
username, str: A confirmed Wordnik username (required)
|
||||
body, str: The user's password (required)
|
||||
|
||||
Returns: AuthenticationToken
|
||||
"""
|
||||
|
||||
allParams = ['username', 'body']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method authenticatePost" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/account.{format}/authenticate/{username}'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'POST'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('username' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['username']))
|
||||
resourcePath = resourcePath.replace('{' + 'username' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'AuthenticationToken')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getWordListsForLoggedInUser(self, auth_token, **kwargs):
|
||||
"""Fetches WordList objects for the logged-in user.
|
||||
|
||||
Args:
|
||||
auth_token, str: auth_token of logged-in user (required)
|
||||
skip, int: Results to skip (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: list[WordList]
|
||||
"""
|
||||
|
||||
allParams = ['auth_token', 'skip', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getWordListsForLoggedInUser" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/account.{format}/wordLists'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('skip' in params):
|
||||
queryParams['skip'] = self.apiClient.toPathValue(params['skip'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[WordList]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getApiTokenStatus(self, **kwargs):
|
||||
"""Returns usage statistics for the API account.
|
||||
|
||||
Args:
|
||||
api_key, str: Wordnik authentication token (optional)
|
||||
|
||||
Returns: ApiTokenStatus
|
||||
"""
|
||||
|
||||
allParams = ['api_key']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getApiTokenStatus" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/account.{format}/apiTokenStatus'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('api_key' in params):
|
||||
headerParams['api_key'] = params['api_key']
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'ApiTokenStatus')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getLoggedInUser(self, auth_token, **kwargs):
|
||||
"""Returns the logged-in User
|
||||
|
||||
Args:
|
||||
auth_token, str: The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) (required)
|
||||
|
||||
Returns: User
|
||||
"""
|
||||
|
||||
allParams = ['auth_token']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getLoggedInUser" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/account.{format}/user'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'User')
|
||||
return responseObject
|
||||
|
||||
|
||||
|
||||
|
||||
|
622
samples/client/wordnik-api/python/wordnik/WordApi.py
Normal file
622
samples/client/wordnik-api/python/wordnik/WordApi.py
Normal file
@ -0,0 +1,622 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
WordAPI.py
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
from models import *
|
||||
|
||||
|
||||
class WordApi(object):
|
||||
|
||||
def __init__(self, apiClient):
|
||||
self.apiClient = apiClient
|
||||
|
||||
|
||||
def getExamples(self, word, **kwargs):
|
||||
"""Returns examples for a word
|
||||
|
||||
Args:
|
||||
word, str: Word to return examples for (required)
|
||||
includeDuplicates, str: Show duplicate examples from different sources (optional)
|
||||
useCanonical, str: If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
skip, int: Results to skip (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: ExampleSearchResults
|
||||
"""
|
||||
|
||||
allParams = ['word', 'includeDuplicates', 'useCanonical', 'skip', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getExamples" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/examples'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('includeDuplicates' in params):
|
||||
queryParams['includeDuplicates'] = self.apiClient.toPathValue(params['includeDuplicates'])
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('skip' in params):
|
||||
queryParams['skip'] = self.apiClient.toPathValue(params['skip'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'ExampleSearchResults')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getWord(self, word, **kwargs):
|
||||
"""Given a word as a string, returns the WordObject that represents it
|
||||
|
||||
Args:
|
||||
word, str: String value of WordObject to return (required)
|
||||
useCanonical, str: If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
includeSuggestions, str: Return suggestions (for correct spelling, case variants, etc.) (optional)
|
||||
|
||||
Returns: WordObject
|
||||
"""
|
||||
|
||||
allParams = ['word', 'useCanonical', 'includeSuggestions']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getWord" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('includeSuggestions' in params):
|
||||
queryParams['includeSuggestions'] = self.apiClient.toPathValue(params['includeSuggestions'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'WordObject')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getDefinitions(self, word, **kwargs):
|
||||
"""Return definitions for a word
|
||||
|
||||
Args:
|
||||
word, str: Word to return definitions for (required)
|
||||
partOfSpeech, str: CSV list of part-of-speech types (optional)
|
||||
sourceDictionaries, str: Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
includeRelated, str: Return related words with definitions (optional)
|
||||
useCanonical, str: If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
includeTags, str: Return a closed set of XML tags in response (optional)
|
||||
|
||||
Returns: list[Definition]
|
||||
"""
|
||||
|
||||
allParams = ['word', 'partOfSpeech', 'sourceDictionaries', 'limit', 'includeRelated', 'useCanonical', 'includeTags']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getDefinitions" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/definitions'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('partOfSpeech' in params):
|
||||
queryParams['partOfSpeech'] = self.apiClient.toPathValue(params['partOfSpeech'])
|
||||
if ('includeRelated' in params):
|
||||
queryParams['includeRelated'] = self.apiClient.toPathValue(params['includeRelated'])
|
||||
if ('sourceDictionaries' in params):
|
||||
queryParams['sourceDictionaries'] = self.apiClient.toPathValue(params['sourceDictionaries'])
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('includeTags' in params):
|
||||
queryParams['includeTags'] = self.apiClient.toPathValue(params['includeTags'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[Definition]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getTopExample(self, word, **kwargs):
|
||||
"""Returns a top example for a word
|
||||
|
||||
Args:
|
||||
word, str: Word to fetch examples for (required)
|
||||
useCanonical, str: If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
|
||||
Returns: Example
|
||||
"""
|
||||
|
||||
allParams = ['word', 'useCanonical']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getTopExample" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/topExample'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'Example')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getRelatedWords(self, word, **kwargs):
|
||||
"""Given a word as a string, returns relationships from the Word Graph
|
||||
|
||||
Args:
|
||||
word, str: Word to fetch relationships for (required)
|
||||
relationshipTypes, str: Limits the total results per type of relationship type (optional)
|
||||
useCanonical, str: If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
limitPerRelationshipType, int: Restrict to the supplied relatinship types (optional)
|
||||
|
||||
Returns: list[Related]
|
||||
"""
|
||||
|
||||
allParams = ['word', 'relationshipTypes', 'useCanonical', 'limitPerRelationshipType']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getRelatedWords" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/relatedWords'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('relationshipTypes' in params):
|
||||
queryParams['relationshipTypes'] = self.apiClient.toPathValue(params['relationshipTypes'])
|
||||
if ('limitPerRelationshipType' in params):
|
||||
queryParams['limitPerRelationshipType'] = self.apiClient.toPathValue(params['limitPerRelationshipType'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[Related]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getTextPronunciations(self, word, **kwargs):
|
||||
"""Returns text pronunciations for a given word
|
||||
|
||||
Args:
|
||||
word, str: Word to get pronunciations for (required)
|
||||
sourceDictionary, str: Get from a single dictionary (optional)
|
||||
typeFormat, str: Text pronunciation type (optional)
|
||||
useCanonical, str: If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: list[TextPron]
|
||||
"""
|
||||
|
||||
allParams = ['word', 'sourceDictionary', 'typeFormat', 'useCanonical', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getTextPronunciations" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/pronunciations'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('sourceDictionary' in params):
|
||||
queryParams['sourceDictionary'] = self.apiClient.toPathValue(params['sourceDictionary'])
|
||||
if ('typeFormat' in params):
|
||||
queryParams['typeFormat'] = self.apiClient.toPathValue(params['typeFormat'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[TextPron]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getHyphenation(self, word, **kwargs):
|
||||
"""Returns syllable information for a word
|
||||
|
||||
Args:
|
||||
word, str: Word to get syllables for (required)
|
||||
sourceDictionary, str: Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet. (optional)
|
||||
useCanonical, str: If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: list[Syllable]
|
||||
"""
|
||||
|
||||
allParams = ['word', 'sourceDictionary', 'useCanonical', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getHyphenation" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/hyphenation'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('sourceDictionary' in params):
|
||||
queryParams['sourceDictionary'] = self.apiClient.toPathValue(params['sourceDictionary'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[Syllable]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getWordFrequency(self, word, **kwargs):
|
||||
"""Returns word usage over time
|
||||
|
||||
Args:
|
||||
word, str: Word to return (required)
|
||||
useCanonical, str: If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
startYear, int: Starting Year (optional)
|
||||
endYear, int: Ending Year (optional)
|
||||
|
||||
Returns: FrequencySummary
|
||||
"""
|
||||
|
||||
allParams = ['word', 'useCanonical', 'startYear', 'endYear']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getWordFrequency" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/frequency'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('startYear' in params):
|
||||
queryParams['startYear'] = self.apiClient.toPathValue(params['startYear'])
|
||||
if ('endYear' in params):
|
||||
queryParams['endYear'] = self.apiClient.toPathValue(params['endYear'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'FrequencySummary')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getPhrases(self, word, **kwargs):
|
||||
"""Fetches bi-gram phrases for a word
|
||||
|
||||
Args:
|
||||
word, str: Word to fetch phrases for (required)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
wlmi, int: Minimum WLMI for the phrase (optional)
|
||||
useCanonical, str: If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
|
||||
Returns: list[Bigram]
|
||||
"""
|
||||
|
||||
allParams = ['word', 'limit', 'wlmi', 'useCanonical']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getPhrases" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/phrases'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('wlmi' in params):
|
||||
queryParams['wlmi'] = self.apiClient.toPathValue(params['wlmi'])
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[Bigram]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getEtymologies(self, word, **kwargs):
|
||||
"""Fetches etymology data
|
||||
|
||||
Args:
|
||||
word, str: Word to return (required)
|
||||
useCanonical, str: If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested. (optional)
|
||||
|
||||
Returns: list[str]
|
||||
"""
|
||||
|
||||
allParams = ['word', 'useCanonical']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getEtymologies" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/etymologies'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[str]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getAudio(self, word, **kwargs):
|
||||
"""Fetches audio metadata for a word.
|
||||
|
||||
Args:
|
||||
word, str: Word to get audio for. (required)
|
||||
useCanonical, str: Use the canonical form of the word (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: list[AudioFile]
|
||||
"""
|
||||
|
||||
allParams = ['word', 'useCanonical', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getAudio" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/audio'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('useCanonical' in params):
|
||||
queryParams['useCanonical'] = self.apiClient.toPathValue(params['useCanonical'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[AudioFile]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getScrabbleScore(self, word, **kwargs):
|
||||
"""Returns the Scrabble score for a word
|
||||
|
||||
Args:
|
||||
word, str: Word to get scrabble score for. (required)
|
||||
|
||||
Returns: ScrabbleScoreResult
|
||||
"""
|
||||
|
||||
allParams = ['word']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getScrabbleScore" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/word.{format}/{word}/scrabbleScore'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('word' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['word']))
|
||||
resourcePath = resourcePath.replace('{' + 'word' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'ScrabbleScoreResult')
|
||||
return responseObject
|
||||
|
||||
|
||||
|
||||
|
||||
|
293
samples/client/wordnik-api/python/wordnik/WordListApi.py
Normal file
293
samples/client/wordnik-api/python/wordnik/WordListApi.py
Normal file
@ -0,0 +1,293 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
WordAPI.py
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
from models import *
|
||||
|
||||
|
||||
class WordListApi(object):
|
||||
|
||||
def __init__(self, apiClient):
|
||||
self.apiClient = apiClient
|
||||
|
||||
|
||||
def updateWordList(self, permalink, auth_token, **kwargs):
|
||||
"""Updates an existing WordList
|
||||
|
||||
Args:
|
||||
permalink, str: permalink of WordList to update (required)
|
||||
body, WordList: Updated WordList (optional)
|
||||
auth_token, str: The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) (required)
|
||||
|
||||
Returns:
|
||||
"""
|
||||
|
||||
allParams = ['permalink', 'body', 'auth_token']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method updateWordList" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/wordList.{format}/{permalink}'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'PUT'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
if ('permalink' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['permalink']))
|
||||
resourcePath = resourcePath.replace('{' + 'permalink' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
|
||||
|
||||
def deleteWordList(self, permalink, auth_token, **kwargs):
|
||||
"""Deletes an existing WordList
|
||||
|
||||
Args:
|
||||
permalink, str: ID of WordList to delete (required)
|
||||
auth_token, str: The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) (required)
|
||||
|
||||
Returns:
|
||||
"""
|
||||
|
||||
allParams = ['permalink', 'auth_token']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method deleteWordList" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/wordList.{format}/{permalink}'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'DELETE'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
if ('permalink' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['permalink']))
|
||||
resourcePath = resourcePath.replace('{' + 'permalink' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
|
||||
|
||||
def getWordListByPermalink(self, permalink, auth_token, **kwargs):
|
||||
"""Fetches a WordList by ID
|
||||
|
||||
Args:
|
||||
permalink, str: permalink of WordList to fetch (required)
|
||||
auth_token, str: The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) (required)
|
||||
|
||||
Returns: WordList
|
||||
"""
|
||||
|
||||
allParams = ['permalink', 'auth_token']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getWordListByPermalink" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/wordList.{format}/{permalink}'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
if ('permalink' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['permalink']))
|
||||
resourcePath = resourcePath.replace('{' + 'permalink' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'WordList')
|
||||
return responseObject
|
||||
|
||||
|
||||
def addWordsToWordList(self, permalink, auth_token, **kwargs):
|
||||
"""Adds words to a WordList
|
||||
|
||||
Args:
|
||||
permalink, str: permalink of WordList to user (required)
|
||||
body, list[StringValue]: Array of words to add to WordList (optional)
|
||||
auth_token, str: The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) (required)
|
||||
|
||||
Returns:
|
||||
"""
|
||||
|
||||
allParams = ['permalink', 'body', 'auth_token']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method addWordsToWordList" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/wordList.{format}/{permalink}/words'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'POST'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
if ('permalink' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['permalink']))
|
||||
resourcePath = resourcePath.replace('{' + 'permalink' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
|
||||
|
||||
def getWordListWords(self, permalink, auth_token, **kwargs):
|
||||
"""Fetches words in a WordList
|
||||
|
||||
Args:
|
||||
permalink, str: ID of WordList to use (required)
|
||||
auth_token, str: The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) (required)
|
||||
sortBy, str: Field to sort by (optional)
|
||||
sortOrder, str: Direction to sort (optional)
|
||||
skip, int: Results to skip (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: list[WordListWord]
|
||||
"""
|
||||
|
||||
allParams = ['permalink', 'auth_token', 'sortBy', 'sortOrder', 'skip', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getWordListWords" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/wordList.{format}/{permalink}/words'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('sortBy' in params):
|
||||
queryParams['sortBy'] = self.apiClient.toPathValue(params['sortBy'])
|
||||
if ('sortOrder' in params):
|
||||
queryParams['sortOrder'] = self.apiClient.toPathValue(params['sortOrder'])
|
||||
if ('skip' in params):
|
||||
queryParams['skip'] = self.apiClient.toPathValue(params['skip'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
if ('permalink' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['permalink']))
|
||||
resourcePath = resourcePath.replace('{' + 'permalink' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[WordListWord]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def deleteWordsFromWordList(self, permalink, auth_token, **kwargs):
|
||||
"""Removes words from a WordList
|
||||
|
||||
Args:
|
||||
permalink, str: permalink of WordList to use (required)
|
||||
body, list[StringValue]: Words to remove from WordList (optional)
|
||||
auth_token, str: The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) (required)
|
||||
|
||||
Returns:
|
||||
"""
|
||||
|
||||
allParams = ['permalink', 'body', 'auth_token']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method deleteWordsFromWordList" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/wordList.{format}/{permalink}/deleteWords'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'POST'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
if ('permalink' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['permalink']))
|
||||
resourcePath = resourcePath.replace('{' + 'permalink' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
74
samples/client/wordnik-api/python/wordnik/WordListsApi.py
Normal file
74
samples/client/wordnik-api/python/wordnik/WordListsApi.py
Normal file
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
WordAPI.py
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
from models import *
|
||||
|
||||
|
||||
class WordListsApi(object):
|
||||
|
||||
def __init__(self, apiClient):
|
||||
self.apiClient = apiClient
|
||||
|
||||
|
||||
def createWordList(self, auth_token, **kwargs):
|
||||
"""Creates a WordList.
|
||||
|
||||
Args:
|
||||
body, WordList: WordList to create (optional)
|
||||
auth_token, str: The auth token of the logged-in user, obtained by calling /account.{format}/authenticate/{username} (described above) (required)
|
||||
|
||||
Returns: WordList
|
||||
"""
|
||||
|
||||
allParams = ['body', 'auth_token']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method createWordList" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/wordLists.{format}'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'POST'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('auth_token' in params):
|
||||
headerParams['auth_token'] = params['auth_token']
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'WordList')
|
||||
return responseObject
|
||||
|
||||
|
||||
|
||||
|
||||
|
366
samples/client/wordnik-api/python/wordnik/WordsApi.py
Normal file
366
samples/client/wordnik-api/python/wordnik/WordsApi.py
Normal file
@ -0,0 +1,366 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
WordAPI.py
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
from models import *
|
||||
|
||||
|
||||
class WordsApi(object):
|
||||
|
||||
def __init__(self, apiClient):
|
||||
self.apiClient = apiClient
|
||||
|
||||
|
||||
def searchWords(self, query, **kwargs):
|
||||
"""Searches words
|
||||
|
||||
Args:
|
||||
query, str: Search query (required)
|
||||
includePartOfSpeech, str: Only include these comma-delimited parts of speech (optional)
|
||||
excludePartOfSpeech, str: Exclude these comma-delimited parts of speech (optional)
|
||||
caseSensitive, str: Search case sensitive (optional)
|
||||
minCorpusCount, int: Minimum corpus frequency for terms (optional)
|
||||
maxCorpusCount, int: Maximum corpus frequency for terms (optional)
|
||||
minDictionaryCount, int: Minimum number of dictionary entries for words returned (optional)
|
||||
maxDictionaryCount, int: Maximum dictionary definition count (optional)
|
||||
minLength, int: Minimum word length (optional)
|
||||
maxLength, int: Maximum word length (optional)
|
||||
skip, int: Results to skip (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: WordSearchResults
|
||||
"""
|
||||
|
||||
allParams = ['query', 'includePartOfSpeech', 'excludePartOfSpeech', 'caseSensitive', 'minCorpusCount', 'maxCorpusCount', 'minDictionaryCount', 'maxDictionaryCount', 'minLength', 'maxLength', 'skip', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method searchWords" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/words.{format}/search/{query}'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('caseSensitive' in params):
|
||||
queryParams['caseSensitive'] = self.apiClient.toPathValue(params['caseSensitive'])
|
||||
if ('includePartOfSpeech' in params):
|
||||
queryParams['includePartOfSpeech'] = self.apiClient.toPathValue(params['includePartOfSpeech'])
|
||||
if ('excludePartOfSpeech' in params):
|
||||
queryParams['excludePartOfSpeech'] = self.apiClient.toPathValue(params['excludePartOfSpeech'])
|
||||
if ('minCorpusCount' in params):
|
||||
queryParams['minCorpusCount'] = self.apiClient.toPathValue(params['minCorpusCount'])
|
||||
if ('maxCorpusCount' in params):
|
||||
queryParams['maxCorpusCount'] = self.apiClient.toPathValue(params['maxCorpusCount'])
|
||||
if ('minDictionaryCount' in params):
|
||||
queryParams['minDictionaryCount'] = self.apiClient.toPathValue(params['minDictionaryCount'])
|
||||
if ('maxDictionaryCount' in params):
|
||||
queryParams['maxDictionaryCount'] = self.apiClient.toPathValue(params['maxDictionaryCount'])
|
||||
if ('minLength' in params):
|
||||
queryParams['minLength'] = self.apiClient.toPathValue(params['minLength'])
|
||||
if ('maxLength' in params):
|
||||
queryParams['maxLength'] = self.apiClient.toPathValue(params['maxLength'])
|
||||
if ('skip' in params):
|
||||
queryParams['skip'] = self.apiClient.toPathValue(params['skip'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
if ('query' in params):
|
||||
replacement = str(self.apiClient.toPathValue(params['query']))
|
||||
resourcePath = resourcePath.replace('{' + 'query' + '}',
|
||||
replacement)
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'WordSearchResults')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getWordOfTheDay(self, **kwargs):
|
||||
"""Returns a specific WordOfTheDay
|
||||
|
||||
Args:
|
||||
date, str: Fetches by date in yyyy-MM-dd (optional)
|
||||
|
||||
Returns: WordOfTheDay
|
||||
"""
|
||||
|
||||
allParams = ['date']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getWordOfTheDay" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/words.{format}/wordOfTheDay'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('date' in params):
|
||||
queryParams['date'] = self.apiClient.toPathValue(params['date'])
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'WordOfTheDay')
|
||||
return responseObject
|
||||
|
||||
|
||||
def reverseDictionary(self, query, **kwargs):
|
||||
"""Reverse dictionary search
|
||||
|
||||
Args:
|
||||
query, str: Search term (required)
|
||||
findSenseForWord, str: Restricts words and finds closest sense (optional)
|
||||
includeSourceDictionaries, str: Only include these comma-delimited source dictionaries (optional)
|
||||
excludeSourceDictionaries, str: Exclude these comma-delimited source dictionaries (optional)
|
||||
includePartOfSpeech, str: Only include these comma-delimited parts of speech (optional)
|
||||
excludePartOfSpeech, str: Exclude these comma-delimited parts of speech (optional)
|
||||
expandTerms, str: Expand terms (optional)
|
||||
sortBy, str: Attribute to sort by (optional)
|
||||
sortOrder, str: Sort direction (optional)
|
||||
minCorpusCount, int: Minimum corpus frequency for terms (optional)
|
||||
maxCorpusCount, int: Maximum corpus frequency for terms (optional)
|
||||
minLength, int: Minimum word length (optional)
|
||||
maxLength, int: Maximum word length (optional)
|
||||
includeTags, str: Return a closed set of XML tags in response (optional)
|
||||
skip, str: Results to skip (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: DefinitionSearchResults
|
||||
"""
|
||||
|
||||
allParams = ['query', 'findSenseForWord', 'includeSourceDictionaries', 'excludeSourceDictionaries', 'includePartOfSpeech', 'excludePartOfSpeech', 'expandTerms', 'sortBy', 'sortOrder', 'minCorpusCount', 'maxCorpusCount', 'minLength', 'maxLength', 'includeTags', 'skip', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method reverseDictionary" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/words.{format}/reverseDictionary'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('query' in params):
|
||||
queryParams['query'] = self.apiClient.toPathValue(params['query'])
|
||||
if ('findSenseForWord' in params):
|
||||
queryParams['findSenseForWord'] = self.apiClient.toPathValue(params['findSenseForWord'])
|
||||
if ('includeSourceDictionaries' in params):
|
||||
queryParams['includeSourceDictionaries'] = self.apiClient.toPathValue(params['includeSourceDictionaries'])
|
||||
if ('excludeSourceDictionaries' in params):
|
||||
queryParams['excludeSourceDictionaries'] = self.apiClient.toPathValue(params['excludeSourceDictionaries'])
|
||||
if ('includePartOfSpeech' in params):
|
||||
queryParams['includePartOfSpeech'] = self.apiClient.toPathValue(params['includePartOfSpeech'])
|
||||
if ('excludePartOfSpeech' in params):
|
||||
queryParams['excludePartOfSpeech'] = self.apiClient.toPathValue(params['excludePartOfSpeech'])
|
||||
if ('minCorpusCount' in params):
|
||||
queryParams['minCorpusCount'] = self.apiClient.toPathValue(params['minCorpusCount'])
|
||||
if ('maxCorpusCount' in params):
|
||||
queryParams['maxCorpusCount'] = self.apiClient.toPathValue(params['maxCorpusCount'])
|
||||
if ('minLength' in params):
|
||||
queryParams['minLength'] = self.apiClient.toPathValue(params['minLength'])
|
||||
if ('maxLength' in params):
|
||||
queryParams['maxLength'] = self.apiClient.toPathValue(params['maxLength'])
|
||||
if ('expandTerms' in params):
|
||||
queryParams['expandTerms'] = self.apiClient.toPathValue(params['expandTerms'])
|
||||
if ('includeTags' in params):
|
||||
queryParams['includeTags'] = self.apiClient.toPathValue(params['includeTags'])
|
||||
if ('sortBy' in params):
|
||||
queryParams['sortBy'] = self.apiClient.toPathValue(params['sortBy'])
|
||||
if ('sortOrder' in params):
|
||||
queryParams['sortOrder'] = self.apiClient.toPathValue(params['sortOrder'])
|
||||
if ('skip' in params):
|
||||
queryParams['skip'] = self.apiClient.toPathValue(params['skip'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'DefinitionSearchResults')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getRandomWords(self, **kwargs):
|
||||
"""Returns an array of random WordObjects
|
||||
|
||||
Args:
|
||||
includePartOfSpeech, str: CSV part-of-speech values to include (optional)
|
||||
excludePartOfSpeech, str: CSV part-of-speech values to exclude (optional)
|
||||
sortBy, str: Attribute to sort by (optional)
|
||||
sortOrder, str: Sort direction (optional)
|
||||
hasDictionaryDef, str: Only return words with dictionary definitions (optional)
|
||||
minCorpusCount, int: Minimum corpus frequency for terms (optional)
|
||||
maxCorpusCount, int: Maximum corpus frequency for terms (optional)
|
||||
minDictionaryCount, int: Minimum dictionary count (optional)
|
||||
maxDictionaryCount, int: Maximum dictionary count (optional)
|
||||
minLength, int: Minimum word length (optional)
|
||||
maxLength, int: Maximum word length (optional)
|
||||
limit, int: Maximum number of results to return (optional)
|
||||
|
||||
Returns: list[WordObject]
|
||||
"""
|
||||
|
||||
allParams = ['includePartOfSpeech', 'excludePartOfSpeech', 'sortBy', 'sortOrder', 'hasDictionaryDef', 'minCorpusCount', 'maxCorpusCount', 'minDictionaryCount', 'maxDictionaryCount', 'minLength', 'maxLength', 'limit']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getRandomWords" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/words.{format}/randomWords'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('hasDictionaryDef' in params):
|
||||
queryParams['hasDictionaryDef'] = self.apiClient.toPathValue(params['hasDictionaryDef'])
|
||||
if ('includePartOfSpeech' in params):
|
||||
queryParams['includePartOfSpeech'] = self.apiClient.toPathValue(params['includePartOfSpeech'])
|
||||
if ('excludePartOfSpeech' in params):
|
||||
queryParams['excludePartOfSpeech'] = self.apiClient.toPathValue(params['excludePartOfSpeech'])
|
||||
if ('minCorpusCount' in params):
|
||||
queryParams['minCorpusCount'] = self.apiClient.toPathValue(params['minCorpusCount'])
|
||||
if ('maxCorpusCount' in params):
|
||||
queryParams['maxCorpusCount'] = self.apiClient.toPathValue(params['maxCorpusCount'])
|
||||
if ('minDictionaryCount' in params):
|
||||
queryParams['minDictionaryCount'] = self.apiClient.toPathValue(params['minDictionaryCount'])
|
||||
if ('maxDictionaryCount' in params):
|
||||
queryParams['maxDictionaryCount'] = self.apiClient.toPathValue(params['maxDictionaryCount'])
|
||||
if ('minLength' in params):
|
||||
queryParams['minLength'] = self.apiClient.toPathValue(params['minLength'])
|
||||
if ('maxLength' in params):
|
||||
queryParams['maxLength'] = self.apiClient.toPathValue(params['maxLength'])
|
||||
if ('sortBy' in params):
|
||||
queryParams['sortBy'] = self.apiClient.toPathValue(params['sortBy'])
|
||||
if ('sortOrder' in params):
|
||||
queryParams['sortOrder'] = self.apiClient.toPathValue(params['sortOrder'])
|
||||
if ('limit' in params):
|
||||
queryParams['limit'] = self.apiClient.toPathValue(params['limit'])
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'list[WordObject]')
|
||||
return responseObject
|
||||
|
||||
|
||||
def getRandomWord(self, **kwargs):
|
||||
"""Returns a single random WordObject
|
||||
|
||||
Args:
|
||||
includePartOfSpeech, str: CSV part-of-speech values to include (optional)
|
||||
excludePartOfSpeech, str: CSV part-of-speech values to exclude (optional)
|
||||
hasDictionaryDef, str: Only return words with dictionary definitions (optional)
|
||||
minCorpusCount, int: Minimum corpus frequency for terms (optional)
|
||||
maxCorpusCount, int: Maximum corpus frequency for terms (optional)
|
||||
minDictionaryCount, int: Minimum dictionary count (optional)
|
||||
maxDictionaryCount, int: Maximum dictionary count (optional)
|
||||
minLength, int: Minimum word length (optional)
|
||||
maxLength, int: Maximum word length (optional)
|
||||
|
||||
Returns: WordObject
|
||||
"""
|
||||
|
||||
allParams = ['includePartOfSpeech', 'excludePartOfSpeech', 'hasDictionaryDef', 'minCorpusCount', 'maxCorpusCount', 'minDictionaryCount', 'maxDictionaryCount', 'minLength', 'maxLength']
|
||||
|
||||
params = locals()
|
||||
for (key, val) in params['kwargs'].iteritems():
|
||||
if key not in allParams:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method getRandomWord" % key)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resourcePath = '/words.{format}/randomWord'
|
||||
resourcePath = resourcePath.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
queryParams = {}
|
||||
headerParams = {}
|
||||
|
||||
if ('hasDictionaryDef' in params):
|
||||
queryParams['hasDictionaryDef'] = self.apiClient.toPathValue(params['hasDictionaryDef'])
|
||||
if ('includePartOfSpeech' in params):
|
||||
queryParams['includePartOfSpeech'] = self.apiClient.toPathValue(params['includePartOfSpeech'])
|
||||
if ('excludePartOfSpeech' in params):
|
||||
queryParams['excludePartOfSpeech'] = self.apiClient.toPathValue(params['excludePartOfSpeech'])
|
||||
if ('minCorpusCount' in params):
|
||||
queryParams['minCorpusCount'] = self.apiClient.toPathValue(params['minCorpusCount'])
|
||||
if ('maxCorpusCount' in params):
|
||||
queryParams['maxCorpusCount'] = self.apiClient.toPathValue(params['maxCorpusCount'])
|
||||
if ('minDictionaryCount' in params):
|
||||
queryParams['minDictionaryCount'] = self.apiClient.toPathValue(params['minDictionaryCount'])
|
||||
if ('maxDictionaryCount' in params):
|
||||
queryParams['maxDictionaryCount'] = self.apiClient.toPathValue(params['maxDictionaryCount'])
|
||||
if ('minLength' in params):
|
||||
queryParams['minLength'] = self.apiClient.toPathValue(params['minLength'])
|
||||
if ('maxLength' in params):
|
||||
queryParams['maxLength'] = self.apiClient.toPathValue(params['maxLength'])
|
||||
postData = (params['body'] if 'body' in params else None)
|
||||
|
||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
||||
postData, headerParams)
|
||||
|
||||
if not response:
|
||||
return None
|
||||
|
||||
responseObject = self.apiClient.deserialize(response, 'WordObject')
|
||||
return responseObject
|
||||
|
||||
|
||||
|
||||
|
||||
|
10
samples/client/wordnik-api/python/wordnik/__init__.py
Normal file
10
samples/client/wordnik-api/python/wordnik/__init__.py
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
"""Add all of the modules in the current directory to __all__"""
|
||||
import os
|
||||
|
||||
__all__ = []
|
||||
|
||||
for module in os.listdir(os.path.dirname(__file__)):
|
||||
if module != '__init__.py' and module[-3:] == '.py':
|
||||
__all__.append(module[:-3])
|
||||
|
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class ApiTokenStatus:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'valid': 'bool',
|
||||
'token': 'str',
|
||||
'resetsInMillis': 'long',
|
||||
'remainingCalls': 'long',
|
||||
'expiresInMillis': 'long',
|
||||
'totalRequests': 'long'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.valid = None # bool
|
||||
self.token = None # str
|
||||
self.resetsInMillis = None # long
|
||||
self.remainingCalls = None # long
|
||||
self.expiresInMillis = None # long
|
||||
self.totalRequests = None # long
|
||||
|
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class AudioFile:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'attributionUrl': 'str',
|
||||
'commentCount': 'int',
|
||||
'voteCount': 'int',
|
||||
'fileUrl': 'str',
|
||||
'audioType': 'str',
|
||||
'id': 'long',
|
||||
'duration': 'float',
|
||||
'attributionText': 'str',
|
||||
'createdBy': 'str',
|
||||
'description': 'str',
|
||||
'createdAt': 'datetime',
|
||||
'voteWeightedAverage': 'float',
|
||||
'voteAverage': 'float',
|
||||
'word': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.attributionUrl = None # str
|
||||
self.commentCount = None # int
|
||||
self.voteCount = None # int
|
||||
self.fileUrl = None # str
|
||||
self.audioType = None # str
|
||||
self.id = None # long
|
||||
self.duration = None # float
|
||||
self.attributionText = None # str
|
||||
self.createdBy = None # str
|
||||
self.description = None # str
|
||||
self.createdAt = None # datetime
|
||||
self.voteWeightedAverage = None # float
|
||||
self.voteAverage = None # float
|
||||
self.word = None # str
|
||||
|
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class AuthenticationToken:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'token': 'str',
|
||||
'userId': 'long',
|
||||
'userSignature': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.token = None # str
|
||||
self.userId = None # long
|
||||
self.userSignature = None # str
|
||||
|
38
samples/client/wordnik-api/python/wordnik/models/Bigram.py
Normal file
38
samples/client/wordnik-api/python/wordnik/models/Bigram.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Bigram:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'count': 'long',
|
||||
'gram2': 'str',
|
||||
'gram1': 'str',
|
||||
'wlmi': 'float',
|
||||
'mi': 'float'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.count = None # long
|
||||
self.gram2 = None # str
|
||||
self.gram1 = None # str
|
||||
self.wlmi = None # float
|
||||
self.mi = None # float
|
||||
|
32
samples/client/wordnik-api/python/wordnik/models/Citation.py
Normal file
32
samples/client/wordnik-api/python/wordnik/models/Citation.py
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Citation:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'cite': 'str',
|
||||
'source': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.cite = None # str
|
||||
self.source = None # str
|
||||
|
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class ContentProvider:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'id': 'int',
|
||||
'name': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.id = None # int
|
||||
self.name = None # str
|
||||
|
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Definition:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'extendedText': 'str',
|
||||
'text': 'str',
|
||||
'sourceDictionary': 'str',
|
||||
'citations': 'list[Citation]',
|
||||
'labels': 'list[Label]',
|
||||
'score': 'float',
|
||||
'exampleUses': 'list[ExampleUsage]',
|
||||
'attributionUrl': 'str',
|
||||
'seqString': 'str',
|
||||
'attributionText': 'str',
|
||||
'relatedWords': 'list[Related]',
|
||||
'sequence': 'str',
|
||||
'word': 'str',
|
||||
'notes': 'list[Note]',
|
||||
'textProns': 'list[TextPron]',
|
||||
'partOfSpeech': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.extendedText = None # str
|
||||
self.text = None # str
|
||||
self.sourceDictionary = None # str
|
||||
self.citations = None # list[Citation]
|
||||
self.labels = None # list[Label]
|
||||
self.score = None # float
|
||||
self.exampleUses = None # list[ExampleUsage]
|
||||
self.attributionUrl = None # str
|
||||
self.seqString = None # str
|
||||
self.attributionText = None # str
|
||||
self.relatedWords = None # list[Related]
|
||||
self.sequence = None # str
|
||||
self.word = None # str
|
||||
self.notes = None # list[Note]
|
||||
self.textProns = None # list[TextPron]
|
||||
self.partOfSpeech = None # str
|
||||
|
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class DefinitionSearchResults:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'results': 'list[Definition]',
|
||||
'totalResults': 'int'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.results = None # list[Definition]
|
||||
self.totalResults = None # int
|
||||
|
52
samples/client/wordnik-api/python/wordnik/models/Example.py
Normal file
52
samples/client/wordnik-api/python/wordnik/models/Example.py
Normal file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Example:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'id': 'long',
|
||||
'exampleId': 'long',
|
||||
'title': 'str',
|
||||
'text': 'str',
|
||||
'score': 'ScoredWord',
|
||||
'sentence': 'Sentence',
|
||||
'word': 'str',
|
||||
'provider': 'ContentProvider',
|
||||
'year': 'int',
|
||||
'rating': 'float',
|
||||
'documentId': 'long',
|
||||
'url': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.id = None # long
|
||||
self.exampleId = None # long
|
||||
self.title = None # str
|
||||
self.text = None # str
|
||||
self.score = None # ScoredWord
|
||||
self.sentence = None # Sentence
|
||||
self.word = None # str
|
||||
self.provider = None # ContentProvider
|
||||
self.year = None # int
|
||||
self.rating = None # float
|
||||
self.documentId = None # long
|
||||
self.url = None # str
|
||||
|
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class ExampleSearchResults:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'facets': 'list[Facet]',
|
||||
'examples': 'list[Example]'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.facets = None # list[Facet]
|
||||
self.examples = None # list[Example]
|
||||
|
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class ExampleUsage:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'text': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.text = None # str
|
||||
|
32
samples/client/wordnik-api/python/wordnik/models/Facet.py
Normal file
32
samples/client/wordnik-api/python/wordnik/models/Facet.py
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Facet:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'facetValues': 'list[FacetValue]',
|
||||
'name': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.facetValues = None # list[FacetValue]
|
||||
self.name = None # str
|
||||
|
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class FacetValue:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'count': 'long',
|
||||
'value': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.count = None # long
|
||||
self.value = None # str
|
||||
|
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Frequency:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'count': 'long',
|
||||
'year': 'int'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.count = None # long
|
||||
self.year = None # int
|
||||
|
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class FrequencySummary:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'unknownYearCount': 'int',
|
||||
'totalCount': 'long',
|
||||
'frequencyString': 'str',
|
||||
'word': 'str',
|
||||
'frequency': 'list[Frequency]'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.unknownYearCount = None # int
|
||||
self.totalCount = None # long
|
||||
self.frequencyString = None # str
|
||||
self.word = None # str
|
||||
self.frequency = None # list[Frequency]
|
||||
|
32
samples/client/wordnik-api/python/wordnik/models/Label.py
Normal file
32
samples/client/wordnik-api/python/wordnik/models/Label.py
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Label:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'text': 'str',
|
||||
'type': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.text = None # str
|
||||
self.type = None # str
|
||||
|
36
samples/client/wordnik-api/python/wordnik/models/Note.py
Normal file
36
samples/client/wordnik-api/python/wordnik/models/Note.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Note:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'noteType': 'str',
|
||||
'appliesTo': 'list[str]',
|
||||
'value': 'str',
|
||||
'pos': 'int'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.noteType = None # str
|
||||
self.appliesTo = None # list[str]
|
||||
self.value = None # str
|
||||
self.pos = None # int
|
||||
|
42
samples/client/wordnik-api/python/wordnik/models/Related.py
Normal file
42
samples/client/wordnik-api/python/wordnik/models/Related.py
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Related:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'label1': 'str',
|
||||
'relationshipType': 'str',
|
||||
'label2': 'str',
|
||||
'label3': 'str',
|
||||
'words': 'list[str]',
|
||||
'gram': 'str',
|
||||
'label4': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.label1 = None # str
|
||||
self.relationshipType = None # str
|
||||
self.label2 = None # str
|
||||
self.label3 = None # str
|
||||
self.words = None # list[str]
|
||||
self.gram = None # str
|
||||
self.label4 = None # str
|
||||
|
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class ScoredWord:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'position': 'int',
|
||||
'id': 'long',
|
||||
'docTermCount': 'int',
|
||||
'lemma': 'str',
|
||||
'wordType': 'str',
|
||||
'score': 'float',
|
||||
'sentenceId': 'long',
|
||||
'word': 'str',
|
||||
'stopword': 'bool',
|
||||
'baseWordScore': 'float',
|
||||
'partOfSpeech': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.position = None # int
|
||||
self.id = None # long
|
||||
self.docTermCount = None # int
|
||||
self.lemma = None # str
|
||||
self.wordType = None # str
|
||||
self.score = None # float
|
||||
self.sentenceId = None # long
|
||||
self.word = None # str
|
||||
self.stopword = None # bool
|
||||
self.baseWordScore = None # float
|
||||
self.partOfSpeech = None # str
|
||||
|
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class ScrabbleScoreResult:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'value': 'int'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.value = None # int
|
||||
|
40
samples/client/wordnik-api/python/wordnik/models/Sentence.py
Normal file
40
samples/client/wordnik-api/python/wordnik/models/Sentence.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Sentence:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'hasScoredWords': 'bool',
|
||||
'id': 'long',
|
||||
'scoredWords': 'list[ScoredWord]',
|
||||
'display': 'str',
|
||||
'rating': 'int',
|
||||
'documentMetadataId': 'long'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.hasScoredWords = None # bool
|
||||
self.id = None # long
|
||||
self.scoredWords = None # list[ScoredWord]
|
||||
self.display = None # str
|
||||
self.rating = None # int
|
||||
self.documentMetadataId = None # long
|
||||
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class SimpleDefinition:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'text': 'str',
|
||||
'source': 'str',
|
||||
'note': 'str',
|
||||
'partOfSpeech': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.text = None # str
|
||||
self.source = None # str
|
||||
self.note = None # str
|
||||
self.partOfSpeech = None # str
|
||||
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class SimpleExample:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'id': 'long',
|
||||
'title': 'str',
|
||||
'text': 'str',
|
||||
'url': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.id = None # long
|
||||
self.title = None # str
|
||||
self.text = None # str
|
||||
self.url = None # str
|
||||
|
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class StringValue:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'word': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.word = None # str
|
||||
|
34
samples/client/wordnik-api/python/wordnik/models/Syllable.py
Normal file
34
samples/client/wordnik-api/python/wordnik/models/Syllable.py
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class Syllable:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'text': 'str',
|
||||
'seq': 'int',
|
||||
'type': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.text = None # str
|
||||
self.seq = None # int
|
||||
self.type = None # str
|
||||
|
34
samples/client/wordnik-api/python/wordnik/models/TextPron.py
Normal file
34
samples/client/wordnik-api/python/wordnik/models/TextPron.py
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class TextPron:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'raw': 'str',
|
||||
'seq': 'int',
|
||||
'rawType': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.raw = None # str
|
||||
self.seq = None # int
|
||||
self.rawType = None # str
|
||||
|
44
samples/client/wordnik-api/python/wordnik/models/User.py
Normal file
44
samples/client/wordnik-api/python/wordnik/models/User.py
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class User:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'id': 'long',
|
||||
'username': 'str',
|
||||
'email': 'str',
|
||||
'status': 'int',
|
||||
'faceBookId': 'str',
|
||||
'userName': 'str',
|
||||
'displayName': 'str',
|
||||
'password': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.id = None # long
|
||||
self.username = None # str
|
||||
self.email = None # str
|
||||
self.status = None # int
|
||||
self.faceBookId = None # str
|
||||
self.userName = None # str
|
||||
self.displayName = None # str
|
||||
self.password = None # str
|
||||
|
50
samples/client/wordnik-api/python/wordnik/models/WordList.py
Normal file
50
samples/client/wordnik-api/python/wordnik/models/WordList.py
Normal file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class WordList:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'id': 'long',
|
||||
'permalink': 'str',
|
||||
'name': 'str',
|
||||
'createdAt': 'datetime',
|
||||
'updatedAt': 'datetime',
|
||||
'lastActivityAt': 'datetime',
|
||||
'username': 'str',
|
||||
'userId': 'long',
|
||||
'description': 'str',
|
||||
'numberWordsInList': 'long',
|
||||
'type': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.id = None # long
|
||||
self.permalink = None # str
|
||||
self.name = None # str
|
||||
self.createdAt = None # datetime
|
||||
self.updatedAt = None # datetime
|
||||
self.lastActivityAt = None # datetime
|
||||
self.username = None # str
|
||||
self.userId = None # long
|
||||
self.description = None # str
|
||||
self.numberWordsInList = None # long
|
||||
self.type = None # str
|
||||
|
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class WordListWord:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'id': 'long',
|
||||
'word': 'str',
|
||||
'username': 'str',
|
||||
'userId': 'long',
|
||||
'createdAt': 'datetime',
|
||||
'numberCommentsOnWord': 'long',
|
||||
'numberLists': 'long'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.id = None # long
|
||||
self.word = None # str
|
||||
self.username = None # str
|
||||
self.userId = None # long
|
||||
self.createdAt = None # datetime
|
||||
self.numberCommentsOnWord = None # long
|
||||
self.numberLists = None # long
|
||||
|
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class WordObject:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'id': 'long',
|
||||
'word': 'str',
|
||||
'originalWord': 'str',
|
||||
'suggestions': 'list[str]',
|
||||
'canonicalForm': 'str',
|
||||
'vulgar': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.id = None # long
|
||||
self.word = None # str
|
||||
self.originalWord = None # str
|
||||
self.suggestions = None # list[str]
|
||||
self.canonicalForm = None # str
|
||||
self.vulgar = None # str
|
||||
|
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class WordOfTheDay:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'id': 'long',
|
||||
'parentId': 'str',
|
||||
'category': 'str',
|
||||
'createdBy': 'str',
|
||||
'createdAt': 'datetime',
|
||||
'contentProvider': 'ContentProvider',
|
||||
'htmlExtra': 'str',
|
||||
'word': 'str',
|
||||
'definitions': 'list[SimpleDefinition]',
|
||||
'examples': 'list[SimpleExample]',
|
||||
'note': 'str',
|
||||
'publishDate': 'datetime'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.id = None # long
|
||||
self.parentId = None # str
|
||||
self.category = None # str
|
||||
self.createdBy = None # str
|
||||
self.createdAt = None # datetime
|
||||
self.contentProvider = None # ContentProvider
|
||||
self.htmlExtra = None # str
|
||||
self.word = None # str
|
||||
self.definitions = None # list[SimpleDefinition]
|
||||
self.examples = None # list[SimpleExample]
|
||||
self.note = None # str
|
||||
self.publishDate = None # datetime
|
||||
|
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class WordSearchResult:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'count': 'long',
|
||||
'lexicality': 'float',
|
||||
'word': 'str'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.count = None # long
|
||||
self.lexicality = None # float
|
||||
self.word = None # str
|
||||
|
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2012 Wordnik, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
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.
|
||||
"""
|
||||
class WordSearchResults:
|
||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually."""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.swaggerTypes = {
|
||||
'searchResults': 'list[WordSearchResult]',
|
||||
'totalResults': 'int'
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.searchResults = None # list[WordSearchResult]
|
||||
self.totalResults = None # int
|
||||
|
10
samples/client/wordnik-api/python/wordnik/models/__init__.py
Normal file
10
samples/client/wordnik-api/python/wordnik/models/__init__.py
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
"""Add all of the modules in the current directory to __all__"""
|
||||
import os
|
||||
|
||||
__all__ = []
|
||||
|
||||
for module in os.listdir(os.path.dirname(__file__)):
|
||||
if module != '__init__.py' and module[-3:] == '.py':
|
||||
__all__.append(module[:-3])
|
||||
|
203
samples/client/wordnik-api/python/wordnik/swagger.py
Normal file
203
samples/client/wordnik-api/python/wordnik/swagger.py
Normal file
@ -0,0 +1,203 @@
|
||||
#!/usr/bin/env python
|
||||
"""Wordnik.com's Swagger generic API client. This client handles the client-
|
||||
server communication, and is invariant across implementations. Specifics of
|
||||
the methods and models for each application are generated from the Swagger
|
||||
templates."""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import urllib
|
||||
import urllib2
|
||||
import httplib
|
||||
import json
|
||||
import datetime
|
||||
|
||||
from models import *
|
||||
|
||||
|
||||
class ApiClient:
|
||||
"""Generic API client for Swagger client library builds"""
|
||||
|
||||
def __init__(self, apiKey=None, apiServer=None):
|
||||
if apiKey == None:
|
||||
raise Exception('You must pass an apiKey when instantiating the '
|
||||
'APIClient')
|
||||
self.apiKey = apiKey
|
||||
self.apiServer = apiServer
|
||||
self.cookie = None
|
||||
|
||||
def callAPI(self, resourcePath, method, queryParams, postData,
|
||||
headerParams=None):
|
||||
|
||||
url = self.apiServer + resourcePath
|
||||
headers = {}
|
||||
if headerParams:
|
||||
for param, value in headerParams.iteritems():
|
||||
headers[param] = value
|
||||
|
||||
headers['Content-type'] = 'application/json'
|
||||
headers['api_key'] = self.apiKey
|
||||
|
||||
if self.cookie:
|
||||
headers['Cookie'] = self.cookie
|
||||
|
||||
data = None
|
||||
|
||||
if method == 'GET':
|
||||
|
||||
if queryParams:
|
||||
# Need to remove None values, these should not be sent
|
||||
sentQueryParams = {}
|
||||
for param, value in queryParams.items():
|
||||
if value != None:
|
||||
sentQueryParams[param] = value
|
||||
url = url + '?' + urllib.urlencode(sentQueryParams)
|
||||
|
||||
elif method in ['POST', 'PUT', 'DELETE']:
|
||||
|
||||
if postData:
|
||||
headers['Content-type'] = 'application/json'
|
||||
data = self.sanitizeForSerialization(postData)
|
||||
data = json.dumps(data)
|
||||
|
||||
else:
|
||||
raise Exception('Method ' + method + ' is not recognized.')
|
||||
|
||||
request = MethodRequest(method=method, url=url, headers=headers,
|
||||
data=data)
|
||||
|
||||
# Make the request
|
||||
response = urllib2.urlopen(request)
|
||||
if 'Set-Cookie' in response.headers:
|
||||
self.cookie = response.headers['Set-Cookie']
|
||||
string = response.read()
|
||||
|
||||
try:
|
||||
data = json.loads(string)
|
||||
except ValueError: # PUT requests don't return anything
|
||||
data = None
|
||||
|
||||
return data
|
||||
|
||||
def toPathValue(self, obj):
|
||||
"""Convert a string or object to a path-friendly value
|
||||
Args:
|
||||
obj -- object or string value
|
||||
Returns:
|
||||
string -- quoted value
|
||||
"""
|
||||
if type(obj) == list:
|
||||
return urllib.quote(','.join(obj))
|
||||
else:
|
||||
return urllib.quote(str(obj))
|
||||
|
||||
def sanitizeForSerialization(self, obj):
|
||||
"""Dump an object into JSON for POSTing."""
|
||||
|
||||
if not obj:
|
||||
return None
|
||||
elif type(obj) in [str, int, long, float, bool]:
|
||||
return obj
|
||||
elif type(obj) == list:
|
||||
return [self.sanitizeForSerialization(subObj) for subObj in obj]
|
||||
elif type(obj) == datetime.datetime:
|
||||
return obj.isoformat()
|
||||
else:
|
||||
if type(obj) == dict:
|
||||
objDict = obj
|
||||
else:
|
||||
objDict = obj.__dict__
|
||||
return {key: self.sanitizeForSerialization(val)
|
||||
for (key, val) in objDict.iteritems()
|
||||
if key != 'swaggerTypes'}
|
||||
|
||||
if type(postData) == list:
|
||||
# Could be a list of objects
|
||||
if type(postData[0]) in safeToDump:
|
||||
data = json.dumps(postData)
|
||||
else:
|
||||
data = json.dumps([datum.__dict__ for datum in postData])
|
||||
elif type(postData) not in safeToDump:
|
||||
data = json.dumps(postData.__dict__)
|
||||
|
||||
def deserialize(self, obj, objClass):
|
||||
"""Derialize a JSON string into an object.
|
||||
|
||||
Args:
|
||||
obj -- string or object to be deserialized
|
||||
objClass -- class literal for deserialzied object, or string
|
||||
of class name
|
||||
Returns:
|
||||
object -- deserialized object"""
|
||||
|
||||
# Have to accept objClass as string or actual type. Type could be a
|
||||
# native Python type, or one of the model classes.
|
||||
if type(objClass) == str:
|
||||
if 'list[' in objClass:
|
||||
match = re.match('list\[(.*)\]', objClass)
|
||||
subClass = match.group(1)
|
||||
return [self.deserialize(subObj, subClass) for subObj in obj]
|
||||
|
||||
if (objClass in ['int', 'float', 'long', 'dict', 'list', 'str', 'bool', 'datetime']):
|
||||
objClass = eval(objClass)
|
||||
else: # not a native type, must be model class
|
||||
objClass = eval(objClass + '.' + objClass)
|
||||
|
||||
if objClass in [int, long, float, dict, list, str, bool]:
|
||||
return objClass(obj)
|
||||
elif objClass == datetime:
|
||||
# Server will always return a time stamp in UTC, but with
|
||||
# trailing +0000 indicating no offset from UTC. So don't process
|
||||
# last 5 characters.
|
||||
return datetime.datetime.strptime(obj[:-5],
|
||||
"%Y-%m-%dT%H:%M:%S.%f")
|
||||
|
||||
instance = objClass()
|
||||
|
||||
for attr, attrType in instance.swaggerTypes.iteritems():
|
||||
if attr in obj:
|
||||
value = obj[attr]
|
||||
if attrType in ['str', 'int', 'long', 'float', 'bool']:
|
||||
attrType = eval(attrType)
|
||||
try:
|
||||
value = attrType(value)
|
||||
except UnicodeEncodeError:
|
||||
value = unicode(value)
|
||||
setattr(instance, attr, value)
|
||||
elif (attrType == 'datetime'):
|
||||
setattr(instance, attr, datetime.datetime.strptime(value[:-5],
|
||||
"%Y-%m-%dT%H:%M:%S.%f"))
|
||||
elif 'list[' in attrType:
|
||||
match = re.match('list\[(.*)\]', attrType)
|
||||
subClass = match.group(1)
|
||||
subValues = []
|
||||
if not value:
|
||||
setattr(instance, attr, None)
|
||||
else:
|
||||
for subValue in value:
|
||||
subValues.append(self.deserialize(subValue,
|
||||
subClass))
|
||||
setattr(instance, attr, subValues)
|
||||
else:
|
||||
setattr(instance, attr, self.deserialize(value,
|
||||
objClass))
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
class MethodRequest(urllib2.Request):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Construct a MethodRequest. Usage is the same as for
|
||||
`urllib2.Request` except it also takes an optional `method`
|
||||
keyword argument. If supplied, `method` will be used instead of
|
||||
the default."""
|
||||
|
||||
if 'method' in kwargs:
|
||||
self.method = kwargs.pop('method')
|
||||
return urllib2.Request.__init__(self, *args, **kwargs)
|
||||
|
||||
def get_method(self):
|
||||
return getattr(self, 'method', urllib2.Request.get_method(self))
|
||||
|
Loading…
x
Reference in New Issue
Block a user