You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 10, 2022. It is now read-only.
All notable changes to this project will be documented in this file.
3
+
This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+
## 2.0.1 - 2018-09-25
6
+
* A whole new Netlify Node.js API client! 🎉
7
+
* Client code was extracted from our forthcoming [2.0.0 CLI](https://www.netlify.com/blog/2018/09/10/netlify-cli-2.0-now-in-beta-/) release.
8
+
* A completely new API. Treat the 2.x.x and forward as a completely separate codebase and API.
9
+
* API calls are now derived from the [open-api](https://github.com/netlify/open-api) specification. See the [swagger-ui](https://open-api.netlify.com/#/default) and know that there is a matching API method for every operationID (the name on the right). See the README for full API docs.
10
+
* Includes a method for creating content based deploys.
This repo uses [ava](https://github.com/avajs/ava) for testing. Any files in the `src` directory that have a `.test.js` file extension are automatically detected and run as tests.
21
+
22
+
We also test for a few other things:
23
+
24
+
- Dependencies (used an unused)
25
+
- Linting
26
+
- Test coverage
27
+
- Must work with Windows + Unix environments.
21
28
22
-
## Pull Requests
29
+
## Architecture
23
30
24
-
We actively welcome your pull requests.
31
+
We target Node.js LTS and stable environments, and aim for basic modern browser support when possible. In order to facilitate simple contributions, we avoided any kind of build steps.
25
32
26
-
1. Fork the repo and create your branch from `master`.
27
-
2. If you've added code that should be tested, add tests.
28
-
3. If you've changed APIs, update the documentation.
29
-
4. Ensure the test suite passes.
30
-
5. Make sure your code lints.
33
+
If you need to add new API routes, please add them to the [open-api](https://github.com/netlify/open-api) repo. This client will automatically inherent the new routes from that module.
34
+
35
+
Projects that depend heavily on this client that should be taken into consideration when making changes:
36
+
37
+
-[netlify/cli](https://github.com/netlify/cli)
38
+
39
+
## Releasing
40
+
41
+
```console
42
+
# Make changes
43
+
# Update README docs if they have changed.
44
+
# Update the changelog
45
+
$ npm version [major|minor|patch]
46
+
$ git push && git push --tags
47
+
# Create a github release with the changelog contents
Copy file name to clipboardExpand all lines: README.md
+23-18Lines changed: 23 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,29 +28,32 @@ Create a new instance of the Netlify API client with the provided `accessToken`.
28
28
scheme:'https',
29
29
host:'api.netlify.com',
30
30
pathPrefix:'/api/v1',
31
-
globalParams: {} // parameters you want available for every request
31
+
globalParams: {} // parameters you want available for every request.
32
+
// Global params are only sent of the open-api spec specifies the provided params.
32
33
}
33
34
```
34
35
35
36
### `client.accessToken`
36
37
37
-
A setter/getter that returns the `accessToken` that the client is configured to use. You can set this after the class is instantiated, and all subsequent calls will use the newly set `accessToken`.
38
+
A setter/getter that returns the `accessToken` that the client is configured to use. You can set this after the class is instantiated, and all subsequent calls will use the newly set `accessToken`.
38
39
39
40
### `client.basePath`
40
41
41
42
A getter that returns the formatted base URL of the endpoint the client is configured to use.
42
43
43
44
### Open API Client methods
44
45
45
-
The client is dynamically generated from the [open-api](https://github.com/netlify/open-api) definition file. Each method is is named after the `operationId` name of each endpoint action.**To see list of available operations see the [open-api website](https://open-api.netlify.com/)**.
46
+
The client is dynamically generated from the [open-api](https://github.com/netlify/open-api) definition file. Each method is is named after the `operationId` name of each endpoint action. **To see list of available operations see the [open-api website](https://open-api.netlify.com/)**.
46
47
47
48
Every open-api method has the following signature:
Perform a call to the given endpoint corresponding with the `operationId`. Returns promise that will resolve with the body of the response, or reject with an error with details about the request attached. Rejects if the `status` > 400. Successful response objects have `status` and `statusText` properties on their prototype.
52
+
Perform a call to the given endpoint corresponding with the `operationId`. Returns promise that will resolve with the body of the response, or reject with an error with details about the request attached. Rejects if the `status` > 400. Successful response objects have `status` and `statusText` properties on their prototype.
52
53
53
-
`params` is an object that includes any of the required or optional endpoint parameters. `params.body` should be an object which gets serialized to JSON automatically. If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream.
54
+
-`params` is an object that includes any of the required or optional endpoint parameters.
55
+
-`params.body` should be an object which gets serialized to JSON automatically.
56
+
- If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream.
54
57
55
58
```js
56
59
// example params
@@ -63,7 +66,7 @@ Perform a call to the given endpoint corresponding with the `operationId`. Retu
63
66
}
64
67
```
65
68
66
-
Optional `opts` can include any property you want passed to `node-fetch`. The `headers` property is merged with some `defaultHeaders`.
69
+
Optional `opts` can include any property you want passed to `node-fetch`. The `headers` property is merged with some `defaultHeaders`.
67
70
68
71
```js
69
72
// example opts
@@ -82,23 +85,25 @@ All methods are conveniently consumed with async/await:
82
85
asyncfunctiongetSomeData () {
83
86
// Calls may fail!
84
87
try {
85
-
constresposnse=awaitclient.getSites()
86
-
return response
88
+
returnawaitclient.getSiteDeploy({
89
+
siteId:'1234abcd',
90
+
deploy_id:'4567'
91
+
})
87
92
} catch (e) {
88
93
// handle error
89
94
}
90
95
}
91
96
```
92
97
93
-
If the request response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text` of the response is returned.
98
+
If the request response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text` of the response is returned.
94
99
95
-
### Convenience Methods
100
+
### API Flow Methods
96
101
97
102
Some methods have been added in addition to the open API methods that make certain actions simpler to perform.
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`. Call this with the response from a `client.createTicket({ client_id })` call. Automatically sets the `accessToken` to `this.accessToken` and returns `accessToken` for the consumer to save for later.
106
+
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`. Call this with the response from a `client.createTicket({ client_id })` call. Automatically sets the `accessToken` to `this.accessToken` and returns `accessToken` for the consumer to save for later.
0 commit comments