Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add “netlify api” command #379

Merged
merged 5 commits into from
Aug 7, 2019
Merged

add “netlify api” command #379

merged 5 commits into from
Aug 7, 2019

Conversation

DavidWells
Copy link
Contributor

@DavidWells DavidWells commented Jul 24, 2019

#261

Adds netlify api openApiMethod for advanced use cases. https://open-api.netlify.com/#/default/

Example

netlify api getSite --data '{ "site_id": "my-site"}'

List out methods:

netlify api --list
cli git:(addAPICommand) ✗ netlify api --list
.--------------------------------------------------------------------------------------------------.
|                                       Netlify API Methods                                        |
|--------------------------------------------------------------------------------------------------|
|         API Method          |                             Docs Link                              |
|-----------------------------|--------------------------------------------------------------------|
| listSites                   | https://open-api.netlify.com/#/default/listSites                   |
| createSite                  | https://open-api.netlify.com/#/default/createSite                  |
| getSite                     | https://open-api.netlify.com/#/default/getSite                     |
| updateSite                  | https://open-api.netlify.com/#/default/updateSite                  |
| deleteSite                  | https://open-api.netlify.com/#/default/deleteSite                  |
| provisionSiteTLSCertificate | https://open-api.netlify.com/#/default/provisionSiteTLSCertificate |
| showSiteTLSCertificate      | https://open-api.netlify.com/#/default/showSiteTLSCertificate      |
| listSiteForms               | https://open-api.netlify.com/#/default/listSiteForms               |
| listSiteSubmissions         | https://open-api.netlify.com/#/default/listSiteSubmissions         |
| listSiteFiles               | https://open-api.netlify.com/#/default/listSiteFiles               |
| listSiteAssets              | https://open-api.netlify.com/#/default/listSiteAssets              |
| createSiteAsset             | https://open-api.netlify.com/#/default/createSiteAsset             |
| getSiteAssetInfo            | https://open-api.netlify.com/#/default/getSiteAssetInfo            |
| updateSiteAsset             | https://open-api.netlify.com/#/default/updateSiteAsset             |
| deleteSiteAsset             | https://open-api.netlify.com/#/default/deleteSiteAsset             |
| getSiteAssetPublicSignature | https://open-api.netlify.com/#/default/getSiteAssetPublicSignature |
| getSiteFileByPathName       | https://open-api.netlify.com/#/default/getSiteFileByPathName       |
| listSiteSnippets            | https://open-api.netlify.com/#/default/listSiteSnippets            |
| createSiteSnippet           | https://open-api.netlify.com/#/default/createSiteSnippet           |
| getSiteSnippet              | https://open-api.netlify.com/#/default/getSiteSnippet              |
| updateSiteSnippet           | https://open-api.netlify.com/#/default/updateSiteSnippet           |
| deleteSiteSnippet           | https://open-api.netlify.com/#/default/deleteSiteSnippet           |
| getSiteMetadata             | https://open-api.netlify.com/#/default/getSiteMetadata             |
| updateSiteMetadata          | https://open-api.netlify.com/#/default/updateSiteMetadata          |
| listSiteBuildHooks          | https://open-api.netlify.com/#/default/listSiteBuildHooks          |
| createSiteBuildHook         | https://open-api.netlify.com/#/default/createSiteBuildHook         |
| getSiteBuildHook            | https://open-api.netlify.com/#/default/getSiteBuildHook            |
| updateSiteBuildHook         | https://open-api.netlify.com/#/default/updateSiteBuildHook         |
| deleteSiteBuildHook         | https://open-api.netlify.com/#/default/deleteSiteBuildHook         |
| listSiteDeploys             | https://open-api.netlify.com/#/default/listSiteDeploys             |
| createSiteDeploy            | https://open-api.netlify.com/#/default/createSiteDeploy            |
| getSiteDeploy               | https://open-api.netlify.com/#/default/getSiteDeploy               |
| updateSiteDeploy            | https://open-api.netlify.com/#/default/updateSiteDeploy            |
| restoreSiteDeploy           | https://open-api.netlify.com/#/default/restoreSiteDeploy           |
| listSiteBuilds              | https://open-api.netlify.com/#/default/listSiteBuilds              |
| createSiteBuild             | https://open-api.netlify.com/#/default/createSiteBuild             |
| listSiteDeployedBranches    | https://open-api.netlify.com/#/default/listSiteDeployedBranches    |
| getSiteBuild                | https://open-api.netlify.com/#/default/getSiteBuild                |
| updateSiteBuildLog          | https://open-api.netlify.com/#/default/updateSiteBuildLog          |
| notifyBuildStart            | https://open-api.netlify.com/#/default/notifyBuildStart            |
| getDNSForSite               | https://open-api.netlify.com/#/default/getDNSForSite               |
| configureDNSForSite         | https://open-api.netlify.com/#/default/configureDNSForSite         |
| getDeploy                   | https://open-api.netlify.com/#/default/getDeploy                   |
| lockDeploy                  | https://open-api.netlify.com/#/default/lockDeploy                  |
| unlockDeploy                | https://open-api.netlify.com/#/default/unlockDeploy                |
| uploadDeployFile            | https://open-api.netlify.com/#/default/uploadDeployFile            |
| uploadDeployFunction        | https://open-api.netlify.com/#/default/uploadDeployFunction        |
| listForms                   | https://open-api.netlify.com/#/default/listForms                   |
| listFormSubmissions         | https://open-api.netlify.com/#/default/listFormSubmissions         |
| listHooksBySiteId           | https://open-api.netlify.com/#/default/listHooksBySiteId           |
| createHookBySiteId          | https://open-api.netlify.com/#/default/createHookBySiteId          |
| getHook                     | https://open-api.netlify.com/#/default/getHook                     |
| updateHook                  | https://open-api.netlify.com/#/default/updateHook                  |
| deleteHookBySiteId          | https://open-api.netlify.com/#/default/deleteHookBySiteId          |
| enableHook                  | https://open-api.netlify.com/#/default/enableHook                  |
| listHookTypes               | https://open-api.netlify.com/#/default/listHookTypes               |
| createTicket                | https://open-api.netlify.com/#/default/createTicket                |
| showTicket                  | https://open-api.netlify.com/#/default/showTicket                  |
| exchangeTicket              | https://open-api.netlify.com/#/default/exchangeTicket              |
| listDeployKeys              | https://open-api.netlify.com/#/default/listDeployKeys              |
| createDeployKey             | https://open-api.netlify.com/#/default/createDeployKey             |
| getDeployKey                | https://open-api.netlify.com/#/default/getDeployKey                |
| deleteDeployKey             | https://open-api.netlify.com/#/default/deleteDeployKey             |
| createSiteInTeam            | https://open-api.netlify.com/#/default/createSiteInTeam            |
| listSitesForAccount         | https://open-api.netlify.com/#/default/listSitesForAccount         |
| listMembersForAccount       | https://open-api.netlify.com/#/default/listMembersForAccount       |
| addMemberToAccount          | https://open-api.netlify.com/#/default/addMemberToAccount          |
| listPaymentMethodsForUser   | https://open-api.netlify.com/#/default/listPaymentMethodsForUser   |
| listAccountTypesForUser     | https://open-api.netlify.com/#/default/listAccountTypesForUser     |
| listAccountsForUser         | https://open-api.netlify.com/#/default/listAccountsForUser         |
| createAccount               | https://open-api.netlify.com/#/default/createAccount               |
| getAccount                  | https://open-api.netlify.com/#/default/getAccount                  |
| updateAccount               | https://open-api.netlify.com/#/default/updateAccount               |
| cancelAccount               | https://open-api.netlify.com/#/default/cancelAccount               |
| listAccountAuditEvents      | https://open-api.netlify.com/#/default/listAccountAuditEvents      |
| listFormSubmission          | https://open-api.netlify.com/#/default/listFormSubmission          |
| deleteSubmission            | https://open-api.netlify.com/#/default/deleteSubmission            |
| createServiceInstance       | https://open-api.netlify.com/#/default/createServiceInstance       |
| showServiceInstance         | https://open-api.netlify.com/#/default/showServiceInstance         |
| updateServiceInstance       | https://open-api.netlify.com/#/default/updateServiceInstance       |
| deleteServiceInstance       | https://open-api.netlify.com/#/default/deleteServiceInstance       |
| getServices                 | https://open-api.netlify.com/#/default/getServices                 |
| showService                 | https://open-api.netlify.com/#/default/showService                 |
| showServiceManifest         | https://open-api.netlify.com/#/default/showServiceManifest         |
| getCurrentUser              | https://open-api.netlify.com/#/default/getCurrentUser              |
'--------------------------------------------------------------------------------------------------'

