github.com/nullne/docker@v1.13.0-rc1/api/server/router/swarm/cluster.go (about)

     1  package swarm
     2  
     3  import (
     4  	"github.com/docker/docker/api/server/router"
     5  	"github.com/docker/docker/daemon"
     6  )
     7  
     8  // swarmRouter is a router to talk with the build controller
     9  type swarmRouter struct {
    10  	backend Backend
    11  	routes  []router.Route
    12  }
    13  
    14  // NewRouter initializes a new build router
    15  func NewRouter(d *daemon.Daemon, b Backend) router.Router {
    16  	r := &swarmRouter{
    17  		backend: b,
    18  	}
    19  	r.initRoutes()
    20  	if d.HasExperimental() {
    21  		r.addExperimentalRoutes()
    22  	}
    23  	return r
    24  }
    25  
    26  // Routes returns the available routers to the swarm controller
    27  func (sr *swarmRouter) Routes() []router.Route {
    28  	return sr.routes
    29  }
    30  
    31  func (sr *swarmRouter) addExperimentalRoutes() {
    32  	sr.routes = append(sr.routes,
    33  		router.Cancellable(router.NewGetRoute("/services/{id}/logs", sr.getServiceLogs)),
    34  	)
    35  }
    36  
    37  func (sr *swarmRouter) initRoutes() {
    38  	sr.routes = []router.Route{
    39  		router.NewPostRoute("/swarm/init", sr.initCluster),
    40  		router.NewPostRoute("/swarm/join", sr.joinCluster),
    41  		router.NewPostRoute("/swarm/leave", sr.leaveCluster),
    42  		router.NewGetRoute("/swarm", sr.inspectCluster),
    43  		router.NewGetRoute("/swarm/unlockkey", sr.getUnlockKey),
    44  		router.NewPostRoute("/swarm/update", sr.updateCluster),
    45  		router.NewPostRoute("/swarm/unlock", sr.unlockCluster),
    46  		router.NewGetRoute("/services", sr.getServices),
    47  		router.NewGetRoute("/services/{id}", sr.getService),
    48  		router.NewPostRoute("/services/create", sr.createService),
    49  		router.NewPostRoute("/services/{id}/update", sr.updateService),
    50  		router.NewDeleteRoute("/services/{id}", sr.removeService),
    51  		router.NewGetRoute("/nodes", sr.getNodes),
    52  		router.NewGetRoute("/nodes/{id}", sr.getNode),
    53  		router.NewDeleteRoute("/nodes/{id}", sr.removeNode),
    54  		router.NewPostRoute("/nodes/{id}/update", sr.updateNode),
    55  		router.NewGetRoute("/tasks", sr.getTasks),
    56  		router.NewGetRoute("/tasks/{id}", sr.getTask),
    57  		router.NewGetRoute("/secrets", sr.getSecrets),
    58  		router.NewPostRoute("/secrets", sr.createSecret),
    59  		router.NewDeleteRoute("/secrets/{id}", sr.removeSecret),
    60  		router.NewGetRoute("/secrets/{id}", sr.getSecret),
    61  		router.NewPostRoute("/secrets/{id}/update", sr.updateSecret),
    62  	}
    63  }