userver: /data/code/userver/libraries/s3api/src/s3api/models/s3api_connection_type.cpp Source File
Loading...
Searching...
No Matches
s3api_connection_type.cpp
1#include <userver/s3api/models/s3api_connection_type.hpp>
2
3#include <userver/formats/json/value.hpp>
4#include <userver/utils/assert.hpp>
5
6USERVER_NAMESPACE_BEGIN
7
8namespace s3api {
9
10S3ConnectionType Parse(const formats::json::Value& elem, formats::parse::To<S3ConnectionType>) {
11 const auto as_string = elem.As<std::string>();
12 if (as_string == "http") {
13 return S3ConnectionType::kHttp;
14 }
15 if (as_string == "https") {
16 return S3ConnectionType::kHttps;
17 }
18 UINVARIANT(false, "invalid value of connection_type");
19}
20
21std::string_view ToStringView(S3ConnectionType connection_type) {
22 switch (connection_type) {
23 case S3ConnectionType::kHttp:
24 return "http";
25 case S3ConnectionType::kHttps:
26 return "https";
27 }
28 return "unknown";
29}
30
31std::string ToString(S3ConnectionType connection_type) { return std::string{ToStringView(connection_type)}; }
32
33} // namespace s3api
34
35USERVER_NAMESPACE_END