ServiceRequest.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 1999-2019 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICEREQUEST_H_
  17. #define CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICEREQUEST_H_
  18. #include <map>
  19. #include "CoreExport.h"
  20. #include "Url.h"
  21. #include <string>
  22. namespace AlibabaCloud {
  23. class ALIBABACLOUD_CORE_EXPORT ServiceRequest {
  24. public:
  25. typedef std::string ParameterNameType;
  26. typedef std::string ParameterValueType;
  27. typedef std::map<ParameterNameType, ParameterValueType> ParameterCollection;
  28. virtual ~ServiceRequest();
  29. const char* content() const;
  30. size_t contentSize() const;
  31. bool hasContent() const;
  32. ParameterCollection parameters() const;
  33. std::string product() const;
  34. std::string resourcePath() const;
  35. std::string version() const;
  36. std::string scheme() const;
  37. long connectTimeout() const;
  38. long readTimeout() const;
  39. void setConnectTimeout(const long connectTimeout);
  40. void setReadTimeout(const long readTimeout);
  41. protected:
  42. ServiceRequest(const std::string &product, const std::string &version);
  43. ServiceRequest(const ServiceRequest &other);
  44. ServiceRequest(ServiceRequest &&other);
  45. ServiceRequest& operator=(const ServiceRequest &other);
  46. ServiceRequest& operator=(ServiceRequest &&other);
  47. void addParameter(const ParameterNameType &name,
  48. const ParameterValueType &value);
  49. ParameterValueType parameter(const ParameterNameType &name) const;
  50. ParameterValueType coreParameter(const ParameterNameType &name) const;
  51. void removeParameter(const ParameterNameType &name);
  52. void setContent(const char *data, size_t size);
  53. void setParameter(const ParameterNameType &name,
  54. const ParameterValueType &value);
  55. void setCoreParameter(const ParameterNameType &name,
  56. const ParameterValueType &value);
  57. void setParameters(const ParameterCollection &params);
  58. void setResourcePath(const std::string &path);
  59. void setProduct(const std::string &product);
  60. void setVersion(const std::string &version);
  61. void setScheme(const std::string scheme);
  62. private:
  63. char *content_;
  64. size_t contentSize_;
  65. ParameterCollection params_;
  66. std::string product_;
  67. std::string resourcePath_;
  68. std::string version_;
  69. std::string scheme_;
  70. long connectTimeout_;
  71. long readTimeout_;
  72. };
  73. } // namespace AlibabaCloud
  74. #endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICEREQUEST_H_