Example #1
0
func (r *router) initRoutes() {

	r.routes = []types.Route{

		// GET
		httputils.NewGetRoute(
			"services",
			"/services",
			r.servicesList,
			handlers.NewSchemaValidator(nil, schema.ServiceInfoMapSchema, nil)),

		httputils.NewGetRoute(
			"serviceInspect",
			"/services/{service}",
			r.serviceInspect,
			handlers.NewServiceValidator(),
			handlers.NewSchemaValidator(nil, schema.ServiceInfoSchema, nil)),
	}
}
Example #2
0
func (r *router) initRoutes() {
	r.routes = []types.Route{

		// GET

		// get all snapshots from all services
		httputils.NewGetRoute(
			"snapshots",
			"/snapshots",
			r.snapshots,
			handlers.NewSchemaValidator(
				nil, schema.ServiceSnapshotMapSchema, nil),
		),

		// get all snapshots from a specific service
		httputils.NewGetRoute(
			"snapshotsForService",
			"/snapshots/{service}",
			r.snapshotsForService,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				nil, schema.SnapshotMapSchema, nil),
		),

		// get a specific snapshot from a specific service
		httputils.NewGetRoute(
			"snapshotInspect",
			"/snapshots/{service}/{snapshotID}",
			r.snapshotInspect,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(nil, schema.SnapshotSchema, nil),
		),

		// POST

		// create volume from snapshot
		httputils.NewPostRoute(
			"snapshotCreate",
			"/snapshots/{service}/{snapshotID}",
			r.volumeCreate,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				schema.VolumeCreateRequestSchema,
				schema.VolumeSchema,
				func() interface{} { return &types.VolumeCreateRequest{} }),
			handlers.NewPostArgsHandler(),
		).Queries("create"),

		// copy snapshot
		httputils.NewPostRoute(
			"snapshotCopy",
			"/snapshots/{service}/{snapshotID}",
			r.snapshotCopy,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				schema.SnapshotCopyRequestSchema,
				schema.SnapshotSchema,
				func() interface{} {
					return &types.SnapshotCopyRequest{}
				}),
			handlers.NewPostArgsHandler(),
		).Queries("copy"),

		// DELETE
		httputils.NewDeleteRoute(
			"snapshotRemove",
			"/snapshots/{service}/{snapshotID}",
			r.snapshotRemove,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
		),
	}
}
Example #3
0
func (r *router) initRoutes() {
	r.routes = []types.Route{
		// GET

		// get all volumes from all services
		httputils.NewGetRoute(
			"volumes",
			"/volumes",
			r.volumes,
			handlers.NewSchemaValidator(nil, schema.ServiceVolumeMapSchema, nil),
		),

		// get all volumes from a specific service
		httputils.NewGetRoute(
			"volumesForService",
			"/volumes/{service}",
			r.volumesForService,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(nil, schema.VolumeMapSchema, nil),
		),

		// get a specific volume from a specific service
		httputils.NewGetRoute(
			"volumeInspect",
			"/volumes/{service}/{volumeID}",
			r.volumeInspect,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(nil, schema.VolumeSchema, nil),
		),

		// POST

		// detach all volumes for a service
		httputils.NewPostRoute(
			"volumesDetachForService",
			"/volumes/{service}",
			r.volumeDetachAllForService,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				schema.VolumeDetachRequestSchema,
				schema.VolumeMapSchema,
				func() interface{} { return &types.VolumeDetachRequest{} }),
			handlers.NewPostArgsHandler(),
		).Queries("detach"),

		// create a new volume
		httputils.NewPostRoute(
			"volumeCreate",
			"/volumes/{service}",
			r.volumeCreate,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				schema.VolumeCreateRequestSchema,
				schema.VolumeSchema,
				func() interface{} { return &types.VolumeCreateRequest{} }),
			handlers.NewPostArgsHandler(),
		),

		// create a new volume using an existing volume as the baseline
		httputils.NewPostRoute(
			"volumeCopy",
			"/volumes/{service}/{volumeID}",
			r.volumeCopy,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				schema.VolumeCopyRequestSchema,
				schema.VolumeSchema,
				func() interface{} { return &types.VolumeCopyRequest{} }),
			handlers.NewPostArgsHandler(),
		).Queries("copy"),

		// snapshot an existing volume
		httputils.NewPostRoute(
			"volumeSnapshot",
			"/volumes/{service}/{volumeID}",
			r.volumeSnapshot,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				schema.VolumeSnapshotRequestSchema,
				schema.SnapshotSchema,
				func() interface{} { return &types.VolumeSnapshotRequest{} }),
			handlers.NewPostArgsHandler(),
		).Queries("snapshot"),

		// attach an existing volume
		httputils.NewPostRoute(
			"volumeAttach",
			"/volumes/{service}/{volumeID}",
			r.volumeAttach,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				schema.VolumeAttachRequestSchema,
				schema.VolumeSchema,
				func() interface{} { return &types.VolumeAttachRequest{} }),
			handlers.NewPostArgsHandler(),
		).Queries("attach"),

		// detach all volumes for all services
		httputils.NewPostRoute(
			"volumesDetachAll",
			"/volumes",
			r.volumeDetachAll,
			handlers.NewSchemaValidator(
				schema.VolumeDetachRequestSchema,
				schema.ServiceVolumeMapSchema,
				func() interface{} { return &types.VolumeDetachRequest{} }),
			handlers.NewPostArgsHandler(),
		).Queries("detach"),

		// detach an individual volume
		httputils.NewPostRoute(
			"volumeDetach",
			"/volumes/{service}/{volumeID}",
			r.volumeDetach,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
			handlers.NewSchemaValidator(
				schema.VolumeDetachRequestSchema,
				schema.VolumeSchema,
				func() interface{} { return &types.VolumeDetachRequest{} }),
			handlers.NewPostArgsHandler(),
		).Queries("detach"),

		// DELETE
		httputils.NewDeleteRoute(
			"volumeRemove",
			"/volumes/{service}/{volumeID}",
			r.volumeRemove,
			handlers.NewServiceValidator(),
			handlers.NewStorageSessionHandler(),
		),
	}
}