1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/ec2/model/ModifySnapshotAttributeRequest.h>
7 #include <aws/core/utils/StringUtils.h>
8 #include <aws/core/utils/memory/stl/AWSStringStream.h>
9 
10 using namespace Aws::EC2::Model;
11 using namespace Aws::Utils;
12 
ModifySnapshotAttributeRequest()13 ModifySnapshotAttributeRequest::ModifySnapshotAttributeRequest() :
14     m_attribute(SnapshotAttributeName::NOT_SET),
15     m_attributeHasBeenSet(false),
16     m_createVolumePermissionHasBeenSet(false),
17     m_groupNamesHasBeenSet(false),
18     m_operationType(OperationType::NOT_SET),
19     m_operationTypeHasBeenSet(false),
20     m_snapshotIdHasBeenSet(false),
21     m_userIdsHasBeenSet(false),
22     m_dryRun(false),
23     m_dryRunHasBeenSet(false)
24 {
25 }
26 
SerializePayload() const27 Aws::String ModifySnapshotAttributeRequest::SerializePayload() const
28 {
29   Aws::StringStream ss;
30   ss << "Action=ModifySnapshotAttribute&";
31   if(m_attributeHasBeenSet)
32   {
33     ss << "Attribute=" << SnapshotAttributeNameMapper::GetNameForSnapshotAttributeName(m_attribute) << "&";
34   }
35 
36   if(m_createVolumePermissionHasBeenSet)
37   {
38     m_createVolumePermission.OutputToStream(ss, "CreateVolumePermission");
39   }
40 
41   if(m_groupNamesHasBeenSet)
42   {
43     unsigned groupNamesCount = 1;
44     for(auto& item : m_groupNames)
45     {
46       ss << "UserGroup." << groupNamesCount << "="
47           << StringUtils::URLEncode(item.c_str()) << "&";
48       groupNamesCount++;
49     }
50   }
51 
52   if(m_operationTypeHasBeenSet)
53   {
54     ss << "OperationType=" << OperationTypeMapper::GetNameForOperationType(m_operationType) << "&";
55   }
56 
57   if(m_snapshotIdHasBeenSet)
58   {
59     ss << "SnapshotId=" << StringUtils::URLEncode(m_snapshotId.c_str()) << "&";
60   }
61 
62   if(m_userIdsHasBeenSet)
63   {
64     unsigned userIdsCount = 1;
65     for(auto& item : m_userIds)
66     {
67       ss << "UserId." << userIdsCount << "="
68           << StringUtils::URLEncode(item.c_str()) << "&";
69       userIdsCount++;
70     }
71   }
72 
73   if(m_dryRunHasBeenSet)
74   {
75     ss << "DryRun=" << std::boolalpha << m_dryRun << "&";
76   }
77 
78   ss << "Version=2016-11-15";
79   return ss.str();
80 }
81 
82 
DumpBodyToUrl(Aws::Http::URI & uri) const83 void  ModifySnapshotAttributeRequest::DumpBodyToUrl(Aws::Http::URI& uri ) const
84 {
85   uri.SetQueryString(SerializePayload());
86 }
87