github.com/yasker/longhorn-engine@v0.0.0-20160621014712-6ed6cfca0729/sync/agent/model.go (about)

     1  package agent
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/rancher/go-rancher/client"
     7  )
     8  
     9  type Process struct {
    10  	client.Resource
    11  	ProcessType string    `json:"processType"`
    12  	SrcFile     string    `json:"srcFile"`
    13  	DestFile    string    `json:"destfile"`
    14  	Host        string    `json:"host"`
    15  	Port        int       `json:"port"`
    16  	ExitCode    int       `json:"exitCode"`
    17  	Output      string    `json:"output"`
    18  	Created     time.Time `json:"created"`
    19  }
    20  
    21  type ProcessCollection struct {
    22  	client.Collection
    23  	Data []Process `json:"data"`
    24  }
    25  
    26  func NewSchema() *client.Schemas {
    27  	schemas := &client.Schemas{}
    28  
    29  	schemas.AddType("error", client.ServerApiError{})
    30  	schemas.AddType("apiVersion", client.Resource{})
    31  	schemas.AddType("schema", client.Schema{})
    32  	process := schemas.AddType("process", Process{})
    33  	process.CollectionMethods = []string{"GET", "POST"}
    34  
    35  	for _, name := range []string{"file", "host", "port"} {
    36  		f := process.ResourceFields[name]
    37  		f.Create = true
    38  		process.ResourceFields[name] = f
    39  	}
    40  
    41  	return schemas
    42  }