Volume 2 - Chapter 23: Understanding REST and JSON Flashcards

(41 cards)

1
Q

What are the 6 attributes of a REST-Based (RESTful) API?

A
  1. Client/Server architecture
  2. Stateless operation
  3. Client statement of cacheable/uncacheable
  4. Uniform interface
  5. Layered
  6. Code-on-demand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False:

HTTP is required for an API to be considered RESTful.

A

False; while HTTP/HTTPS is common, it is not a requirement for an API to be considered RESTful.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe how the client/server model functions with a RESTful API.

A
  1. A REST client makes an API REST call to the REST server
  2. The REST server returns a response to the client
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe how a stateless operation works with a RESTful API.

A

APIs that are considered RESTful are stateless; they do not track or keep information about previous API calls or request.

REST servers do not make decisions based on previous requests.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does the function of “cacheable/uncacheable” content fit in with RESTful APIs?

A
  1. REST APIs must clearly mark content as cacheable or uncacheable
  2. If cacheable, a clear timer must be established for when the content needs to be downloaded again
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In regards to Python and other scripting languages, describe the difference between a list and a dictionary.

A

A list is a list of multiple values

A dictionary is a list of matching key:value pairs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The following diagram is an example of a ____.

A

Dictionary, that contains multiple key:value pairs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The following diagram is an example of a ____.

A

List

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the 4 primary functions that can be performed by an application?

A

CRUD:
* Create: Create new variables and data structures on a server
* Read: Read existing varialbes and data structures on a server
* Update: Update existing variables and data structures on a server
* Delete: Delete existing varialbes and data structures on a server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the REST HTTP equivilent to a CRUD “Create” function?

A

POST

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the REST HTTP equivilent to a CRUD “Read” function?

A

GET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the REST HTTP equivilent to a CRUD “Update” function?

A

PATCH, or PUT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the REST HTTP equivilent to a CRUD “Delete” function?

A

DELETE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What term best describes the following?

A resource that an HTTP request will act on.

A

A Uniform Resource Indicator (URI).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In regards to a REST GET Request, what part of a URI structure indicates the transport protocol used to transfer the requested data?

A

The Scheme (Protocol)

For example: https:// or http://

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In regards to a REST GET Request, what part of a URI structure indicates the destination device that is hosting the requested data?

A

The Authority (Host:Port)

For example: 192.168.50.2:875

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

In regards to a REST GET Request, what part of a URI structure identifies the data, and its location on the device that is hosting it?

A

The Path (Resource)

For example: /root/etc/myfiles/notes.txt

18
Q

In regards to a REST GET Request, what part of a URI structure identifies optional parameters for the request used for identifying variables?

A

The Query (Parameter)

For example: ?parm1=192.168.30.2

19
Q

The following image is an example of a?

A

JSON output from a REST API call.

20
Q

What term best describes the following?

A technique used to represent variables as text, send them over a network, or store them in a file.

A

Data Serialization Languages

21
Q

JSON Stands for?

A

JavaScript Object Notation.

22
Q

XML stands for?

A

eXtensible Markup Language.

23
Q

The following image is an example of a?

A

XML output from a REST API call.

24
Q

A technician uses a rest API to request information from a wireless controller. The technician expects to get the following key-value pairs for a dictionary called “statistics”:
* Number of Errors: 482
* Controller Uptime in Days: 399
* Device Hostname: CNTRL-WLC

How would the format of the output of this dictionary be if using XML? (Roughly)

A
        <root>
             <statistics>
                  <errornum>482</errornum>
                  <uptime>399</uptime>
                  <hostname>CNTRL-WLC</hostname>
             </statistics>
        </root>
25
The following image is an example of a?
Output from a YAML REST API call
26
YAML stands for?
YAML Ain't Markup Language.
27
What is the main difference between YAML and XML in regards to data presentation?
YAML does not provide/define markup details, while XML does.
28
A technician uses a rest API to request information from a wireless controller. The technician expects to get the following key-value pairs for a dictionary called "auth": * Host IP: 10.10.20.20 * Username: myuser * Password: mypass How would the format of the output of this dictionary be if using YAML? (Roughly)
``` vars: auth: host: "{{ 10.10.20.20 }}" username: "{{ myuser }}" password: "{{ mypass }}" ```
29
Which data model language best matches the following? A language that is only used for general data modeling?
YAML.
30
Which data model language best matches the following? A language that is used for general data modeling and serialization?
JSON.
31
Which data model language best matches the following? A language that is used for test markup and data modeling
XML
32
What would be the correct JSON formatting for an object that has 3 string key-value pairs? * address1 is 123 4th St * address2 is 456 6th St * addresss is 789 10th St.
``` { "address1": "123 4th St", "address2": "456 6th St", "address3": "789 10th St" } ```
33
Identify the problem with the following JSON dictonary: ``` { "country1": "canada" "country2": "america" "country3": "sweden" } ```
The key:value pairs for country 1 & 2 are missing a comma. The correct formating is: ``` { "country1": "canada", "country2": "america", "country3": "sweden" } ```
34
What would be the correct JSON formatting for an object that has 3 number key-value pairs? * num1 is 295 * num2 is 3 * num3 is 1001
``` { "num1": 295, "num2": 3, "num3": 101 } ```
35
What would be the correct JSON formatting for an array that has 3 string values? * Germany * Britain * Canada
. ``` [ "Germany", "Britain", "Canada" ] ```
36
Identify the problem with the following JSON array: ``` { "do it faster" "makes us stronger" "somebody" } ```
There are 2 problems with this output. The array should use square brackets, not curly brackets, and there is no comma between entries. The correct output would be: ``` [ "do it faster", "makes us stronger", "somebody" ] ```
37
What would be the correct JSON formatting for an object with 2 arrays that match the following? favfoods: chocolate, banana, and redgrapes favnums: 95, 1111, and 1337
. ``` { "favfoods": [ "chocolate", "banana", "redgrapes" ] "favnums": [ 96, 1111, 1337 ] } ```
38
In JSON, the opening and closing curly brackets {} represent a(n) ____ whereas the square brackets [] represent a(n) ____
In JSON, the opening and closing curly brackets {} represent a(n) **object** whereas the square brackets [] represent a(n) **array**
39
What would be the correct JSON formatting for an object with 2 objects that match the following? myscores: * math=79 * science=93 * english=66 teachers: * math=ashley * science=trevor * english=ramone
. ``` { "myscores": { "math": 79, "science": 93, "english": 66 } "teachers": { "math": "ashley", "science": "trevor", "english": "ramone" } } ```
40
Identify the problem with the following JSON object: . ``` [ "myscores": { "math": 79, "science": 93, "english": 66 } "teachers": { "math": ashley, "science": trevor, "english": ramone } ] ```
There are 2 problems with the example: 1. The outter brackets should be curly, as the example is an object 2. The names of the teachers under the "teachers" object should have quotes The correct output is: ``` { "myscores": { "math": 79, "science": 93, "english": 66 } "teachers": { "math": "ashley", "science": "trevor", "english": "ramone" } } ```
41
True or False: JSON does not store whitespace in its code.
True, when JSON code is stored in a file or sent over a network it does not include whitespace.