@ -31,7 +31,7 @@ type adminAPIHandlers struct {
}
}
// registerAdminRouter - Add handler functions for each service REST API routes.
// registerAdminRouter - Add handler functions for each service REST API routes.
func registerAdminRouter ( router * mux . Router ) {
func registerAdminRouter ( router * mux . Router , enableIAM bool ) {
adminAPI := adminAPIHandlers { }
adminAPI := adminAPIHandlers { }
// Admin router
// Admin router
@ -69,42 +69,44 @@ func registerAdminRouter(router *mux.Router) {
/// Config operations
/// Config operations
// Update credentials
if enableIAM {
adminV1Router . Methods ( http . MethodPut ) . Path ( "/config/credential" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . UpdateAdminCredentialsHandler ) )
// Update credentials
// Get config
adminV1Router . Methods ( http . MethodPut ) . Path ( "/config/credential" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . UpdateAdminCredentialsHandler ) )
adminV1Router . Methods ( http . MethodGet ) . Path ( "/config" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . GetConfigHandler ) )
// Get config
// Set config
adminV1Router . Methods ( http . MethodGet ) . Path ( "/config" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . GetConfigHandler ) )
adminV1Router . Methods ( http . MethodPut ) . Path ( "/config" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . SetConfigHandler ) )
// Set config
adminV1Router . Methods ( http . MethodPut ) . Path ( "/config" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . SetConfigHandler ) )
// Get config keys/values
// Get config keys/values
adminV1Router . Methods ( http . MethodGet ) . Path ( "/config-keys" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . GetConfigKeysHandler ) )
adminV1Router . Methods ( http . MethodGet ) . Path ( "/config-keys" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . GetConfigKeysHandler ) )
// Set config keys/values
// Set config keys/values
adminV1Router . Methods ( http . MethodPut ) . Path ( "/config-keys" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . SetConfigKeysHandler ) )
adminV1Router . Methods ( http . MethodPut ) . Path ( "/config-keys" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . SetConfigKeysHandler ) )
// -- IAM APIs --
// -- IAM APIs --
// Add policy IAM
// Add policy IAM
adminV1Router . Methods ( http . MethodPut ) . Path ( "/add-canned-policy" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . AddCannedPolicy ) ) . Queries ( "name" , "{name:.*}" )
adminV1Router . Methods ( http . MethodPut ) . Path ( "/add-canned-policy" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . AddCannedPolicy ) ) . Queries ( "name" , "{name:.*}" )
// Add user IAM
// Add user IAM
adminV1Router . Methods ( http . MethodPut ) . Path ( "/add-user" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . AddUser ) ) . Queries ( "accessKey" , "{accessKey:.*}" )
adminV1Router . Methods ( http . MethodPut ) . Path ( "/add-user" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . AddUser ) ) . Queries ( "accessKey" , "{accessKey:.*}" )
adminV1Router . Methods ( http . MethodPut ) . Path ( "/set-user-policy" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . SetUserPolicy ) ) .
adminV1Router . Methods ( http . MethodPut ) . Path ( "/set-user-policy" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . SetUserPolicy ) ) .
Queries ( "accessKey" , "{accessKey:.*}" ) . Queries ( "name" , "{name:.*}" )
Queries ( "accessKey" , "{accessKey:.*}" ) . Queries ( "name" , "{name:.*}" )
adminV1Router . Methods ( http . MethodPut ) . Path ( "/set-user-status" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . SetUserStatus ) ) .
adminV1Router . Methods ( http . MethodPut ) . Path ( "/set-user-status" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . SetUserStatus ) ) .
Queries ( "accessKey" , "{accessKey:.*}" ) . Queries ( "status" , "{status:.*}" )
Queries ( "accessKey" , "{accessKey:.*}" ) . Queries ( "status" , "{status:.*}" )
// Remove policy IAM
// Remove policy IAM
adminV1Router . Methods ( http . MethodDelete ) . Path ( "/remove-canned-policy" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . RemoveCannedPolicy ) ) . Queries ( "name" , "{name:.*}" )
adminV1Router . Methods ( http . MethodDelete ) . Path ( "/remove-canned-policy" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . RemoveCannedPolicy ) ) . Queries ( "name" , "{name:.*}" )
// Remove user IAM
// Remove user IAM
adminV1Router . Methods ( http . MethodDelete ) . Path ( "/remove-user" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . RemoveUser ) ) . Queries ( "accessKey" , "{accessKey:.*}" )
adminV1Router . Methods ( http . MethodDelete ) . Path ( "/remove-user" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . RemoveUser ) ) . Queries ( "accessKey" , "{accessKey:.*}" )
// List users
// List users
adminV1Router . Methods ( http . MethodGet ) . Path ( "/list-users" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . ListUsers ) )
adminV1Router . Methods ( http . MethodGet ) . Path ( "/list-users" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . ListUsers ) )
// List policies
// List policies
adminV1Router . Methods ( http . MethodGet ) . Path ( "/list-canned-policies" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . ListCannedPolicies ) )
adminV1Router . Methods ( http . MethodGet ) . Path ( "/list-canned-policies" ) . HandlerFunc ( httpTraceHdrs ( adminAPI . ListCannedPolicies ) )
}
// If none of the routes match.
// If none of the routes match, return error .
adminV1Router . NotFoundHandler = http . HandlerFunc ( httpTraceHdrs ( notFoundHandler ) )
adminV1Router . NotFoundHandler = http . HandlerFunc ( httpTraceHdrs ( notFoundHandlerJSON ) )
}
}