REST & JSON Flashcards
REST APIs: 6 attributes
Client/server architecture stateless operation clear statement of cacheable/uncacheable uniform interface layered code-on-demand
Client-server model steps:
1.
2.
3.
- REST client executes REST API call, generates message to REST server
- REST server on right has API code that considers request and decides how to reply
- REST server sends back reply message with appropriate data variables
Stateless operation
REST does not record and use info about API exchanges to process subsequent API exchanges
Cacheable/uncacheable
save vs/ don’t save data for later retrieval (like for websites)
CRUD (REST APIs)- based of HTTP verbs C R U D
Create
Read
Update
Delete
CRUD:REST (HTTP) Create: Read: Update: Delete:
Create: Post
Get: Read
Update: Patch
Delete: Delete
URI structure:
https: //dnac.example.com/dna/intent/api/v1/network-device
1. https://
2. dnac.example.com
3. /dna/intent/api/v1/network-device
- Protocol
- hostname/address- sits between // and first /
- path (resource)
Resource & parameter
https://dnac.example.com/dna/intent/api/v1/network-device?parm1=10.1.1.1…
Resource- /dna/intent/api/v1/network-device
Parameter- ?parm=10.1.1.1…
JSON
- name
- origin
- central purpose
- common use
Javascript object notation RFC 8259. General data modeling and serialization Rest APIS addl: {} start and stop list readable by human and machine.
XML
- name
- origin
- central purpose
- common use
eXtensible markup language. based off HTML.
World Wide Web Consortium
Data-focused text markup that allows data modeling
Rest APIs, web pages
addl:
Variables sit between tags. slightly harder to read than JSON
YAML
- name
- origin
- central purpose
- common use
YAML Aint Markup Language. YAML.org General data modeling Ansible addl: doesn't define markup details like XML. Focuses on data model details. Easiest to read. Starts with #. Denotes variables with {{ }}
JSON
Key:value pair
each colon identifies pair
JSON
Key:
inside double “” before colon, used as the name that references a value
JSON
Value
represents value of key-
text, numeric, array, object
JSON
object
dictionary. list of Key:value pairs inside {}