Depends on https://github.com/netlify/js-client/pull/54/files

@DavidWells
Copy link
Contributor Author

DavidWells commented Jul 24, 2019

Todo:

@DavidWells
Copy link
Contributor Author

Here is example of getting all live functions on a site

netlify api getSite --data '{ "site_id": "6c383b1d-367f-49ec-acab-ac370c99cd76"}' | jq '.published_deploy.available_functions'

image

@DavidWells
Copy link
Contributor Author

Todo:

  • verify --data flag covers most/all use cases
  • verify multi line data arg works
  • disable/hide any commands? 🤔

@DavidWells
Copy link
Contributor Author

Thanks for review @futuregerald

Are there any API requests that you know of that require anything other than a /path or body? Like pagination headers or anything? cc @keiko713 @kitop

The command here is pretty simple

netlify api nameOfMethod --data "JSONPAYLOAD"

Just want to double check this will work for all the methods listed above

@keiko713
Copy link
Contributor

I don't think anything is "required", you could pass but we still return things even it's not passed

@DavidWells
Copy link
Contributor Author

Unable to update merge conflict due to lack of perms.

To resolve conflict update package.json lines:

    "netlify": "^2.4.8",
    "netlify-dev-plugin": "^1.0.27",

Copy link
Contributor

@RaeesBhatti RaeesBhatti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to merge!

@DavidWells
Copy link
Contributor Author

Yeah this is ready. Merge away!

@DavidWells DavidWells merged commit 8c4e155 into master Aug 7, 2019
@DavidWells
Copy link
Contributor Author

closes #261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants