Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOSession - Error when calling TOSession.get_parameters_by_profile_id #6589

Closed
davidc0le opened this issue Feb 28, 2022 · 0 comments · Fixed by #6590
Closed

TOSession - Error when calling TOSession.get_parameters_by_profile_id #6589

davidc0le opened this issue Feb 28, 2022 · 0 comments · Fixed by #6590
Labels
bug something isn't working as intended TC Client (python) related to the Python implementation of a TC client

Comments

@davidc0le
Copy link
Contributor

This Bug Report affects these Traffic Control components:

  • Traffic Control Client - Python

Current behavior:

When calling TOSession.get_parameters_by_profile_id with a valid profile_id, an error is received. The code used was as follows:

    with TOSession(ats_host, verify_cert=verify_cert) as traffic_ops_api:
        traffic_ops_api.login(to_user, to_pass)
        profiles = traffic_ops_api.get_profiles()[0]
        src = profiles[1] 
        params = traffic_ops_api.get_parameters_by_profile_id(profile_id=src.id)

And the error:

ERROR:trafficops.restapi:restapi.py:_build_endpoint:344: Expecting a value for keyword argument ['id'] for format field specification ['profiles/{id:d}/parameters']
ERROR:root:Expecting a value for keyword argument ['id'] for format field specification ['profiles/{id:d}/parameters']
Traceback (most recent call last):
File "/path/to/apache-trafficcontrol-6.0.2/traffic_control/clients/python/trafficops/restapi.py", line 339, in _build_endpoint
new_api_path = api_path.format(**url_params) + qparams
KeyError: 'id'

ValueError: Expecting a value for keyword argument ['id'] for format field specification ['profiles/{id:d}/parameters']

The decorator for method get_parameters_by_profile_id is using a different variable to the one defined in the method ( profile_id vs id ).

Expected behavior:

A list of parameters should be returned.

Steps to reproduce:

The following code could be used to reproduce the issue:

    with TOSession(ats_host, verify_cert=verify_cert) as traffic_ops_api:
        traffic_ops_api.login(to_user, to_pass)
        profiles = traffic_ops_api.get_profiles()[0]
        src = profiles[1] 
        params = traffic_ops_api.get_parameters_by_profile_id(profile_id=src.id)
@davidc0le davidc0le added the bug something isn't working as intended label Feb 28, 2022
@rawlinp rawlinp added the TC Client (python) related to the Python implementation of a TC client label Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working as intended TC Client (python) related to the Python implementation of a TC client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants