Code Monkey home page Code Monkey logo

open-api's Introduction

open-api

Build Status

This repository contains Netlify's API definition in the Open API format, formerly known as Swagger.

It's still a work in progress and we welcome feedback and contributions.

Usage

The swagger.yml file is the master copy of the Open API 2.0 definition. Additional context on using the API can be found on our docs site.

The spec is published and versioned for various ecosystems:

SwaggerUI (Web UI)

You can view the definition using Swagger UI by visiting open-api.netlify.com which provides limited interaction with the API from the browser.

Go Client

GoDoc Go Report Card Github release

$ go get github.com/netlify/open-api/...

See CONTRIBUTING.md for details on how this client is developed and generated.

JS Client

npm version downloads

We have a fully featured JS/Node.js client that implements some of the same 'porcelain' methods that the go client does in addition to the open-api methods.

See github.com/netlify/build/tree/main/packages/js-client for more details.

npm module

npm version

You can also consume the swagger spec as an npm module:

$ npm install @netlify/open-api
# or
$ yarn add @netlify/open-api
import spec from '@netlify/open-api' // import the spec object into your project

The module also ships a copy of the original yml spec file at @netlify/open-api/js/dist/swagger.yml. You can use these with generic swagger/open-api clients:

swagger-js

Swagger's JS client can dynamically create a client from a spec either from a URL or spec object.

See the swagger-js client:

Usage
<script src='browser/swagger-client.js' type='text/javascript'></script>
<script>
var swaggerClient = new SwaggerClient('https://open-api.netlify.com/swagger.json');
</script>

Contributing

See CONTRIBUTING.md for more info on how to make contributions to this project.

License

MIT. See LICENSE for more details.

open-api's People

Contributors

bcomnes avatar benaiah avatar benedfit avatar biilmann avatar brycekahle avatar calavera avatar davidwells avatar dependabot[bot] avatar eduardoboucas avatar ehmicky avatar erezrokah avatar erikw avatar fawazfarid avatar futuregerald avatar hereje avatar jasonbarry avatar jenae-janzen avatar jgantunes avatar jrwhitmer avatar keiko713 avatar khendrikse avatar kitop avatar ldez avatar mraerino avatar netlify-bot avatar paulo avatar rybit avatar skn0tt avatar token-generator-app[bot] avatar vbrown608 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

open-api's Issues

appropriately handle unicode filenames in site deploys

Situation: Enterprise customer Global Citizen Year is unable to successfully deploy their site from git. While there is another problem also blocking, this one is 1/2 of the problem. They have unicode filenames and their deploys error like this:

failed during stage 'deploying site': Failed to execute deploy: Upload cancelled: updates/on-walking-sharing-space-and-our-mother%c2%89s-garden/index.html

