REST APIs Flashcards
What is an API?
A software interface that allows two applications to communicate with each other
What does CRUD stand for in the context of REST APIs?
Create, Read, Update, and Delete
What is a CRUD create operation?
Used to create a new variable and set its initial value
What is a CRUD read operation?
Used to retrieve the value of a variable
What is a CRUD update operation?
Used to change the value of a variable
What is a CRUD delete operation?
Used to delete a variable
HTTP uses _____ that map to CRUD operations
verbs
HTTP _____ maps to CRUD create
POST
HTTP _____ maps to CRUD read
GET
HTTP _____ maps to CRUD update
PUT, PATCH
HTTP _____ maps to CRUD delete
DELETE
What is an HTTP URI?
Uniform Resource Identifier,
Indicates a particular resource available on an HTTP server
An HTTP request will always include a ______ and a _____
HTTP Verb and a URI
Do REST APIs always have to use HTTP?
No, although HTTP is the most common
HTTP 1xx response codes indicate what?
Informational response code. request was received, continuing process
HTTP 2xx response codes indicate what?
Successful response code. Request was received, understood, and accepted.
HTTP 3xx response codes indicate what?
Redirection response code. Further action needs to be taken in order to complete the request
HTTP 4xx response codes indicate what?
Client error response code. Request contains bad syntax or cannot be fulfilled.
HTTP 5xx response codes indicate what?
Sever error response code. Server failed to fulfill an apparently valid request.
What does REST stand for?
Representational State Transfer
What are the 6 constraints of RESTful APIs?
- Uniform Interface
- Client-server
- Stateless
- Cacheable or non-cacheable
- Layered system
- Code-on-demand (optional)
Explain the client-server constraint of REST APIs
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.
Explain the stateless constraint of REST APIs
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.
Is TCP a stateful or stateless protocol?
Stateful
Establishes connections and uses sequence and acknowledgement numbers to keep track of events between servers and clients.
Is UDP a stateful or stateless protocol?
Stateless
No connection is made and exchanges are not tracked
REST APIs generally use HTTP. HTTP uses TCP (stateful). Therefore, are REST APIs stateful?
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.
Explain the Cacheable or Non-Cacheable constraint of REST APIs
REST APIs must support caching of data.
Not all resources have to be cacheable, but all cacheable resources must be declared as cacheable
Does REST describe a specific API, or a set of rules about how the API should work?
How the API should work. REST is not a single API
Which of the following is NOT a constraint of RESTful architecture?
a) Client-Server
b) Cacheable
c) Stateful
d) Layered System
e) Uniform Interface
c) Stateful
REST APIs should be stateless
Which category of HTTP response would you expect in response to a successful request?
a) 1xx
b) 2xx
c) 3xx
d) 4xx
e) 5xx
b) 2xx
HTTP verbs PUT and PATCH are equivalent to which CRUD operation?
a) C
b) R
c) U
d) D
c) U
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) HTTPS
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) REST APIs encode data in either XML format or JSON format
b) REST APIs are typically used to communicate with an SDN application plane
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) 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.
What HTTP method is used in HTML forms but should be avoided because it includes sensitive information in the request URI?
GET
Is OpFlex an imperative or declarative SDN model?
Declarative
is OpenFlow an imperative or declarative SDN model?
Imperative
Name a Cisco proprietary API
OnePK