1.20.0 • Published 5 years ago

portainer_api v1.20.0

Weekly downloads
-
License
Unlicense
Repository
-
Last release
5 years ago

portainer_api

PortainerApi - JavaScript client for portainer_api Portainer API is an HTTP API served by Portainer. It is used by the Portainer UI and everything you can do with the UI can be done using the HTTP API. Examples are available at https://gist.github.com/deviantony/77026d402366b4b43fa5918d41bc42f8 You can find out more about Portainer at http://portainer.io and get some support on Slack. # Authentication Most of the API endpoints require to be authenticated as well as some level of authorization to be used. Portainer API uses JSON Web Token to manage authentication and thus requires you to provide a token in the Authorization header of each request with the Bearer authentication mechanism. Example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInJvbGUiOjEsImV4cCI6MTQ5OTM3NjE1NH0.NJ6vE8FY1WG6jsRQzfMqeatJ4vh2TWAeeYfDhP71YEE # Security Each API endpoint has an associated access policy, it is documented in the description of each endpoint. Different access policies are available: Public access Authenticated access Restricted access Administrator access ### Public access No authentication is required to access the endpoints with this access policy. ### Authenticated access Authentication is required to access the endpoints with this access policy. ### Restricted access Authentication is required to access the endpoints with this access policy. Extra-checks might be added to ensure access to the resource is granted. Returned data might also be filtered. ### Administrator access Authentication as well as an administrator role are required to access the endpoints with this access policy. # Execute Docker requests Portainer DO NOT expose specific endpoints to manage your Docker resources (create a container, remove a volume, etc...). Instead, it acts as a reverse-proxy to the Docker HTTP API. This means that you can execute Docker requests via the Portainer HTTP API. To do so, you can use the /endpoints/{id}/docker Portainer API endpoint (which is not documented below due to Swagger limitations). This endpoint has a restricted access policy so you still need to be authenticated to be able to query this endpoint. Any query on this endpoint will be proxied to the Docker API of the associated endpoint (requests and responses objects are the same as documented in the Docker API). NOTE: You can find more information on how to query the Docker API in the Docker official documentation as well as in this Portainer example. This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.20.0
  • Package version: 1.20.0
  • Build package: io.swagger.codegen.languages.JavascriptClientCodegen

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install portainer_api --save
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your portainer_api from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('portainer_api') in javascript files from the directory you ran the last command above from.

git

If the library is hosted at a git repository, e.g. https://github.com/YOUR_USERNAME/portainer_api then install it via:

    npm install YOUR_USERNAME/portainer_api --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var PortainerApi = require('portainer_api');

var api = new PortainerApi.AuthApi()

var body = new PortainerApi.AuthenticateUserRequest(); // {AuthenticateUserRequest} Credentials used for authentication


var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.authenticateUser(body, callback);

Documentation for API Endpoints

All URIs are relative to http://portainer.domain/api