(from https://app.netlify.com/sites/wizardly-wing-6da16b/deploys/5bac50cd73f2cf0ea39d04ca)

you can see the problem more clearly in humio:

Failed to upload file updates/on-walking-sharing-space-and-our-mother%c2%89s-garden/index.html" build_id=5bac50cd73f2cf0ea39d04cb context=production deploy_id=5bac50cd73f2cf0ea39d04ca error="[PUT /deploys/{deploy_id}/files/{path}][422] uploadDeployFile default u0026{Code:422 Message:Missing entry in deploy for /updates/on-walking-sharing-space-and-our-motheru0089s-garden/index.html}

(from https://cloud.humio.com/netlify-production/search?widgetType=list-view&query=5bac50cd73f2cf0ea39d04ca%20on-walking-sharing-space&live=false&start=1537945200000&end=1538031600000&fullscreen=false)

@bcomnes tracked this down to this repo and behavior:

When you make the API call to create a deploy for files that contain unicode characters in filenames, filenames in the initial manifest need to be unescaped (== actual names), but when uploaded (PUT to the API) must be escaped since the filename is in a URL

Add Identity endpoints

The Identity service adds endpoints for user management, like

https://api.netlify.com/api/v1/sites/{SITE_ID}/identity/{IDENTITY_INSTANCE_ID}/users/invite

We also need to add identity_instance_id to the payload of the site endpoint.

Plumbing DeleteSite operation casts interface to wrong type, panics

From calling operations.DeleteSite:

panic: interface conversion: interface {} is *operations.DeleteSiteDefault, not *operations.DeleteSiteOK

goroutine 205 [running]:
github.com/netlify/open-api/go/plumbing/operations.(*Client).DeleteSite(0xc42032d7e0, 0xc42039b110, 0x1db43e0, 0xc4203d75d0, 0x30, 0x1894dc0, 0x1930501)
	/Users/mitchellh/code/go/src/github.com/netlify/open-api/go/plumbing/operations/operations_client.go:400 +0x56e

review all endpoints for correctness

I suspect that many of the endpoints are incomplete - have had attributes added or they should be PUT instead of PATCH. A review to set a good baseline would be useful

Get cloud functions usage via API

Hi! Is there a way to get the cloud functions usage (requests & hours) for a particular site via the API? If not, would this be something which could be added? Thanks ๐Ÿ˜

Heisenbug: periodic error TextMarshaler error

On creating a Netlify site with no settings site (params are empty), I'm periodically getting this:

netlify_site.test: &{0 } (*models.Error) is not supported by the TextConsumer, can be resolved by supporting TextUnmarshaler interface

Sorry, it is in Go => string format.

This is in a loop of creating/deleting a site with no params. Seems to be about 1 in 10 chance.

Add entrypoints for Teams

We have a bunch of new team entrypoints that are not here, we need to add them to the swagger.yml file.

Separate API by sections

Right now, there is only a "default" section. We should divide the API by logical sections:

  • sites
  • deploys
  • dns
  • hooks
  • forms
  • snippets
    ...

Improve error messaging around failed deployments (particularly of functions)

Currently when customers do something "interesting" with functions (there's a large class of things that count as interesting; see related issue: https://github.com/netlify/bitballoon/issues/1628), we give a very non-useful error message while failing the deploy:

10:37:50 AM: Failing build: Failed to deploy site
10:37:50 AM: failed during stage 'deploying site': Failed to execute deploy: Upload cancelled: submission-created

This comes from https://github.com/netlify/buildbot/blob/d1d46200977e9388ad296974ec8dacb61a1c47bc/bot/stage_deploy.go#L50

@calavera asserts that it should be improved here:

https://github.com/netlify/open-api/blob/master/go/porcelain/deploy.go#L389

if sharedErr.err != nil {
  return fmt.Errorf("Upload cancelled: %s -- %v", f.Name, sharedErr.err)

And maybe once that messaging is improved, buildbot can be changed to surface the reason rather than just that there was an inscrutable error.

Add user endpoint

Please forgive me if I'm incorrect, but it appears we are missing the /user endpoint for listing user information.

processing_settings missing from site and siteSetup definitions

I'm in the process of creating a .NET client for the API and am using the Open API specification as a guide along with the API docs. This is probably the first of several issues I'll open as I find discrepancies between the Open API specification, the API docs, and what I see on the wire. I'm happy to tackle some of these as PRs as well, but want to get them in as issues first.

Both the API docs and the wire data contain a payload for a processing_settings property in the site and siteSetup objects;

"processing_settings": {
    "css": {
      "bundle": true,
      "minify": true
    },
    "js": {
      "bundle": true,
      "minify": true
    },
    "images": {
      "optimize": true
    },
    "html": {
      "pretty_urls": true
    },
    "skip": true
  }

This structure appears to be totally missing from the Open API specification.

Site.BuildSettings.Repo is not populated on GET

Hello,

For CreateSite, the API allows us to populate the repo field with something like mitchellh/foo. However, upon reading that site, only the repo_url is populated and repo is empty.

For Terraform, this is making it difficult to verify the remote settings are setup correctly. If this is working as intended I can try to parse this information out but the best thing would be to avoid that if possible.

siteSetup contains more properties than is needed for createSite operation

The createSite operation in the Open API specification uses the siteSetup definition for the body but that object appears to contain many more properties than are relevant for the operation. The API docs only mention name, custom_domain, password, force_ssl, processing_settings (see #47), and repo. Wondering if a new object definition should be created and referenced for the createSite operation?

Ability to Delete a deploy

I am wondering if it would be possible to have a Delete deploy.

Currently we can delete a site
image

Is it possible to have a DELETE /deploys/{deploy_id} ? or is that not possible?

Deploy can open too many files at once

A file is opened to compute the SHA, but keeps the file handle open. If the deploy has a large number of files, this can result in a too many open files error.

plan_data missing from site defintion

The wire data contains a plan_data property for the site definition:

"plan_data": {
    "title": "Netlify Team Free",
    "asset_acceleration": true,
    "form_processing": true,
    "cdn_propagation": "partial",
    "build_gc_exchange": "buildbot-gc",
    "build_node_pool": "buildbot-ssd",
    "domain_aliases": true,
    "secure_site": false,
    "prerendering": true,
    "proxying": true,
    "ssl": "custom",
    "rate_cents": 0,
    "yearly_rate_cents": 0,
    "cdn_network": "free_cdn_network",
    "branch_deploy": true,
    "managed_dns": true,
    "geo_ip": true,
    "split_testing": true,
    "id": "nf_team_dev"
  }

This appears to be missing from the Open API specification.

Site doesn't respond to event from webhook when created using createSite

When I create a site with a linked GitLab repository using the createSite operation, the site doesn't respond to incoming events (push or merge request) from the webhook (https://api.netlify.com/hooks/gitlab).

Here's the API call I'm using to create the site (which contains a netlify.toml file):

const Netlify = require('netlify')
const client = new Netlify(process.env.NETLIFY_TOKEN)

;(async () => {
  const { id: deployKeyId } = await client.createDeployKey()
  const site = await client.createSite({
    body: {
      repo: {
        provider: 'gitlab',
        deploy_key_id: deployKeyId,
        repo_path: 'group/repo-name',
        repo_branch: 'master',
      }
    }
  })
})()

If I click "Edit settings", then "Link to a different repository", the site starts responding to events from the webhook. However, there doesn't seem to be any change in the site settings (at least as reported by the API).

Is the createSite API not capable of setting up a site with CI properly? If so, what setting am I missing?

I also noticed that even if the repository is public, and I set the public_repo property to true, Netlify still reports the repository as private (as indicated by the lock icon next to the repository URL on the Build Settings page and confirmed by the API).

SiteBuildSettings missing many key fields

Howdy! ๐Ÿ‘‹

SiteBuildSettings is missing a lot of really important fields I wanted to point out:

  • env
  • provider
  • repo_type
  • repo_url
  • repo_branch

I'm able to create a site connected to a VCS from the API but I can't reload that data and verify. This is particularly important in Terraform so it can reconcile if anything changed remotely.

EDIT: Added env as an important one since I can't modify env vars until this is available.

Activate go modules

Now that go modules are out, we should start using go modules with the go lib.

Add Split Testing Endpoint

Noticed there were issues for missing endpoints but didn't see one for /sites/{site_id}/traffic_splits, feel free to close if it's because it's still in beta!

Inconsistency between API docs and Open API for updateSite operation

The API docs say:

Takes all the same parameters as when creating a site.

That is specified in the API docs as name, custom_domain, password, force_ssl, processing_settings (see #47), and repo. However, the Open API specification indicates the body should contain the much more expansive siteSetup object.

Enable Let's Encrypt SSL

Hello,

I'm trying to understand how I can enable SSL with Let's Encrypt (which would correspond to POST /api/sites/{site_id}/ssl) with the go library. It looks like noting is defined in the library for this.
Is there something I didn't find?

Moreover, once it will be enabled, is there a way to disable it?
According to https://www.netlify.com/docs/api/#sites, there is no way to disable it...

Handle 408 timeouts better in go client / text error decoder

res, err := b.apiClient.DeployFiles(absFilePath, absFuncPath, b.Branch, b.GitRef(), b.SysLog)

When the retry uploads fail with a 408 you end up with an error like:

deploying site': Failed to execute deploy: no consumer: "text/html; charset=UTF-8"

Not very friendly. We probably need to special case handle 408s since its not returning JSON messaging.

Build Hooks unsupported

Sorry for all the issues, but I figure separate issues for each thing I find is easier to track and resolve than one big mega issue. If you'd prefer a mega issue then let me know.

Site Build Hooks are unsupported, specifically the API /sites/:id/build_hooks.

Missing DeleteSite on Porcelain Netlify client

I'm using Netlify client from porcelain package for site operations (create, deploy..).
I want to implement site delete action (using site id), but I'm getting error type *porcelain.Netlify has no field or method DeleteSite.
I tried adding DeleteSite method to site.go in porcelain package (using GetSite from Netlify client as a pattern) just to see would it work, and it did, site got deleted.

Are you planning on adding this method to Netlify client?


I did manage to make it work by calling Operations.DeleteSite on Netlify client, but I also had to import plumbing operations package in order to get NewDeleteSiteParams. Site gets deleted, but this just doesn't look like a preferred way of doing it.

import(
    netlify "github.com/netlify/open-api/go/porcelain"
    netlifyOperations "github.com/netlify/open-api/go/plumbing/operations"
)

func deleteNetlifySite(siteID string) {
    
    ...

    client := netlify.New(transport, strfmt.Default)
    resp, err := client.Operations.DeleteSite(netlifyOperations.NewDeleteSiteParams().WithSiteID(siteID), authInfo)
}

No read/delete for deploy keys?

I'm working on a Terraform provider and noticed there is no read/delete endpoints for deploy keys.

The primary sketchy thing about this for me is that Terraform can't verify that a deploy key is still valid.

From a Netlify PoV, we'll likely be running nightly acceptance tests at some point that could create dozens if not a hundred or more deploy keys. Is it okay that these grow unbounded?

Add dns_zones endpoints

There are more dns_zones endpoints in the api that are undocumented. Add them to open-api

Add a Scala / Java SDK

Netlify seems awesome! I saw this:

Currently, we're generating client code for Go, but we're planning on releasing libraries in any language that can generate code from the spec.

.. but creating an issue anyway, so that I can track and be notified when other languages are supported.

I am particularly looking for Scala / Java support.

Thanks!

Retrieve files list in a specific deploy

Hi there,

am I correct in assuming that there is currently no way of GETting the list of files for an older deploy? Something that would look like /deploys/{deploy_id}/files. I just found uploadDeployFile but it is a PUT.

Basically, I need to check the hash assigned to a particular file name in several old deploys recursively (they are too many to do it by hand).

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.