MCPcopy Create free account
hub / github.com/apache/mesos / _api

Method _api

src/slave/http.cpp:541–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539
540
541Future<Response> Http::_api(
542 const mesos::agent::Call& call,
543 Option<Owned<Reader<mesos::agent::Call>>>&& reader,
544 const RequestMediaTypes& mediaTypes,
545 const Option<Principal>& principal) const
546{
547 // Validate that a client has not _accidentally_ sent us a
548 // streaming request for a call type that does not support it.
549 if (streamingMediaType(mediaTypes.content) &&
550 call.type() != mesos::agent::Call::ATTACH_CONTAINER_INPUT) {
551 return UnsupportedMediaType(
552 "Streaming 'Content-Type' " + stringify(mediaTypes.content) + " is "
553 "not supported for " + stringify(call.type()) + " call");
554 } else if (!streamingMediaType(mediaTypes.content) &&
555 call.type() == mesos::agent::Call::ATTACH_CONTAINER_INPUT) {
556 return UnsupportedMediaType(
557 string("Expecting 'Content-Type' to be ") + APPLICATION_RECORDIO +
558 " for " + stringify(call.type()) + " call");
559 }
560
561 if (streamingMediaType(mediaTypes.accept) &&
562 call.type() != mesos::agent::Call::ATTACH_CONTAINER_OUTPUT &&
563 call.type() != mesos::agent::Call::LAUNCH_NESTED_CONTAINER_SESSION) {
564 return NotAcceptable("Streaming response is not supported for " +
565 stringify(call.type()) + " call");
566 }
567
568 // Each handler must log separately to add context
569 // it might extract from the nested message.
570 switch (call.type()) {
571 case mesos::agent::Call::UNKNOWN:
572 return NotImplemented();
573
574 case mesos::agent::Call::GET_HEALTH:
575 return getHealth(call, mediaTypes.accept, principal);
576
577 case mesos::agent::Call::GET_FLAGS:
578 return getFlags(call, mediaTypes.accept, principal);
579
580 case mesos::agent::Call::GET_VERSION:
581 return getVersion(call, mediaTypes.accept, principal);
582
583 case mesos::agent::Call::GET_METRICS:
584 return getMetrics(call, mediaTypes.accept, principal);
585
586 case mesos::agent::Call::GET_LOGGING_LEVEL:
587 return getLoggingLevel(call, mediaTypes.accept, principal);
588
589 case mesos::agent::Call::SET_LOGGING_LEVEL:
590 return setLoggingLevel(call, mediaTypes.accept, principal);
591
592 case mesos::agent::Call::LIST_FILES:
593 return listFiles(call, mediaTypes.accept, principal);
594
595 case mesos::agent::Call::READ_FILE:
596 return readFile(call, mediaTypes.accept, principal);
597
598 case mesos::agent::Call::GET_STATE:

Callers

nothing calls this directly

Calls 8

streamingMediaTypeFunction · 0.85
NotAcceptableClass · 0.85
NotImplementedClass · 0.85
getFrameworksFunction · 0.85
typeMethod · 0.80
stringifyFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected