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.
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
argsorkwargswould be incorrect.argsis anargparse.Namespaceobject containing command-line arguments, not a file object.kwargsis a dictionary used for API filters later in the script, not for loading JSON from a file.api_key,api_base_uri,result, andapi_resultare also not file objects.
- For the second blank, using
api_keyfor thehostparameter would be incorrect.api_keyis a distinct authentication credential, not the API endpoint URL. Usingargswould also be wrong as it contains parsed command-line arguments, not API client configuration parameters. - For the third blank, assigning
resultorkwargswould be incorrect.resultis a dictionary initialized earlier (result = dict(changed=False)) to track if a change occurred, not to hold the API response.kwargsis passed into thegetmethod as arguments, not returned by it.args,api_file,api_key, andapi_base_uriare 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
Community Discussion
No community discussion yet for this question.