github.com/cookieai-jar/moby@v17.12.1-ce-rc2+incompatible/api/server/router/swarm/cluster.go (about)

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