ClassMethodHTTP requestDescription
PortainerApi.AuthApiauthenticateUserPOST /authAuthenticate a user
PortainerApi.DockerhubApidockerHubInspectGET /dockerhubRetrieve DockerHub information
PortainerApi.DockerhubApidockerHubUpdatePUT /dockerhubUpdate DockerHub information
PortainerApi.EndpointGroupsApiendpointGroupAccessUpdatePUT /endpoint_groups/{id}/accessManage accesses to an endpoint group
PortainerApi.EndpointGroupsApiendpointGroupCreatePOST /endpoint_groupsCreate a new endpoint
PortainerApi.EndpointGroupsApiendpointGroupDeleteDELETE /endpoint_groups/{id}Remove an endpoint group
PortainerApi.EndpointGroupsApiendpointGroupInspectGET /endpoint_groups/{id}Inspect an endpoint group
PortainerApi.EndpointGroupsApiendpointGroupListGET /endpoint_groupsList endpoint groups
PortainerApi.EndpointGroupsApiendpointGroupUpdatePUT /endpoint_groups/{id}Update an endpoint group
PortainerApi.EndpointsApiendpointAccessUpdatePUT /endpoints/{id}/accessManage accesses to an endpoint
PortainerApi.EndpointsApiendpointCreatePOST /endpointsCreate a new endpoint
PortainerApi.EndpointsApiendpointDeleteDELETE /endpoints/{id}Remove an endpoint
PortainerApi.EndpointsApiendpointInspectGET /endpoints/{id}Inspect an endpoint
PortainerApi.EndpointsApiendpointJobPOST /endpoints/{id}/jobExecute a job on the endpoint host
PortainerApi.EndpointsApiendpointListGET /endpointsList endpoints
PortainerApi.EndpointsApiendpointUpdatePUT /endpoints/{id}Update an endpoint
PortainerApi.RegistriesApiregistryAccessUpdatePUT /registries/{id}/accessManage accesses to a registry
PortainerApi.RegistriesApiregistryCreatePOST /registriesCreate a new registry
PortainerApi.RegistriesApiregistryDeleteDELETE /registries/{id}Remove a registry
PortainerApi.RegistriesApiregistryInspectGET /registries/{id}Inspect a registry
PortainerApi.RegistriesApiregistryListGET /registriesList registries
PortainerApi.RegistriesApiregistryUpdatePUT /registries/{id}Update a registry
PortainerApi.ResourceControlsApiresourceControlCreatePOST /resource_controlsCreate a new resource control
PortainerApi.ResourceControlsApiresourceControlDeleteDELETE /resource_controls/{id}Remove a resource control
PortainerApi.ResourceControlsApiresourceControlUpdatePUT /resource_controls/{id}Update a resource control
PortainerApi.SettingsApipublicSettingsInspectGET /settings/publicRetrieve Portainer public settings
PortainerApi.SettingsApisettingsInspectGET /settingsRetrieve Portainer settings
PortainerApi.SettingsApisettingsLDAPCheckPUT /settings/authentication/checkLDAPTest LDAP connectivity
PortainerApi.SettingsApisettingsUpdatePUT /settingsUpdate Portainer settings
PortainerApi.StacksApistackCreatePOST /stacksDeploy a new stack
PortainerApi.StacksApistackDeleteDELETE /stacks/{id}Remove a stack
PortainerApi.StacksApistackFileInspectGET /stacks/{id}/fileRetrieve the content of the Stack file for the specified stack
PortainerApi.StacksApistackInspectGET /stacks/{id}Inspect a stack
PortainerApi.StacksApistackListGET /stacksList stacks
PortainerApi.StacksApistackMigratePOST /stacks/{id}/migrateMigrate a stack to another endpoint
PortainerApi.StacksApistackUpdatePUT /stacks/{id}Update a stack
PortainerApi.StatusApistatusInspectGET /statusCheck Portainer status
PortainerApi.TagsApitagCreatePOST /tagsCreate a new tag
PortainerApi.TagsApitagDeleteDELETE /tags/{id}Remove a tag
PortainerApi.TagsApitagListGET /tagsList tags
PortainerApi.TeamMembershipsApiteamMembershipCreatePOST /team_membershipsCreate a new team membership
PortainerApi.TeamMembershipsApiteamMembershipDeleteDELETE /team_memberships/{id}Remove a team membership
PortainerApi.TeamMembershipsApiteamMembershipListGET /team_membershipsList team memberships
PortainerApi.TeamMembershipsApiteamMembershipUpdatePUT /team_memberships/{id}Update a team membership
PortainerApi.TeamsApiteamCreatePOST /teamsCreate a new team
PortainerApi.TeamsApiteamDeleteDELETE /teams/{id}Remove a team
PortainerApi.TeamsApiteamInspectGET /teams/{id}Inspect a team
PortainerApi.TeamsApiteamListGET /teamsList teams
PortainerApi.TeamsApiteamMembershipsInspectGET /teams/{id}/membershipsInspect a team memberships
PortainerApi.TeamsApiteamUpdatePUT /teams/{id}Update a team
PortainerApi.TemplatesApitemplateCreatePOST /templatesCreate a new template
PortainerApi.TemplatesApitemplateDeleteDELETE /templates/{id}Remove a template
PortainerApi.TemplatesApitemplateInspectGET /templates/{id}Inspect a template
PortainerApi.TemplatesApitemplateListGET /templatesList available templates
PortainerApi.TemplatesApitemplateUpdatePUT /templates/{id}Update a template
PortainerApi.UploadApiuploadTLSPOST /upload/tls/{certificate}Upload TLS files
PortainerApi.UsersApiuserAdminCheckGET /users/admin/checkCheck administrator account existence
PortainerApi.UsersApiuserAdminInitPOST /users/admin/initInitialize administrator account
PortainerApi.UsersApiuserCreatePOST /usersCreate a new user
PortainerApi.UsersApiuserDeleteDELETE /users/{id}Remove a user
PortainerApi.UsersApiuserInspectGET /users/{id}Inspect a user
PortainerApi.UsersApiuserListGET /usersList users
PortainerApi.UsersApiuserMembershipsInspectGET /users/{id}/membershipsInspect a user memberships
PortainerApi.UsersApiuserPasswordCheckPOST /users/{id}/passwdCheck password validity for a user
PortainerApi.UsersApiuserUpdatePUT /users/{id}Update a user

Documentation for Models

Documentation for Authorization

jwt

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header
1.20.0

5 years ago