nerdexam
CiscoCisco

200-901 · Question #398

200-901 Question #398: Real Exam Question with Answer & Explanation

This question assesses the ability to correctly construct a Python script using the Cisco Intersight SDK by filling in missing arguments and variable assignments based on context.

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:

Explanation

This question assesses the ability to correctly construct a Python script using the Cisco Intersight SDK by filling in missing arguments and variable assignments based on context.

Approach. 1. The first blank is within intersight_api_params.json.load(__________). The preceding line with open(args.api_params, 'r') as api_file: opens a file and assigns the file object to the variable api_file. The json.load() function expects a file-like object to parse JSON data. Therefore, api_file is the correct option here. 2. The second blank is within host=intersight_api_params['__________']. This line configures the IntersightApiClient instance, specifically setting the host parameter. The intersight_api_params variable is a dictionary loaded from a JSON file. The host parameter typically refers to the base Uniform Resource Identifier (URI) for the API. Among the given options, api_base_uri is the most appropriate key to retrieve the base URI from the configuration dictionary. The API documentation in the first image supports this by showing full URIs. 3. The third blank is __________ = api_handle.asset_device_registrations_get(**kwargs). This line assigns the return value of an API call to a variable. The subsequent line, for device in api_result.results:, clearly indicates that the variable holding the API response must be named api_result because it is expected to have a results attribute that can be iterated over. Thus, api_result is the correct choice.

Common mistakes.

  • common_mistake. 1. For the first blank, using args or kwargs would be incorrect. args is an argparse.Namespace object containing command-line arguments, not a file object. kwargs is a dictionary used for API filters later in the script, not for loading JSON from a file. api_key, api_base_uri, result, and api_result are also not file objects.
  1. For the second blank, using api_key for the host parameter would be incorrect. api_key is a distinct authentication credential, not the API endpoint URL. Using args would also be wrong as it contains parsed command-line arguments, not API client configuration parameters.
  2. For the third blank, assigning result or kwargs would be incorrect. result is a dictionary initialized earlier (result = dict(changed=False)) to track if a change occurred, not to hold the API response. kwargs is passed into the get method as arguments, not returned by it. args, api_file, api_key, and api_base_uri are also clearly inappropriate for storing an API call's response object.

Concept tested. Python scripting fundamentals, including variable assignment, function arguments (positional and keyword arguments, unpacking with **kwargs), working with file objects, JSON parsing (json.load), understanding object-oriented programming (instance creation, method calls), and configuring/using an SDK for API interaction (specifically Cisco Intersight SDK). It also tests the ability to read and understand code context to infer correct variable usage and program flow.

Topics

#Python Programming#Cisco SDKs#API Interaction#Network Automation

Community Discussion

No community discussion yet for this question.

Full 200-901 PracticeBrowse All 200-901 Questions