nerdexam
Cisco

200-901 · Question #557

Drag and Drop Question Refer to the exhibit. Drag and drop the code from the bottom onto the box where the code is missing to construct a Python script by using the Cisco SDK. Not all options are…

The correct answer is api_key_id; api_instance; filter; args. The question requires completing a Python script using the Cisco Intersight SDK by dragging and dropping the correct code snippets into the appropriate blanks to properly initialize the API client, create an API handler, and construct a query filter.

Cisco Platforms and Development

Question

Drag and Drop Question Refer to the exhibit. Drag and drop the code from the bottom onto the box where the code is missing to construct a Python script by using the Cisco SDK. Not all options are used. Answer:

Exhibit

200-901 question #557 exhibit

Answer Area

Drag items

filterapi_key_idargsdeviceapi_base_urlapi_instance

Correct arrangement

  • api_key_id
  • api_instance
  • filter
  • args

Explanation

The question requires completing a Python script using the Cisco Intersight SDK by dragging and dropping the correct code snippets into the appropriate blanks to properly initialize the API client, create an API handler, and construct a query filter.

Approach. To correctly complete the Python script, each blank must be filled based on the context of the surrounding code and common practices when using the Cisco Intersight SDK:

  1. Blank 1 (Line 13): api_key_id = intersight_api_params['[BLANK 1]']

    • This line is part of the IntersightApiClient initialization, specifically for providing the API key ID. The intersight_api_params dictionary is being accessed to retrieve this value. Given the variable name api_key_id on the left side of the assignment, the most logical key to access in the intersight_api_params dictionary for this value is 'api_key_id'. Therefore, 'api_key_id' is the correct snippet.
  2. Blank 2 (Line 14): api_handle = asset_device_registration_api.AssetDeviceRegistrationApi([BLANK 2])

    • This line instantiates an API handler object (AssetDeviceRegistrationApi). In the Cisco Intersight SDK (and many other Python SDKs), API handlers require an instantiated API client object (like IntersightApiClient) to be passed to them during initialization. This client object manages the actual HTTP communication. The api_instance variable, defined just above, holds the IntersightApiClient object. Therefore, 'api_instance' is the correct snippet.
  3. Blank 3 (Line 15): kwargs = dict([BLANK 3]="ConnectionStatus eq 'Connected'")

    • This line constructs a dictionary kwargs that is later passed to api_handle.asset_device_registrations_get(**kwargs). The value "ConnectionStatus eq 'Connected'" is an OData filter string used to narrow down the results of an API query. In many REST APIs, including Intersight, OData filter strings are passed using a parameter typically named 'filter'. Therefore, 'filter' is the correct snippet.

Common mistakes.

  • common_mistake. Common mistakes arise from misunderstanding the purpose of each blank or the standard usage of the Cisco Intersight SDK. Here's why the other options are incorrect for the specific blanks:

  • 'args': This variable is used later in the script as args.hostname to access command-line arguments. It is not a dictionary key for API parameters or an ApiClient instance.

  • 'device': This variable is used within the loop (for device in api_result.results:) to iterate over individual device objects. It is not a dictionary key for API parameters or an ApiClient instance.

  • 'api_base_uri': This string is already used as a dictionary key for the host parameter during IntersightApiClient initialization (host = intersight_api_params['api_base_uri']). It is not the key for api_key_id, nor is it an ApiClient instance or a filter parameter name.

Concept tested. The core concepts tested include: understanding of Python programming fundamentals (dictionary access, object instantiation), familiarity with the Cisco Intersight Python SDK (API client initialization, API handler creation), common patterns for interacting with REST APIs (passing authentication credentials, constructing query parameters like filters), and interpreting code context to complete a script.

Topics

#Python#Cisco SDK#DNA Center#API interaction

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice