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

Cannot deserialize input data due to invalid discriminator value. #30

Open
Christophoclese opened this issue Nov 15, 2022 · 2 comments
Open

Comments

@Christophoclese
Copy link

Christophoclese commented Nov 15, 2022

Hi, I am getting an ApiValueError when attempting to retrieve a list of our server assets. I'm not sure if this is something I'm doing wrong. This is using version 1.0.11.9235 of the module.

Code:

from intersight.api import view_api

api_instance = view_api.ViewApi(api_client)
api_response = api_instance.get_view_server_list(top=1)

Traceback:

Traceback (most recent call last):
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\intersight-test.py", line 58, in <module>
    api_response = api_instance.get_view_server_list(top=1)
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\api\view_api.py", line 714, in get_view_server_list
    return self.get_view_server_list_endpoint.call_with_http_info(**kwargs)
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\api_client.py", line 887, in call_with_http_info
    return self.api_client.call_api(
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\api_client.py", line 422, in call_api
    return self.__call_api(resource_path, method,
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\api_client.py", line 227, in __call_api
    return_data = self.deserialize(
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\api_client.py", line 333, in deserialize
    deserialized_data = validate_and_convert_types(
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\model_utils.py", line 1583, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\model_utils.py", line 1472, in attempt_convert_item
    raise conversion_exc
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\model_utils.py", line 1463, in attempt_convert_item
    return deserialize_model(input_value, valid_class,
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\model_utils.py", line 1377, in deserialize_model
    return model_class._new_from_openapi_data(**kw_args)
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\model_utils.py", line 49, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "C:\Users\cbarton\Desktop\Experiments\intersight-python\venv\lib\site-packages\intersight\model_utils.py", line 402, in _new_from_openapi_data
    raise ApiValueError(
intersight.exceptions.ApiValueError: Cannot deserialize input data due to invalid discriminator value. The OpenAPI document has no mapping for discriminator property 'ObjectType'='compute.Physical.List' at path: ['received_data']
@dsoper2
Copy link

dsoper2 commented Feb 21, 2023

Sorry for the slow response on this issue. While waiting on a fix an alternative to the view_api using the compute_api can be found at https://github.com/dsoper2/DEVWKS-2254/blob/main/src/clive_intersight_python.ipynb:
import intersight.api.compute_api

Create physical summary (server) class instance

api_instance = intersight.api.compute_api.ComputeApi(api_client)

Find the count of servers in the account

server_query = api_instance.get_compute_physical_summary_list(count=True)
print(server_query)

Intersight limits the number of items returned. Page through returned results and select Name, Model, Serial

per_page = 50
query_select = "Name,Model,Serial"
for i in range(0, server_query.count, per_page):
page_query = api_instance.get_compute_physical_summary_list(top=per_page, skip=i, select=query_select)
print(page_query)

@Christophoclese
Copy link
Author

Thanks for the suggestions @dsoper2!

I ended up implementing an alternate workaround by passing _preload_content=False into get_view_server_list(). This disables the automatic serialization of JSON into objects.

import intersight

from intersight.api import view_api

page_size = 100
page_start = 0
server_list = []
records_available = 0

# Initialize the View API client
view_api_instance = view_api.ViewApi(self.intersight_client)

# Attempt to obtain information on servers in Intersight
while page_start <= records_available:
    api_response = view_api_instance.get_view_server_list(
        _preload_content=False,
        top=page_size,
        skip=page_start,
    )
    intersight_data = json.loads(api_response.read())
    server_list += intersight_data['Results']
    page_start += page_size
    records_available = intersight_data['Count']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants