Skip to content

hlorofos/pmio-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PMIO

PMIO - Go client for PMIO This ProcessMaker I/O API provides access to a BPMN 2.0 compliant workflow engine API that is designed to be used as a microservice to support enterprise cloud applications. The current Alpha 1.0 version supports most of the descriptive classes of the BPMN 2.0 specification. This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.0.0
  • Package version: 1.0.0
  • Build date: 2017-09-26T12:29:56.762+03:00

For more information, please visit https://www.processmaker.io/

Installation

go get github.com/ProcessMaker/pmio-sdk-go

For glide

glide get github.com/ProcessMaker/pmio-sdk-go

For dep

dep ensure -add github.com/ProcessMaker/pmio-sdk-go

Install the required libraries:

go get -u gopkg.in/go-resty/resty.v0
go get github.com/stretchr/testify

Getting Started

You can run this code in examples directory

package main

import (
	"os"
    "log"
    "github.com/ProcessMaker/pmio-sdk-go/pmio"
)


func main() {
    //You should define the server URL (PMIO_API_HOST) and authorization API key (PMIO_ACCESS_TOKEN)
    //as environment variables or write its inplace
    /// you can find this variables in your Processmaker.io account
    var apiHost string = os.Getenv("PMIO_API_HOST")
    var accessToken string = os.Getenv("PMIO_ACCESS_TOKEN")

    if apiHost == "" || accessToken == "" {
        log.Fatal("You should define the server URL (PMIO_API_HOST) and authorization API key (PMIO_ACCESS_TOKEN)")
    }

    //make API client and configurate them
    api := pmio.NewClient()
    api.Configuration.BasePath = "https://" + apiHost + "/api/v1"
    api.Configuration.Host = apiHost
    api.Configuration.APIKey["Authorization"] = accessToken
    api.Configuration.APIKeyPrefix["Authorization"] = "Bearer"
    api.Configuration.AccessToken = accessToken

    //call API method. This method returns user information using a token
    userItem, _, err := api.MyselfUser(1,100)

    if err != nil {
        log.Println(err)
    } else {
        log.Println("userItem = ", userItem)
    }
}

Getting Oauth authorization key example

Having both client_id and client_secret you may retrieve access_token using password grant. Additionally username and password are required to perform the operation.

// +build ignore

package main

import (
	"log"
	"encoding/json"
	"os"
	"gopkg.in/go-resty/resty.v0"
)


type AuthConfig struct {
	GrantType string `json:"grant_type"`
	ClientID string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	UserName string `json:"username"`
	Password string `json:"password"`
	Host string `json:"host"`
}

