REST APIs Flashcards

1
Q

What is an API?

A

A software interface that allows two applications to communicate with each other

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

What does CRUD stand for in the context of REST APIs?

A

Create, Read, Update, and Delete

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

What is a CRUD create operation?

A

Used to create a new variable and set its initial value

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

What is a CRUD read operation?

A

Used to retrieve the value of a variable

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

What is a CRUD update operation?

A

Used to change the value of a variable

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

What is a CRUD delete operation?

A

Used to delete a variable

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

HTTP uses _____ that map to CRUD operations

A

verbs

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

HTTP _____ maps to CRUD create

A

POST

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

HTTP _____ maps to CRUD read

A

GET

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

HTTP _____ maps to CRUD update

A

PUT, PATCH

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

HTTP _____ maps to CRUD delete

A

DELETE

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

What is an HTTP URI?

A

Uniform Resource Identifier,

Indicates a particular resource available on an HTTP server

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

An HTTP request will always include a ______ and a _____

A

HTTP Verb and a URI

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

Do REST APIs always have to use HTTP?

A

No, although HTTP is the most common

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

HTTP 1xx response codes indicate what?

A

Informational response code. request was received, continuing process

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

HTTP 2xx response codes indicate what?

A

Successful response code. Request was received, understood, and accepted.

17
Q

HTTP 3xx response codes indicate what?

A

Redirection response code. Further action needs to be taken in order to complete the request

18
Q

HTTP 4xx response codes indicate what?

A

Client error response code. Request contains bad syntax or cannot be fulfilled.

19
Q

HTTP 5xx response codes indicate what?

A

Sever error response code. Server failed to fulfill an apparently valid request.

20
Q

What does REST stand for?

A

Representational State Transfer

21
Q

What are the 6 constraints of RESTful APIs?

A
  1. Uniform Interface
  2. Client-server
  3. Stateless
  4. Cacheable or non-cacheable
  5. Layered system
  6. Code-on-demand (optional)
22
Q

Explain the client-server constraint of REST APIs

A

Client uses API calls to access the resources on the server. Separation between client and server means they can both change and evolve independently of each other. When the client application changes or the server changes, the interface between them must not break.

23
Q

Explain the stateless constraint of REST APIs

A

API exchanges are stateless. Each API exchange is a separate event, independent of all past exchanges between the client and server. Server doesn’t store information about previous requests from the client to determine how it should respond to new requests.

If authentication is requires, client must authenticate with the server for each request it makes.

24
Q

Is TCP a stateful or stateless protocol?

A

Stateful

Establishes connections and uses sequence and acknowledgement numbers to keep track of events between servers and clients.

25
Q

Is UDP a stateful or stateless protocol?

A

Stateless

No connection is made and exchanges are not tracked

26
Q

REST APIs generally use HTTP. HTTP uses TCP (stateful). Therefore, are REST APIs stateful?

A

No. The functions of the OSI layers are different and don’t cause REST APIs to be stateful. Since TCP is L4, and REST and HTTP are L5+, they aren’t stateful because of TCP.

27
Q

Explain the Cacheable or Non-Cacheable constraint of REST APIs

A

REST APIs must support caching of data.

Not all resources have to be cacheable, but all cacheable resources must be declared as cacheable

28
Q

Does REST describe a specific API, or a set of rules about how the API should work?

A

How the API should work. REST is not a single API

29
Q

Which of the following is NOT a constraint of RESTful architecture?

a) Client-Server
b) Cacheable
c) Stateful
d) Layered System
e) Uniform Interface

A

c) Stateful

REST APIs should be stateless

30
Q

Which category of HTTP response would you expect in response to a successful request?

a) 1xx
b) 2xx
c) 3xx
d) 4xx
e) 5xx

A

b) 2xx

31
Q

HTTP verbs PUT and PATCH are equivalent to which CRUD operation?

a) C
b) R
c) U
d) D

A

c) U

32
Q

Which of the following would you expect to find as the scheme of a URI?

a) HTTPS
b) sandboxdnac.cisco.com
c) /dna/intent/api/v1/network-device
d) accept:application/xml

A

a) HTTPS

33
Q

Which of the following statements about REST APIs are true?

a) REST APIs encode data in either XML format or JSON format
b) REST APIs are typically used to communicate with an SDN application plane
c) REST APIs are typically used to communicate with an SDN data plane
d) REST APIs encode data exclusively in XML format
e) REST APIs encode data exclusively in JSON format

A

a) REST APIs encode data in either XML format or JSON format
b) REST APIs are typically used to communicate with an SDN application plane

34
Q

Which of the following APIs are typically used to enable communication between an SDN controller and the application plane? (pick many)

a) REST
b) OnePK
c) NETCONF
d) OpFlex
e) OSGi
f) OpenFlow

A

a) REST
e) OSGi

OnePK is a Cisco proprietary API for configuring network devices, OpenFlow and OpFlex are SDN models. NETCONF isn’t an API so much as a transport coordination tool that uses SSH to make config changes.

35
Q

What HTTP method is used in HTML forms but should be avoided because it includes sensitive information in the request URI?

A

GET

36
Q

Is OpFlex an imperative or declarative SDN model?

A

Declarative

37
Q

is OpenFlow an imperative or declarative SDN model?

A

Imperative

38
Q

Name a Cisco proprietary API

A

OnePK