fastly / fastly-py Goto Github PK
View Code? Open in Web Editor NEWA Fastly API client for Python
Home Page: https://pypi.org/project/fastly/
License: MIT License
A Fastly API client for Python
Home Page: https://pypi.org/project/fastly/
License: MIT License
Version
Lib version: 5.2.0
.
What happened
I tried to use Enable Product API but it is failing on type error when using multiple methods on instance class of EnabledProductsApi
:
api_response = api_instance.get_enabled_product(**options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/api/enabled_products_api.py", line 471, in get_enabled_product
return self.get_enabled_product_endpoint.call_with_http_info(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/api_client.py", line 872, in call_with_http_info
return self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/api_client.py", line 427, in call_api
return self.__call_api(resource_path, method,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/api_client.py", line 236, in __call_api
return_data = self.deserialize(
^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/api_client.py", line 341, in deserialize
deserialized_data = validate_and_convert_types(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model/enabled_product_response.py", line 186, in _from_openapi_data
setattr(self, var_name, var_value)
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 184, in __setattr__
self[attr] = value
~~~~^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 509, in __setitem__
self.set_attribute(name, value)
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 156, in set_attribute
value = validate_and_convert_types(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/q9k17i98pxvzxxqk7mazb8gnbcpwffj9-python3-3.11.8-env/lib/python3.11/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: EnabledProductResponseLinks._from_openapi_data() got multiple values for argument '_self'
The above error is raised also for python example code from the Fastly documentation.
$ python -m test.api_test
..E.
======================================================================
ERROR: test_auth_session_success (__main__.APITest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/edmund/fastly/fastly-py/test/api_test.py", line 23, in test_auth_session_success
self.api.authenticate_by_password('[email protected]', 'password')
File "fastly/fastly.py", line 23, in authenticate_by_password
self.conn.authenticator = SessionAuthenticator(self.conn, login, password)
File "fastly/auth.py", line 18, in __init__
resp, data = conn.request('POST', '/login', body)
File "fastly/connection.py", line 44, in request
raise AuthenticationError()
AuthenticationError
----------------------------------------------------------------------
Ran 4 tests in 0.784s
FAILED (errors=1)
Version
4.1.1
What happened
Finally got to test the latest updates, but list_acl_entries
is broken. Running identical code to example:
try:
# List ACL entries
api_response = api_instance.list_acl_entries(service_id, acl_id)
pprint(api_response)
except fastly.ApiException as e:
print("Exception when calling AclEntryApi->list_acl_entries: %s\n" % e)
And getting the following error:
Invalid inputs given to generate an instance of 'AclEntry'. The input data was invalid for the allOf schema 'AclEntry' in the composed schema 'AclEntryResponse'. Error=Invalid type for variable 'negated'. Required value type is int and passed type was str at ['received_data'][0]['negated']
fastly.exceptions.ApiTypeError: Invalid type for variable 'negated'. Required value type is int and passed type was str at ['received_data'][0]['negated']
The values of service_id
and acl_id
are valid IDs and type of str
, currently using requests
workaround:
response = requests.get(
"{}/service/{}/acl/{}/entries".format(FASTLY_API_URL, service_id, acl_id),
headers={
"Fastly-Key": FASTLY_API_KEY,
"Accept": "application/json"
},
timeout=5)
It'd be nice to be able to install this via PIP on PyPi.
We'd like to have more confidence in the structure and integrity of the code. Let's get a linter running with our code and clean out any errors/warnings that the linter finds.
just trying the docs for month to date bill found here, and hit an exception internally to the package. Tried another billing_api endpoint and it also hit the same error.
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'Billing'. The input data was invalid for the allOf schema 'Billing' in the composed schema 'BillingEstimateResponse'. Error=Invalid type for variable 'cost'. Required value type is dict and passed type was float at ['received_data']['regions']['usa']['cost']
I noticed when trying to create a Healthcheck
the method
property clashes with the parameter in query()
.
payload = {
"service_id": newService.attrs["id"],
"version": 1,
"name": TEST_NAME,
"host": REQ_HOST,
"method": "GET",
"path": TEST_PATH,
"expected_response": 200,
"check_interval": 60000,
"initial": 1,
"threshold": 1,
"timeout": 5000,
"window": 2,
}
newHealthcheck = fastly.models.Healthcheck.create(api.conn, data=payload)
Traceback (most recent call last):
File "./python/main.py", line 54, in <module>
newHealthcheck = fastly.models.Healthcheck.create(api.conn, data=payload)
File "/usr/local/lib/python2.7/site-packages/fastly/models.py", line 79, in create
instance.save()
File "/usr/local/lib/python2.7/site-packages/fastly/models.py", line 44, in save
resp, data = self._collection_query('POST', body=params_str)
File "/usr/local/lib/python2.7/site-packages/fastly/models.py", line 29, in _collection_query
return self.__class__.query(self.conn, self.COLLECTION_PATTERN, method, suffix, body, **self.attrs)
TypeError: query() got multiple values for keyword argument 'method'
Related to an issue originally reported here:
#88 (comment)
We need to update Fastly's internal OpenAPI schemas to address instances where fields are missing nullable: true
.
Let's use github actions for CI, including setting up a full test account to be used when testing in CI with secret credentials
Hi,
I'm trying to run get_service_detail
function and receiving an error both with using service version and without it:
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1784, in get_allof_instances
allof_instance = allof_class._from_openapi_data(**model_args, **constant_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/version_detail.py", line 239, in _from_openapi_data
setattr(self, var_name, var_value)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 184, in __setattr__
self[attr] = value
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 509, in __setitem__
self.set_attribute(name, value)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 156, in set_attribute
value = validate_and_convert_types(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1619, in validate_and_convert_types
input_value[index] = validate_and_convert_types(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/header_response.py", line 245, in _from_openapi_data
composed_info = validate_get_composed_info(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
allof_instances = get_allof_instances(self, model_args, constant_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1780, in get_allof_instances
for allof_class in self._composed_schemas['allOf']:
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 62, in __get__
result = self._fn()
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/header_response.py", line 387, in _composed_schemas
lazy_import()
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/header_response.py", line 35, in lazy_import
from fastly.model.str_none_type import StrNoneType
ModuleNotFoundError: No module named 'fastly.model.str_none_type'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1784, in get_allof_instances
allof_instance = allof_class._from_openapi_data(**model_args, **constant_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/service_detail_all_of.py", line 181, in _from_openapi_data
setattr(self, var_name, var_value)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 184, in __setattr__
self[attr] = value
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 509, in __setitem__
self.set_attribute(name, value)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 156, in set_attribute
value = validate_and_convert_types(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1462, in attempt_convert_item
raise conversion_exc
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/service_version_detail.py", line 279, in _from_openapi_data
composed_info = validate_get_composed_info(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
allof_instances = get_allof_instances(self, model_args, constant_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1789, in get_allof_instances
raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'VersionDetail'. The input data was invalid for the allOf schema 'VersionDetail' in the composed schema 'ServiceVersionDetail'. Error=No module named 'fastly.model.str_none_type'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/davidg/Code/devops/lambdas/fastly/main.py", line 126, in <module>
api_response = api_instance.get_service_detail(service_id)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api/service_api.py", line 830, in get_service_detail
return self.get_service_detail_endpoint.call_with_http_info(**kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api_client.py", line 862, in call_with_http_info
return self.api_client.call_api(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api_client.py", line 421, in call_api
return self.__call_api(resource_path, method,
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api_client.py", line 232, in __call_api
return_data = self.deserialize(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api_client.py", line 337, in deserialize
deserialized_data = validate_and_convert_types(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1462, in attempt_convert_item
raise conversion_exc
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/service_detail.py", line 226, in _from_openapi_data
composed_info = validate_get_composed_info(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
allof_instances = get_allof_instances(self, model_args, constant_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1789, in get_allof_instances
raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'ServiceDetailAllOf'. The input data was invalid for the allOf schema 'ServiceDetailAllOf' in the composed schema 'ServiceDetail'. Error=Invalid inputs given to generate an instance of 'VersionDetail'. The input data was invalid for the allOf schema 'VersionDetail' in the composed schema 'ServiceVersionDetail'. Error=No module named 'fastly.model.str_none_type'
The code is the example code in get_service_detail with correct api key and service id and using latest 1.1.0 version.
From debbugin it looks like this module is really not exists in the code:
fastly-py/fastly/model/header_response.py
Line 35 in ffef2b7
This module seems to fail to function due to an unresolved import when installed under pipenv
To replicate, using pipenv:
Pipfile:
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
[packages]
fastly = "==0.2.3"
[requires]
python_version = "3.7"
Steps to replicate:
jbeard@jbeard-desktop /tmp/fastly-py-test $ pipenv install
jbeard@jbeard-desktop /tmp/fastly-py-test $ pipenv run python
Python 3.7.3 (default, May 8 2019, 14:42:49)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from fastly import fastly
>>> api = fastly.API()
>>> api.authenticate_by_key('DUMMY')
>>> api.service('DUMMY')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/.venv/lib/python3.7/site-packages/fastly/fastly.py", line 33, in service
return Service.find(self.conn, id=id)
NameError: name 'Service' is not defined
>>>
I believe this can be fixed with an implict import statement in fastly.py:
from fastly.models import *
Version
fastly==4.0.0
What happened
I got an error while trying to list all tokens belonging to a customer.
In order to get started, I used the sample script provided here: https://github.com/fastly/fastly-py/blob/main/docs/TokensApi.md#list_tokens_customer
But when I tested it, I got the following error:
Traceback (most recent call last):
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1784, in get_allof_instances
allof_instance = allof_class._from_openapi_data(**model_args, **constant_args)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model/token.py", line 183, in _from_openapi_data
setattr(self, var_name, var_value)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 184, in __setattr__
self[attr] = value
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 509, in __setitem__
self.set_attribute(name, value)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 160, in set_attribute
check_allowed_values(
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 872, in check_allowed_values
raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid value for `scope` (global:read global), must be one of ['global', 'purge_select', 'purge_all', 'global:read']
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/gasper/Documents/work/experiments/audit_fastly_users/main.py", line 64, in <module>
main()
File "/home/gasper/Documents/work/experiments/audit_fastly_users/main.py", line 45, in main
customer_tokens = list_customer_tokens(fastly_api_key, customer_id)
File "/home/gasper/Documents/work/experiments/audit_fastly_users/main.py", line 32, in list_customer_tokens
api_response = api_instance.list_tokens_customer(customer_id)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api/tokens_api.py", line 850, in list_tokens_customer
return self.list_tokens_customer_endpoint.call_with_http_info(**kwargs)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api_client.py", line 872, in call_with_http_info
return self.api_client.call_api(
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api_client.py", line 427, in call_api
return self.__call_api(resource_path, method,
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api_client.py", line 236, in __call_api
return_data = self.deserialize(
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/api_client.py", line 341, in deserialize
deserialized_data = validate_and_convert_types(
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1619, in validate_and_convert_types
input_value[index] = validate_and_convert_types(
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1462, in attempt_convert_item
raise conversion_exc
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model/token_response.py", line 223, in _from_openapi_data
composed_info = validate_get_composed_info(
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
allof_instances = get_allof_instances(self, model_args, constant_args)
File "/home/gasper/.local/lib/python3.10/site-packages/fastly/model_utils.py", line 1789, in get_allof_instances
raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'Token'. The input data was invalid for the allOf schema 'Token' in the composed schema 'TokenResponse'. Error=Invalid value for `scope` (global:read global), must be one of ['global', 'purge_select', 'purge_all', 'global:read']
I was expecting to get a list containing all tokens belonging to my customer account.
Am I missing something? Can you folks help me to understand that error?
Any support would be highly appreciated!
Thank you!
Version
fastly==1.3.0
What happened
I'm attempting to upload a TLS cert with the upload_tls_bulk_cert()
method.
When I structure the request as per this example:
https://developer.fastly.com/reference/api/tls/platform/#upload-tls-bulk-cert
I get this error:
AttributeError: 'dict' object has no attribute 'tls_configurations'
The error looks like it's originating from the model_utils - I've got a stacktrace here:
https://gist.github.com/mechanicalgirl/9421a604b989b3ebb65aa3b44092b5bf
I've also tried structuring the request as per these docs:
https://github.com/fastly/fastly-py/blob/main/docs/TlsBulkCertificatesApi.md#upload_tls_bulk_cert
Where the error returned is this:
Exception when calling TlsBulkCertificatesApi->upload_tls_bulk_cert: (400)
Reason: Bad Request
HTTP response body: {"errors":[{"title":"Missing required attribute","detail":"param is missing or the value is empty: tls_configuration_ids"}]}
(My apologies, I did not save a stacktrace from this one.)
I've been able to get this working with a workaround that uses the request library and hits the api.fastly.com/tls/bulk/certificates
endpoint directly.
I started with a Fastly support request - one of their engineers directed me to submit an issue here. Their ticket is https://support.fastly.com/hc/en-us/requests/610399 and may provide more detail. (There are some of my code examples in that ticket, although I don't think they'll be helpful as they mirror what's in your docs exactly, aside from the specific values being passed.)
It'd be nice for potential new contributors to be able to know how we do business. Probably should include a code-of-conduct, requirements for PRs (for example, new PRs should have tests and should include updates to the CLI).
Fastly APIs must be used with ssl. Having the environment variable FASTLY_SECURE
which toggles between http and https is not useful and is actively confusing because any communication to fastly's APIs via http will simply not work. Let's remove this feature.
Version
5.2.0
What happened
when calling
api_response = api_instance.list_backends(service_id, version_id)
Changes in the backend_api.py file introduced in version 5.2.0 cause the following exception
File "/Users/ianderso/e-conolight.com/config/fastlytesting/update_fastly_backend.py", line 139, in <module>
main()
File "/Users/ianderso/e-conolight.com/config/fastlytesting/update_fastly_backend.py", line 129, in main
bkends = getBackendNames(api_client, service_id, current_version)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/update_fastly_backend.py", line 69, in getBackendNames
api_response = api_instance.list_backends(service_id, version_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/api/backend_api.py", line 1068, in list_backends
return self.list_backends_endpoint.call_with_http_info(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/api_client.py", line 872, in call_with_http_info
return self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/api_client.py", line 427, in call_api
return self.__call_api(resource_path, method,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/api_client.py", line 236, in __call_api
return_data = self.deserialize(
^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/api_client.py", line 341, in deserialize
deserialized_data = validate_and_convert_types(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 1619, in validate_and_convert_types
input_value[index] = validate_and_convert_types(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 1462, in attempt_convert_item
raise conversion_exc
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model/backend_response.py", line 311, in _from_openapi_data
composed_info = validate_get_composed_info(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
allof_instances = get_allof_instances(self, model_args, constant_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ianderso/e-conolight.com/config/fastlytesting/lib/python3.12/site-packages/fastly/model_utils.py", line 1789, in get_allof_instances
raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'Backend'. The input data was invalid for the allOf schema 'Backend' in the composed schema 'BackendResponse'. Error=Invalid type for variable 'tcp_keepalive_enable'. Required value type is bool and passed type was NoneType at ['received_data'][0]['tcp_keepalive_enable']```
➜ fastly python3 -m pip install fastly
Requirement already satisfied: fastly in /usr/local/lib/python3.11/site-packages (2.2.1)
➜ fastly python3
Python 3.11.2 (main, Mar 24 2023, 00:31:37) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import fastly
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<redacted>/fastly.py", line 2, in <module>
from fastly.api import tokens_api
ModuleNotFoundError: No module named 'fastly.api'; 'fastly' is not a package
>>>
It appears that because the underlying HTTP is powered by the minimal most low-level Python HTTP package that there's no easy way to use a proxy. I'm not sure if this project is still maintained or if it's just an "as-is" alternative to the more up-to-date golang CLI
It would make much more sense to use the third-party requests
package which is the standard for nearly all Python projects doing anything but the simplest HTTP operations
Rather than hack in proxy support, I'm going to fork fastly-py
and make the necessary changes to make it work with requests
, if you're interest in a PR I'm happy to submit it but it will be a pretty invasive change
Running the example from the docs gives me this error:
Traceback (most recent call last):
api.purge_key(service, key)
File "fastly/fastly.py", line 79, in purge_key
resp, data = self.conn.request('POST', '/service/%s/purge/%s' % (service, key), headers=headers)
File "fastly/connection.py", line 35, in request
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
AttributeError: 'module' object has no attribute 'PROTOCOL_TLS'
I'm using python 3.4.2 and fastly 0.1.4.
I ended up using the API directly instead, but curious to find out if this is an issue with my environment or with the way the package is handling SSL connections.
Sorry to nit-pick here, I'm not a lawyer but I'm asked to clarify the license for this code (BSD, MIT, etc.). Do you have a preference?
When writing a try-except block to catch this library's exceptions, one has to add extra lines to catch everything:
try:
# make calls to fastly
except (
fastly.errors.AuthenticationError,
fastly.errors.InternalServerError,
fastly.errors.BadRequestError,
fastly.errors.NotFoundError
) as e:
# handle exception
It would be nice if the error classes shared the same base class so that consumers only had to catch a single exception:
try:
# make calls to fastly
except fastly.errors.FastlyError as e:
# handle exception
One of the features that are currently not implemented in the fastly-py is a model for TLS subscriptions.
This came up when one of our prospects tried to automate their domain/TLS deployment flow using python.
He worked around it with Requests library and our API endpoints which did the job, but an official support would be great.
Thanks!
Version
4.0.0 (and 3.x.x)
TLDR
I am running into a bug with regards to Boolean values.
The bug seems to be in the way data is send to the API by the Fastly-py library, not necessarily in the API itself.
The REST calls where this issue arises are of Content-Type ‘application/x-www-form-urlencoded’. The given values are transferred to the server 1:1. This means that when I provide a Python Boolean (i.e. False or True) for a certain parameter, it is sent as such to the API, although the API only seems to understand lowercase Boolean values, or binary values such as 0 or 1.
What I did
I stumbled upon this bug while trying to create objects with specific parameters of type ‘Boolean’, in my case a backend object for my service with specific values for ‘ssl_check_cert’ and ‘use_ssl’.
My code does the following:
What I expected would happen
I expected a service would be created, with a backend which has both 'ssl_check_cert' and 'use_ssl' set to False.
What actually happened
I noticed that the values given in my Python code were not reflected in the created backend object. The values for both 'ssl_check_cert' and 'use_ssl' were set to True (the default value), completely ignoring my values during creation.
This behavior indicates that the given values are not understood by the Fastly API.
Extra comment
I’m not a programmer so I don’t know the best solution for this. I did however find a dirty hack which worked for me as a temporarily solution. I noticed this ‘_urlencode’ function in a very old version of the fastly-py project (0.5.x), which says something about converting Boolean to lowercase:
I somewhat recreated this function as follows:
def sanitize_list_of_tuples(input_list):
def sanitize_value(value):
""" Sanitize the value """
if isinstance(value, bool):
# Perform the desired conversion for booleans
return int(value) # Example: Convert boolean to integer
# Handle other value types if needed
return value
sanitized_list = []
for key, value in input_list:
sanitized_value = sanitize_value(value)
sanitized_list.append((key, sanitized_value))
return sanitized_list
I added this function at the top of rest.py and added the following line before line 161 of rest.py:
post_params = sanitize_list_of_tuples(post_params)
This results in Boolean values being converted to their integer/binary representation, which the Fastly API does interpret correctly.
As I said, I’m not sure if this is the best solution, probably not, you guys probably know a better way to fix this issue across the board.
Let me know if you need any further information or assistance!
Thanks in advance,
Mark
Fastly 0.0.3 isn't available on the index.
The web page exists: https://pypi.python.org/pypi/fastly/0.0.3
But the code isn't there.
$ pip install fastly==0.0.3
Collecting fastly==0.0.3
Could not find a version that satisfies the requirement fastly==0.0.3 (from versions: 0.0.2)
No distributions matching the version for fastly==0.0.3
it's nice to be able to have the tooling in place to do all the critical tasks with the project, specifically:
python --version
Python 2.7.11
pip install fastly
import fastly
api_key = '123'
api = fastly.API()
api.authenticate_by_key(api_key)
print api.__dict__
I'm using the exact example from the README
Module 'fastly' has no 'API' member
it would be nice to officially have some documentation for this package and its public functions. We should use a system like PyDoc to do this.
It would be helpful if this were on PyPI.
Version
4.2.2
What happened
When installing the 4.2.2 version, the required dependencies are not resolved. For e.g.
12:10 $ pip install fastly
Looking in indexes: https://local-pypi-repo/artifactory/api/pypi/pypi-repos/simple
Collecting fastly
Downloading https://local-pypi-repo/artifactory/api/pypi/pypi-repos/packages/packages/22/ef/651e717cba0fbf73ad1a23256b1224860aa1172e5c521482d4b870d75153/fastly-4.2.2-py3-none-any.whl (2.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.6/2.6 MB 7.9 MB/s eta 0:00:00
Installing collected packages: fastly
Successfully installed fastly-4.2.2
I would expect urllib3
and python-dateutil
to be installed as per the setup config here.
The missing package metadata (and the dependencies) results in import errors
Python 3.9.13 (main, Jan 31 2023, 15:38:49)
[Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import fastly
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/dmistry/.pyenv/versions/gh-py-libs-39/lib/python3.9/site-packages/fastly/__init__.py", line 16, in <module>
from fastly.api_client import ApiClient
File "/Users/dmistry/.pyenv/versions/gh-py-libs-39/lib/python3.9/site-packages/fastly/api_client.py", line 20, in <module>
from urllib3.fields import RequestField
ModuleNotFoundError: No module named 'urllib3'
>>>
In connection.py
there are only a few HTTP error codes checked for: 400,401,403,404,500
but we often see several other responses, especially HTTP 502
. The logic to do this checking is a little flawed, it assumes any response not caught specifically is an OK response, requiring clients to do extensive checking on each call for the extra error cases.
This logic should be rewritten to either raise specific errors for all possible cases, or to raise a default error when the status code is not 2xx
.
Version
Python 3.11.3
fastly 2.3.0
What happened
Tried following each of these CustomerApi list_users examples:
https://developer.fastly.com/reference/api/account/customer/#list-users
https://github.com/fastly/fastly-py/blob/main/docs/CustomerApi.md#list_users
With both, I get this error:
Traceback (most recent call last):
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1784, in get_allof_instances
allof_instance = allof_class._from_openapi_data(**model_args, **constant_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model/user.py", line 198, in _from_openapi_data
setattr(self, var_name, var_value)
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 184, in __setattr__
self[attr] = value
~~~~^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 509, in __setitem__
self.set_attribute(name, value)
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 156, in set_attribute
value = validate_and_convert_types(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1448, in attempt_convert_item
raise get_type_error(input_value, path_to_item, valid_classes,
fastly.exceptions.ApiTypeError: Invalid type for variable 'require_new_password'. Required value type is bool and passed type was NoneType at ['received_data'][0]['require_new_password']
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/pnickerson/repositories/devops_shared/cashstar/./uar-fastly.py", line 32, in <module>
api_response = api_instance.list_users(customer_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/api/customer_api.py", line 762, in list_users
return self.list_users_endpoint.call_with_http_info(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/api_client.py", line 872, in call_with_http_info
return self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/api_client.py", line 427, in call_api
return self.__call_api(resource_path, method,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/api_client.py", line 236, in __call_api
return_data = self.deserialize(
^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/api_client.py", line 341, in deserialize
deserialized_data = validate_and_convert_types(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1619, in validate_and_convert_types
input_value[index] = validate_and_convert_types(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1462, in attempt_convert_item
raise conversion_exc
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model/schemas_user_response.py", line 226, in _from_openapi_data
composed_info = validate_get_composed_info(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
allof_instances = get_allof_instances(self, model_args, constant_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pnickerson/.local/lib/python3.11/site-packages/fastly/model_utils.py", line 1789, in get_allof_instances
raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'User'. The input data was invalid for the allOf schema 'User' in the composed schema 'SchemasUserResponse'. Error=Invalid type for variable 'require_new_password'. Required value type is bool and passed type was NoneType at ['received_data'][0]['require_new_password']
If I use curl against the API, I notice the result includes this key-value pair:
[{"require_new_password": null,...},...]
Looks like this isn't supported? The API documents are ambiguous on if you can even get a list of services, but it seems possible?
Currently it's necessary to set up an .env
file and source
it before testing. This file requires a lot of information about a fastly user account (including username, password, account token, service-id. Plus the service-id that you reference needs to have certain things set up, but none of this configuration is documented. Let's get this fully documented so it's easy for anyone to test this library.
The readme file mentions "This 1.x release" but we're well into 2.x releases now. Also, couldn't find a CONTRIBUTING file that would tell me where to send a PR to fix it myself.
Version 1.0.0
This is happening for various API calls. When passing the int value to the call it still says string is passed.
fastly.exceptions.ApiTypeError: Invalid type for variable 'version'. Required value type is int and passed type was str at ['received_data']['version']
This is the API call where version_is is int, I tried type casting too but still the same problem persists.
I observed this in other calls too.
api_response = api_instance.create_snippet(service_id, 44 , name=snippet_name, dynamic=dynamic, type=type, content=content, priority=priority)
Traceback (most recent call last):
File "/Users/kondapal/fastly_py/main.py", line 47, in
vcl.createVCLSnippet(configuration, service_id, int(cloned_service_version), acl_name, vcl_snippet)
File "/Users/kondapal/fastly_py/vcl.py", line 43, in createVCLSnippet
api_response = api_instance.create_snippet(service_id, version_id , name=snippet_name, dynamic=dynamic, type=type, content=content, priority=priority)
File "/usr/local/lib/python3.10/site-packages/fastly/api/snippet_api.py", line 573, in create_snippet
return self.create_snippet_endpoint.call_with_http_info(**kwargs)
File "/usr/local/lib/python3.10/site-packages/fastly/api_client.py", line 862, in call_with_http_info
return self.api_client.call_api(
File "/usr/local/lib/python3.10/site-packages/fastly/api_client.py", line 421, in call_api
return self.__call_api(resource_path, method,
File "/usr/local/lib/python3.10/site-packages/fastly/api_client.py", line 232, in __call_api
return_data = self.deserialize(
File "/usr/local/lib/python3.10/site-packages/fastly/api_client.py", line 337, in deserialize
deserialized_data = validate_and_convert_types(
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 1462, in attempt_convert_item
raise conversion_exc
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/fastly/model/snippet_response.py", line 233, in _from_openapi_data
composed_info = validate_get_composed_info(
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
allof_instances = get_allof_instances(self, model_args, constant_args)
File "/usr/local/lib/python3.10/site-packages/fastly/model_utils.py", line 1789, in get_allof_instances
raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'ServiceIdAndVersion'. The input data was invalid for the allOf schema 'ServiceIdAndVersion' in the composed schema 'SnippetResponse'. Error=Invalid type for variable 'version'. Required value type is int and passed type was str at ['received_data']['version']
Version
Please provide the version of fastly
that you're using.
4.2.1
What happened
When attempting to run api_instance.create_log_gcs(service_id, version_id, etc..)
, I get the following error:
venv/lib/python3.10/site-packages/fastly/model/logging_gcs_response.py", line 38, in lazy_import
from fastly.model.str_none_type import StrNoneType
ModuleNotFoundError: No module named 'fastly.model.str_none_type'
Please describe what you did, what you expected to happen, and what happened instead.
What I did: Attempted to create a GCS logging endpoint using create_log_gcs with compression_codec
set to None
since I have gzip
set to 3
and the docs specifically state "Specifying both compression_codec
and gzip_level
in the same API request will result in an error. (optional)".
Then, I set compression_codec
to an empty string since it's not nullable according to the README and the API returned the same error as above^.
So I'm stuck..
What I expected to happen: I expected the GCS logging endpoint to be created 🪄
What happened: I get the following error
venv/lib/python3.10/site-packages/fastly/model/logging_gcs_response.py", line 38, in lazy_import
from fastly.model.str_none_type import StrNoneType
ModuleNotFoundError: No module named 'fastly.model.str_none_type'
If you provide a name for a Model
, such as a Healthcheck
that has a space in it, the created URI will fail with a 404 as the space has not been escaped to %20
.
The naive fix is something like the following in models.py:
@@ -12,6 +12,9 @@ class Model(object):
@classmethod
def query(cls, conn, pattern, method, suffix='', body=None, **kwargs):
+ for key in kwargs:
+ value = quote(kwargs[key], safe='')
+ kwargs[key] = value
This isn't entirely explicit though as the overlap between self.attrs
as source for body data and URI data isn't entirely clear.
[ ] Check out 2to3 https://docs.python.org/2/library/2to3.html
[ ] Take over https://github.com/zebrafishlabs/fastly-python and combine? @zebrafishlabs
Is this repo abandoned? There are several PR's going back to 2020 that have no movement. Our own project still requires a working 2.7 compatible fastly library (for now) and we need to be able to access ACLs. I have a fork where I am adding this ability and about to submit a PR, but it looks like that may be in vain.
Currently there is no requirements.txt
file for this library, so its dependencies are poorly documented. There are also no instructions for using with with virtualenv
. Let's get these written up.
Version
1.1.0
What happened
Running sample code for list_acls
fails as the returned version in API request is string and the python expects for integer:
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1784, in get_allof_instances
allof_instance = allof_class._from_openapi_data(**model_args, **constant_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/service_id_and_version.py", line 175, in _from_openapi_data
setattr(self, var_name, var_value)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 184, in __setattr__
self[attr] = value
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 509, in __setitem__
self.set_attribute(name, value)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 156, in set_attribute
value = validate_and_convert_types(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1448, in attempt_convert_item
raise get_type_error(input_value, path_to_item, valid_classes,
fastly.exceptions.ApiTypeError: Invalid type for variable 'version'. Required value type is int and passed type was str at ['received_data'][0]['version']
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/davidg/Code/devops/lambdas/fastly/main.py", line 106, in <module>
lambda_handler({}, "")
File "/Users/davidg/Code/devops/lambdas/fastly/main.py", line 87, in lambda_handler
fastly_get_service_acl(service_id, version_id)
File "/Users/davidg/Code/devops/lambdas/fastly/main.py", line 35, in fastly_get_service_acl
api_response = api_instance.list_acls(service_id, 15)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api/acl_api.py", line 690, in list_acls
return self.list_acls_endpoint.call_with_http_info(**kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api_client.py", line 862, in call_with_http_info
return self.api_client.call_api(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api_client.py", line 421, in call_api
return self.__call_api(resource_path, method,
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api_client.py", line 232, in __call_api
return_data = self.deserialize(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/api_client.py", line 337, in deserialize
deserialized_data = validate_and_convert_types(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1619, in validate_and_convert_types
input_value[index] = validate_and_convert_types(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1569, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1462, in attempt_convert_item
raise conversion_exc
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1453, in attempt_convert_item
return deserialize_model(input_value, valid_class,
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1373, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 369, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 45, in wrapped_init
return fn(_self, *args, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model/acl_response.py", line 204, in _from_openapi_data
composed_info = validate_get_composed_info(
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1992, in validate_get_composed_info
allof_instances = get_allof_instances(self, model_args, constant_args)
File "/opt/homebrew/lib/python3.9/site-packages/fastly/model_utils.py", line 1789, in get_allof_instances
raise ApiValueError(
fastly.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'ServiceIdAndVersion'. The input data was invalid for the allOf schema 'ServiceIdAndVersion' in the composed schema 'AclResponse'. Error=Invalid type for variable 'version'. Required value type is int and passed type was str at ['received_data'][0]['version']
From some debugging I see that it's not changing the type in remove_uncoercible
function. The type pair <str>, <int>
is not UPCONVERSION_TYPE_PAIRS
and must_convert
is passed False here
fastly-py/fastly/model_utils.py
Line 1079 in ffef2b7
Are there plans to implement all APIs in this module? Looks like it is only supporting a readonly API calls. go-fastly seems to have a more complete implementation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.