1 /******************************************************************
\r
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 ******************************************************************/
\r
25 ActionType Action::getType() const
\r
29 void Action::setType(const ActionType &type)
\r
33 std::string Action::getDescription() const
\r
35 return m_description;
\r
37 void Action::setDescription(const std::string &description)
\r
39 m_description = description;
\r
41 std::map<std::string, HeaderPtr > const &Action::getHeaders() const
\r
45 void Action::setHeader(const std::string &headerName, const HeaderPtr &header)
\r
47 m_headers[headerName] = header;
\r
49 std::map<std::string, QueryParameterPtr > const &Action::getQueryParameters()const
\r
51 return m_queryParameters;
\r
53 void Action::setQueryParameter(const std::string ¶mName,
\r
54 const QueryParameterPtr &queryParameter)
\r
56 m_queryParameters[paramName] = queryParameter;
\r
58 RequestResponseBodyPtr Action::getRequestBody(const std::string &bodyType)
\r
60 return m_requestBody[bodyType];
\r
63 std::map<std::string, RequestResponseBodyPtr> const &Action::getRequestBody() const
\r
65 return m_requestBody;
\r
67 void Action::setRequestBody(const std::string &typeName)
\r
69 m_requestBody[typeName] = std::make_shared<RequestResponseBody>(typeName);
\r
72 void Action::setRequestBody(const std::string &typeName , const RequestResponseBodyPtr &body)
\r
74 m_requestBody[typeName] = body;
\r
76 ResponsePtr Action::getResponse(const std::string &responseCode)
\r
78 return m_responses[responseCode];
\r
81 std::map<std::string, ResponsePtr> const &Action::getResponses() const
\r
85 void Action::setResponse(const std::string &responseCode, const ResponsePtr &response)
\r
87 m_responses[responseCode] = response;
\r
90 std::list<std::string> const &Action::getProtocols() const
\r
94 void Action::setProtocol(const std::string &protocol)
\r
96 m_protocols.push_back(protocol);
\r
98 std::map<std::string, UriParameterPtr > const &Action::getBaseUriParameters() const
\r
100 return m_baseUriParameters;
\r
102 void Action::setBaseUriParameter(const std::string ¶mName ,
\r
103 const UriParameterPtr &baseUriParameter)
\r
105 m_baseUriParameters[paramName] = baseUriParameter;
\r
108 std::list<std::string> const &Action::getTraits() const
\r
112 void Action::setTrait(const std::string &trait)
\r
114 m_trait.push_back(trait);
\r
116 void Action::readAction(const ActionType actionType, const YAML::Node &yamlNode)
\r
118 m_type = actionType;
\r
119 for ( YAML::const_iterator it = yamlNode.begin(); it != yamlNode.end(); ++it )
\r
121 std::string key = READ_NODE_AS_STRING(it->first);
\r
123 if (key == Keys::Description)
\r
124 setDescription(READ_NODE_AS_STRING(it->second));
\r
125 else if (key == Keys::Responses)
\r
127 YAML::Node responseNode = it->second;
\r
128 for ( YAML::const_iterator tt = responseNode.begin(); tt != responseNode.end(); ++tt )
\r
130 std::string responseCode = READ_NODE_AS_STRING(tt->first);
\r
131 setResponse(responseCode, std::make_shared<Response>(tt->second, m_includeResolver));
\r
134 else if (key == Keys::Headers)
\r
136 YAML::Node paramNode = it->second;
\r
137 for ( YAML::const_iterator tt = paramNode.begin(); tt != paramNode.end(); ++tt )
\r
139 setHeader(READ_NODE_AS_STRING(tt->first), std::make_shared<Header>(tt->second));
\r
142 else if (key == Keys::QueryParameters)
\r
144 YAML::Node paramNode = it->second;
\r
145 for ( YAML::const_iterator tt = paramNode.begin(); tt != paramNode.end(); ++tt )
\r
147 setQueryParameter(READ_NODE_AS_STRING(tt->first), std::make_shared<QueryParameter>(tt->second));
\r
150 else if (key == Keys::Protocols)
\r
152 YAML::Node protocolNode = it->second;
\r
153 for ( YAML::const_iterator tt = protocolNode.begin(); tt != protocolNode.end(); ++tt )
\r
155 setProtocol(READ_NODE_AS_STRING(*tt));
\r
158 else if (key == Keys::BaseUriParameters)
\r
160 YAML::Node paramNode = it->second;
\r
161 for ( YAML::const_iterator tt = paramNode.begin(); tt != paramNode.end(); ++tt )
\r
163 setBaseUriParameter(READ_NODE_AS_STRING(tt->first), std::make_shared<UriParameter>(tt->second));
\r
166 else if (key == Keys::Body)
\r
168 YAML::Node responseBody = it->second;
\r
170 for ( YAML::const_iterator tt = responseBody.begin(); tt != responseBody.end(); ++tt )
\r
172 std::string type = READ_NODE_AS_STRING(tt->first);
\r
173 setRequestBody(type, std::make_shared<RequestResponseBody>(type, tt->second, m_includeResolver));
\r
176 else if (key == Keys::IsTrait)
\r
178 YAML::Node traitNode = it->second;
\r
179 for ( YAML::const_iterator tt = traitNode.begin(); tt != traitNode.end(); ++tt )
\r
181 setTrait(READ_NODE_AS_STRING(*tt));
\r