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
24 * @brief This file provides data Model for RAML Action.
\r
33 #include "ActionType.h"
\r
35 #include "QueryParameter.h"
\r
36 #include "RequestResponseBody.h"
\r
37 #include "UriParameter.h"
\r
38 #include "Response.h"
\r
40 #include "IncludeResolver.h"
\r
46 * @brief This class provides data Model for RAML Action.
\r
52 * This method is for getting Type from Action.
\r
54 * @return Type as string.
\r
56 virtual ActionType getType() const;
\r
59 * This method is for setting Type to Action.
\r
61 * @param type - Type as string
\r
63 virtual void setType(const ActionType &type);
\r
66 * This method is for getting Description from Action.
\r
68 * @return Description as string.
\r
70 virtual std::string getDescription() const;
\r
73 * This method is for setting Description to Action.
\r
75 * @param description - Description as string
\r
77 virtual void setDescription(const std::string &description);
\r
80 * This method is for getting Header from Action.
\r
82 * @return map of Header name and Pointer to Header.
\r
84 virtual std::map<std::string, HeaderPtr > const &getHeaders() const;
\r
87 * This method is for setting Header to Action.
\r
89 * @param headerName - Header name as string
\r
90 * @param header - Pointer to Header
\r
92 virtual void setHeader(const std::string &headerName, const HeaderPtr &header);
\r
95 * This method is for getting QueryParameter from Action.
\r
97 * @return map of QueryParameter name and Pointer to QueryParameter.
\r
99 virtual std::map<std::string, QueryParameterPtr > const &getQueryParameters()const;
\r
102 * This method is for setting QueryParameter to Action.
\r
104 * @param paramName - QueryParameter name as string
\r
105 * @param queryParameter - Pointer to QueryParameter
\r
107 virtual void setQueryParameter(const std::string ¶mName,
\r
108 const QueryParameterPtr &queryParameter);
\r
111 * This method is for getting RequestResponseBody from Action.
\r
113 * @param bodyType - bodyType name as string
\r
115 * @return Pointer to RequestResponseBody
\r
117 virtual RequestResponseBodyPtr getRequestBody(const std::string &bodyType);
\r
120 * This method is for getting RequestResponseBody from Action.
\r
122 * @return map of RequestResponseBody name and Pointer to RequestResponseBody.
\r
124 virtual std::map<std::string, RequestResponseBodyPtr> const &getRequestBody() const;
\r
127 * This method is for setting RequestResponseBody to Action.
\r
129 * @param typeName - RequestResponseBody name as string
\r
131 virtual void setRequestBody(const std::string &typeName);
\r
134 * This method is for setting Type to Action.
\r
136 * @param typeName - RequestResponseBody name as string
\r
137 * @param body - Pointer to RequestResponseBody
\r
139 virtual void setRequestBody(const std::string &typeName ,
\r
140 const RequestResponseBodyPtr &body);
\r
143 * This method is for getting Response from Action.
\r
145 * @param responseCode - Response code as string
\r
147 * @return Pointer to Response
\r
149 virtual ResponsePtr getResponse(const std::string &responseCode);
\r
152 * This method is for getting Response from Action.
\r
154 * @return map of response code and Pointer to Response
\r
156 virtual std::map<std::string, ResponsePtr> const &getResponses() const;
\r
159 * This method is for setting Response to Action.
\r
161 * @param responseCode - responseCode as string
\r
162 * @param response - Pointer to Response
\r
164 virtual void setResponse(const std::string &responseCode, const ResponsePtr &response);
\r
167 * This method is for getting Protocols from Action.
\r
169 * @return list of Protocols as string.
\r
171 virtual std::list<std::string> const &getProtocols() const;
\r
174 * This method is for setting Protocols to Action.
\r
176 * @param protocol - protocol as string
\r
178 virtual void setProtocol(const std::string &protocol);
\r
181 * This method is for getting BaseUriParameter from Action.
\r
183 * @return map of BaseUriParameter name and pointer to UriParameter.
\r
185 virtual std::map< std::string, UriParameterPtr > const &getBaseUriParameters() const;
\r
188 * This method is for setting BaseUriParameter to Action.
\r
190 * @param paramName - BaseUriParameter name as string
\r
191 * @param baseUriParameter - pointer to UriParameter.
\r
193 virtual void setBaseUriParameter(const std::string ¶mName ,
\r
194 const UriParameterPtr &baseUriParameter);
\r
197 * This method is for getting Traits from Action.
\r
199 * @return list of traits as string.
\r
201 virtual std::list<std::string> const &getTraits() const;
\r
204 * This method is for setting Trait to Action.
\r
206 * @param trait - trait as string
\r
208 virtual void setTrait(const std::string &trait);
\r
211 * Constructor of Action.
\r
213 Action(): m_includeResolver(NULL) { }
\r
216 * Constructor of Action.
\r
218 * @param actionType - type of action in ActionType enum
\r
219 * @param yamlNode - Reference to YamlNode for reading the Action
\r
220 * @param includeResolver - Reference to IncludeResolver for reading external files
\r
223 Action(const ActionType actionType, const YAML::Node &yamlNode,
\r
224 const IncludeResolverPtr &includeResolver)
\r
225 : m_includeResolver(includeResolver)
\r
227 readAction(actionType, yamlNode);
\r
231 * copy Constructor of Action.
\r
233 Action(const Action &) = default;
\r
235 virtual void readAction(const ActionType actionType, const YAML::Node &yamlNode);
\r
240 std::string m_description;
\r
241 std::map<std::string, HeaderPtr> m_headers;
\r
242 std::map<std::string, QueryParameterPtr> m_queryParameters;
\r
243 std::map<std::string, RequestResponseBodyPtr> m_requestBody;
\r
244 std::map<std::string, ResponsePtr> m_responses;
\r
245 std::list<std::string> m_protocols;
\r
246 std::map< std::string, UriParameterPtr > m_baseUriParameters;
\r
247 std::list<std::string> m_trait;
\r
250 IncludeResolverPtr m_includeResolver;
\r
253 /** ActionPtr - shared Ptr to Action.*/
\r
254 typedef std::shared_ptr<Action> ActionPtr;
\r