Chapter 47 - Understanding REST and JSON Flashcards

1
Q

What is a library?

A
  • Prebuilt index of data that can be used instead of writing the equivalent from scratch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the attributes that define REST APIs?

A
  • Client/server architecture - Uses API calls (E.g. HTTP requests) to access data on the REST server
  • Stateless operation - Does not use information from previous API exchanges to influence future API exchanges
  • Clear statement of cacheable and uncacheable - Marks data that should or should not be cached for better performance (if cached, the server does not have to retrieve a resource for the client after already retrieving it within a certain timeframe)
  • Uniform interface
  • Layered
  • Code-on-demand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are Simple Variables?

A
  • Variables with a single data name and a single attributed value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are Array Data Structures?

A
  • Data Structure with a single data key but multiple attributed values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Object Data Structures?

A
  • Data structures that contain multiple key:value pairs
  • Sometimes called a Dictionary
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why do a lot of REST APIs use HTTP as their networking protocol?

A
  • Very similar (e.g. both client/server, both stateless, both clearly mark cacheable and uncacheable data)
  • REST APIs can also use URIs to specify in HTTP what data it needs to perform an action on
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is CRUD?

A
  • An acronym for the four primary actions of an application:
    - Create - Allows users to create variables and data structures at a server and set their initial values
    - Read - Allows users to retrieve the current value of variables that exist at a server
    - Update - Allows the client to update variables and data structures at a server
    - Delete - Allows the client to delete variables from a server
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List HTTP verbs and their corresponding CRUD terms

A
  • POST - Create
  • GET - Read
  • PATCH/PUT - Update
  • DELETE - Delete
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the different parts of a URI?

A

HTTPS://google.com/path/to/resource?specific=query

  • Before the :// - Protocol (Scheme)
  • Immediately after the :// - The hostname of the server (authority)
  • Immediately after the / - The path to the resource on the server
  • Immediately after the ? - A query that specifies the variable that the client is querying at a given destination
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is JSON?

A
  • JavaScript Object Notation
  • Open standard file format and data interchange format that stores and transmits data in human readable text
  • Data serialisation language
  • Commonly used in REST APIs
  • Whitespace is insignificant
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a Data Serialisation Language?

A
  • Provides a standardised method of representing data between programs. Useful when programs are written in different languages as they may interpret/represent variables differently
  • An example is JSON, XML, YAML
  • Sometimes known as a Data Modelling Language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is XML?

A
  • eXtensible Markup Language
  • Data serialisation language
  • A successor to HTML that improves on the ability for variables to be changed dynamically
  • Commonly used in REST APIs and web pages
  • Whitespace does not change the meaning of data
  • key value pairs are written as <key> value </key>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is YAML?

A
  • YAML Ain’t Markup Language
  • Data serialisation language
  • Unlike XML focuses more on data model details than markup
  • Commonly used in Ansible
  • White space does change the meaning of data
  • Files start with ‘—’
  • Lists start with ‘-‘
  • Key value pairs are defined as key:value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is markup in the context of programming?

A
  • The ability for a programming language to add more information to variables to define how they are displayed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

JSON syntax rules

A
  • Key:Value Pair - Every colon identifies one key:value pair with the key before the colon and the value after.
  • Key - Text inside double quotes, before a colon that is used as a name that references a value
  • Value - Item after the colon that represents the value of the key. These can be:
    - string
    - number
    - null
    - boolean
    - Array
    - Object - An unordered list of key:value pairs
  • Multiple Pairs - Separate each pair with a comma at the end of each pair apart from the last one
  • Curly brackets - Begin and end a JSON object. A series of key:value pairs enclosed in curly brakcets. Python knows them as dictionaries.
  • Square brackets - Begin and end a JSON array. A series of values (not key:value pairs) enclosed in square brackets. Python knows them as lists.
  • Objects and arrays can be nested within each other
  • Whitespace does not change the meaning of data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are JSON data types?

A
  • null- Represents the intentional lack of a value. Just the word null in no quotes.
  • string - Text value. Surrounded by quotes.
  • boolean - True/False value. Not surrounded by quotes.
  • number - Numeric value. Not surrounded by quotes.
16
Q

What are variables?

A
  • A data container that stores a value
17
Q

How many key:value pairs are in the below?

{
“Identity”:{
“Interface”:”G0/1”,
“Enabled”:true
}
}

A
  • 3
  • However, “Identity” is a key and then everything inside the second set of curly brackets is the value.
18
Q

What are nested objects?

A
  • Objects within objects
  • An example is:
    {
    “Identity”:{
    “Interface”:”G0/1”,
    “Enabled”:true
    }
    }
19
Q

True or False. In JSON, having a comma at the end of the last key:value pair in an object is fine.

A

False. There should only be a comma between key:value pairs and not after the last key:value pair.

20
Q

What are HTTP response codes?

A
  • 3 digit numbers that define the response from a HTTP server:
    - 1xx - Informational (e.g. 102 - Processing)
    - 2xx - Successful (e.g. 200 - OK, 201 - Created)
    - 3xx - Redirection (e.g. 301 - Moved permanently)
    - 4xx - Client error (e.g. 403 - Unauthorised, 404 - Not found)
    - 5xx - Server error (e.g. 500 - Internal server error)