type AuthSuccess struct {
	TokenType string `json:"token_type"`
	ExpiresIn int `json:"expires_in"`
	AccessToken string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

func main() {
	var cfg AuthConfig
	configFile, err := os.Open("authconfig.json")
	defer configFile.Close()
	if err != nil {
		log.Println("Please rename and set fields of authconfig.example.json. More info in readme...")
		log.Fatal(err)
	}
	
	err = json.NewDecoder(configFile).Decode(&cfg)
	if err != nil {
		log.Fatal(err)
	}
	args := make(map[string]string)
	args["grant_type"] = cfg.GrantType
	args["client_id"] = cfg.ClientID
	args["client_secret"] = cfg.ClientSecret
	args["username"] = cfg.UserName
	args["password"] = cfg.Password
	
	auth := &AuthSuccess{}

	_, err = resty.R().
	SetFormData(args).SetResult(auth).Post("https://" + cfg.Host + "/oauth/access_token")

	if err != nil {
		log.Println("err = ", err)
	} else {
		log.Println("TokenType = ", auth.TokenType)
		log.Println("ExpiresIn = ", auth.ExpiresIn)
		log.Println("AccessToken = ", auth.AccessToken)
		log.Println("RefreshToken = ", auth.RefreshToken)
	}
}

This code is located in the folder examples

To run this code you need:

  1. Rename file authconfig.example.json to authconfig.json

  2. Write down your values, which you can find in your Processmaker.io account (client_id, client_secret, username and password)

  3. Run:
    go run examples/gettingoauth.go

How run Go-SDK Tests

The test files are in the directory tests. To run tests code you need:

  1. Rename file env.example.json to env.json

  2. Write down your values domain name and authorization key

  3. Run: go test github.com/ProcessMaker/pmio-sdk-go/tests or go test -v github.com/ProcessMaker/pmio-sdk-go/tests

Documentation for API Endpoints

All URIs are relative to https://CHANGEME.api.processmaker.io/api/v1

Class Method HTTP request Description
Client AddEvent Post /processes/{process_id}/events
Client AddEventConnector Post /processes/{process_id}/events/{event_id}/connectors
Client AddFlow Post /processes/{process_id}/flows
Client AddGateway Post /processes/{process_id}/gateways
Client AddGroup Post /groups
Client AddGroupsToTask Put /processes/{process_id}/tasks/{task_id}/groups
Client AddInputOutput Post /processes/{process_id}/tasks/{task_id}/inputoutput
Client AddInstance Post /processes/{process_id}/instances
Client AddOauthClient Post /users/{user_id}/clients
Client AddProcess Post /processes
Client AddTask Post /processes/{process_id}/tasks
Client AddTaskConnector Post /processes/{process_id}/tasks/{task_id}/connectors
Client AddUser Post /users
Client AddUsersToGroup Put /groups/{id}/users
Client DeleteEvent Delete /processes/{process_id}/events/{event_id}
Client DeleteEventConnector Delete /processes/{process_id}/events/{event_id}/connectors/{connector_id}
Client DeleteFlow Delete /processes/{process_id}/flows/{flow_id}
Client DeleteGateway Delete /processes/{process_id}/gateways/{gateway_id}
Client DeleteGroup Delete /groups/{id}
Client DeleteInputOutput Delete /processes/{process_id}/tasks/{task_id}/inputoutput/{inputoutput_uid}
Client DeleteInstance Delete /processes/{process_id}/instances/{instance_id}
Client DeleteOauthClient Delete /users/{user_id}/clients/{client_id}
Client DeleteProcess Delete /processes/{id}
Client DeleteTask Delete /processes/{process_id}/tasks/{task_id}
Client DeleteTaskConnector Delete /processes/{process_id}/tasks/{task_id}/connectors/{connector_id}
Client DeleteUser Delete /users/{id}
Client EventTrigger Post /processes/{process_id}/events/{event_id}/trigger
Client EventWebhook Post /processes/{process_id}/events/{event_id}/webhook
Client FindByFieldInsideDataModel Get /processes/{process_id}/datamodels/search/{search_param}
Client FindDataModel Get /processes/{process_id}/instances/{instance_id}/datamodel
Client FindEventById Get /processes/{process_id}/events/{event_id}
Client FindEventConnectorById Get /processes/{process_id}/events/{event_id}/connectors/{connector_id}
Client FindEventConnectors Get /processes/{process_id}/events/{event_id}/connectors
Client FindEvents Get /processes/{process_id}/events
Client FindFlowById Get /processes/{process_id}/flows/{flow_id}
Client FindFlows Get /processes/{process_id}/flows
Client FindGatewayById Get /processes/{process_id}/gateways/{gateway_id}
Client FindGateways Get /processes/{process_id}/gateways
Client FindGroupById Get /groups/{id}
Client FindGroups Get /groups
Client FindInputOutputById Get /processes/{process_id}/tasks/{task_id}/inputoutput/{inputoutput_uid}
Client FindInputOutputs Get /processes/{process_id}/tasks/{task_id}/inputoutput
Client FindInstanceById Get /processes/{process_id}/instances/{instance_id}
Client FindInstances Get /processes/{process_id}/instances
Client FindOauthClientById Get /users/{user_id}/clients/{client_id}
Client FindOauthClients Get /users/{user_id}/clients
Client FindProcessById Get /processes/{id}
Client FindProcesses Get /processes
Client FindTaskById Get /processes/{process_id}/tasks/{task_id}
Client FindTaskConnectorById Get /processes/{process_id}/tasks/{task_id}/connectors/{connector_id}
Client FindTaskConnectors Get /processes/{process_id}/tasks/{task_id}/connectors
Client FindTaskInstanceById Get /task_instances/{task_instance_id}
Client FindTaskInstances Get /task_instances
Client FindTaskInstancesByInstanceAndTaskId Get /instances/{instance_id}/tasks/{task_id}/task_instances
Client FindTaskInstancesByInstanceAndTaskIdDelegated Get /instances/{instance_id}/tasks/{task_id}/task_instances/delegated
Client FindTaskInstancesByInstanceAndTaskIdStarted Get /instances/{instance_id}/tasks/{task_id}/task_instances/started
Client FindTasks Get /processes/{process_id}/tasks
Client FindTokens Get /processes/{process_id}/instances/{instance_id}/tokens
Client FindUserById Get /users/{id}
Client FindUsers Get /users
Client ImportBpmnFile Post /processes/import
Client MyselfUser Get /users/myself
Client RemoveGroupsFromTask Delete /processes/{process_id}/tasks/{task_id}/groups
Client RemoveUsersFromGroup Delete /groups/{id}/users
Client SyncGroupsToTask Post /processes/{process_id}/tasks/{task_id}/groups
Client SyncUsersToGroup Post /groups/{id}/users
Client UpdateEvent Put /processes/{process_id}/events/{event_id}
Client UpdateEventConnector Put /processes/{process_id}/events/{event_id}/connectors/{connector_id}
Client UpdateFlow Put /processes/{process_id}/flows/{flow_id}
Client UpdateGateway Put /processes/{process_id}/gateways/{gateway_id}
Client UpdateGroup Put /groups/{id}
Client UpdateInputOutput Put /processes/{process_id}/tasks/{task_id}/inputoutput/{inputoutput_uid}
Client UpdateInstance Put /processes/{process_id}/instances/{instance_id}
Client UpdateOauthClient Put /users/{user_id}/clients/{client_id}
Client UpdateProcess Put /processes/{id}
Client UpdateTask Put /processes/{process_id}/tasks/{task_id}
Client UpdateTaskConnector Put /processes/{process_id}/tasks/{task_id}/connectors/{connector_id}
Client UpdateTaskInstance Patch /task_instances/{task_instance_id}
Client UpdateUser Put /users/{id}
EventApi AddEvent Post /processes/{process_id}/events
EventApi AddEventConnector Post /processes/{process_id}/events/{event_id}/connectors
EventApi DeleteEvent Delete /processes/{process_id}/events/{event_id}
EventApi DeleteEventConnector Delete /processes/{process_id}/events/{event_id}/connectors/{connector_id}
EventApi EventTrigger Post /processes/{process_id}/events/{event_id}/trigger
EventApi EventWebhook Post /processes/{process_id}/events/{event_id}/webhook
EventApi FindEventById Get /processes/{process_id}/events/{event_id}
EventApi FindEventConnectorById Get /processes/{process_id}/events/{event_id}/connectors/{connector_id}
EventApi FindEventConnectors Get /processes/{process_id}/events/{event_id}/connectors
EventApi FindEvents Get /processes/{process_id}/events
EventApi UpdateEvent Put /processes/{process_id}/events/{event_id}
EventApi UpdateEventConnector Put /processes/{process_id}/events/{event_id}/connectors/{connector_id}
FlowApi AddFlow Post /processes/{process_id}/flows
FlowApi DeleteFlow Delete /processes/{process_id}/flows/{flow_id}
FlowApi FindFlowById Get /processes/{process_id}/flows/{flow_id}
FlowApi FindFlows Get /processes/{process_id}/flows
FlowApi UpdateFlow Put /processes/{process_id}/flows/{flow_id}
GatewayApi AddGateway Post /processes/{process_id}/gateways
GatewayApi DeleteGateway Delete /processes/{process_id}/gateways/{gateway_id}
GatewayApi FindGatewayById Get /processes/{process_id}/gateways/{gateway_id}
GatewayApi FindGateways Get /processes/{process_id}/gateways
GatewayApi UpdateGateway Put /processes/{process_id}/gateways/{gateway_id}
GroupsApi AddGroup Post /groups
GroupsApi AddUsersToGroup Put /groups/{id}/users
GroupsApi DeleteGroup Delete /groups/{id}
GroupsApi FindGroupById Get /groups/{id}
GroupsApi FindGroups Get /groups
GroupsApi RemoveUsersFromGroup Delete /groups/{id}/users
GroupsApi SyncUsersToGroup Post /groups/{id}/users
GroupsApi UpdateGroup Put /groups/{id}
InputoutputApi AddInputOutput Post /processes/{process_id}/tasks/{task_id}/inputoutput
InputoutputApi DeleteInputOutput Delete /processes/{process_id}/tasks/{task_id}/inputoutput/{inputoutput_uid}
InputoutputApi FindInputOutputById Get /processes/{process_id}/tasks/{task_id}/inputoutput/{inputoutput_uid}
InputoutputApi FindInputOutputs Get /processes/{process_id}/tasks/{task_id}/inputoutput
InputoutputApi UpdateInputOutput Put /processes/{process_id}/tasks/{task_id}/inputoutput/{inputoutput_uid}
OauthApi AddOauthClient Post /users/{user_id}/clients
OauthApi FindOauthClientById Get /users/{user_id}/clients/{client_id}
OauthApi FindOauthClients Get /users/{user_id}/clients
ProcessApi AddProcess Post /processes
ProcessApi DeleteProcess Delete /processes/{id}
ProcessApi FindProcessById Get /processes/{id}
ProcessApi FindProcesses Get /processes
ProcessApi ImportBpmnFile Post /processes/import
ProcessApi UpdateProcess Put /processes/{id}
ProcessInstanceApi AddInstance Post /processes/{process_id}/instances
ProcessInstanceApi DeleteInstance Delete /processes/{process_id}/instances/{instance_id}
ProcessInstanceApi FindByFieldInsideDataModel Get /processes/{process_id}/datamodels/search/{search_param}
ProcessInstanceApi FindDataModel Get /processes/{process_id}/instances/{instance_id}/datamodel
ProcessInstanceApi FindInstanceById Get /processes/{process_id}/instances/{instance_id}
ProcessInstanceApi FindInstances Get /processes/{process_id}/instances
ProcessInstanceApi FindTaskInstancesByInstanceAndTaskId Get /instances/{instance_id}/tasks/{task_id}/task_instances
ProcessInstanceApi FindTaskInstancesByInstanceAndTaskIdDelegated Get /instances/{instance_id}/tasks/{task_id}/task_instances/delegated
ProcessInstanceApi FindTaskInstancesByInstanceAndTaskIdStarted Get /instances/{instance_id}/tasks/{task_id}/task_instances/started
ProcessInstanceApi FindTokens Get /processes/{process_id}/instances/{instance_id}/tokens
ProcessInstanceApi UpdateInstance Put /processes/{process_id}/instances/{instance_id}
TaskApi AddGroupsToTask Put /processes/{process_id}/tasks/{task_id}/groups
TaskApi AddTask Post /processes/{process_id}/tasks
TaskApi AddTaskConnector Post /processes/{process_id}/tasks/{task_id}/connectors
TaskApi DeleteTask Delete /processes/{process_id}/tasks/{task_id}
TaskApi DeleteTaskConnector Delete /processes/{process_id}/tasks/{task_id}/connectors/{connector_id}
TaskApi FindTaskById Get /processes/{process_id}/tasks/{task_id}
TaskApi FindTaskConnectorById Get /processes/{process_id}/tasks/{task_id}/connectors/{connector_id}
TaskApi FindTaskConnectors Get /processes/{process_id}/tasks/{task_id}/connectors
TaskApi FindTaskInstanceById Get /task_instances/{task_instance_id}
TaskApi FindTaskInstances Get /task_instances
TaskApi FindTasks Get /processes/{process_id}/tasks
TaskApi RemoveGroupsFromTask Delete /processes/{process_id}/tasks/{task_id}/groups
TaskApi SyncGroupsToTask Post /processes/{process_id}/tasks/{task_id}/groups
TaskApi UpdateTask Put /processes/{process_id}/tasks/{task_id}
TaskApi UpdateTaskConnector Put /processes/{process_id}/tasks/{task_id}/connectors/{connector_id}
TaskApi UpdateTaskInstance Patch /task_instances/{task_instance_id}
UsersApi AddUser Post /users
UsersApi DeleteUser Delete /users/{id}
UsersApi FindUserById Get /users/{id}
UsersApi FindUsers Get /users
UsersApi MyselfUser Get /users/myself
UsersApi UpdateUser Put /users/{id}

Documentation For Models

Documentation For Authorization

PasswordGrant

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published