From abaf88548bdd33a142769a9d477799769606b8ab Mon Sep 17 00:00:00 2001 From: dinghh Date: Sun, 8 Oct 2023 15:15:19 +0800 Subject: [PATCH 1/3] [1] iam policy c++ sdk --- .../include/aws/iam/model/GetPolicyRequest.h | 20 ++++---- .../include/aws/iam/model/Policy.h | 42 ++++++++++++++++ .../source/model/GetPolicyRequest.cpp | 6 +-- .../aws-cpp-sdk-iam/source/model/Policy.cpp | 17 +++++++ create_policy.cpp | 49 +++++++++++++++++++ get_policy.cpp | 48 ++++++++++++++++++ 6 files changed, 169 insertions(+), 13 deletions(-) create mode 100644 create_policy.cpp create mode 100644 get_policy.cpp diff --git a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/GetPolicyRequest.h b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/GetPolicyRequest.h index 571677ff0..728d0067c 100644 --- a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/GetPolicyRequest.h +++ b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/GetPolicyRequest.h @@ -42,7 +42,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline const Aws::String& GetPolicyArn() const{ return m_policyArn; } + inline const Aws::String& GetPolicyName() const{ return m_policyName; } /** *

The Amazon Resource Name (ARN) of the managed policy that you want @@ -50,7 +50,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline bool PolicyArnHasBeenSet() const { return m_policyArnHasBeenSet; } + inline bool PolicyNameHasBeenSet() const { return m_policyNameHasBeenSet; } /** *

The Amazon Resource Name (ARN) of the managed policy that you want @@ -58,7 +58,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline void SetPolicyArn(const Aws::String& value) { m_policyArnHasBeenSet = true; m_policyArn = value; } + inline void SetPolicyName(const Aws::String& value) { m_policyNameHasBeenSet = true; m_policyName = value; } /** *

The Amazon Resource Name (ARN) of the managed policy that you want @@ -66,7 +66,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline void SetPolicyArn(Aws::String&& value) { m_policyArnHasBeenSet = true; m_policyArn = std::move(value); } + inline void SetPolicyName(Aws::String&& value) { m_policyNameHasBeenSet = true; m_policyName = std::move(value); } /** *

The Amazon Resource Name (ARN) of the managed policy that you want @@ -74,7 +74,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline void SetPolicyArn(const char* value) { m_policyArnHasBeenSet = true; m_policyArn.assign(value); } + inline void SetPolicyName(const char* value) { m_policyNameHasBeenSet = true; m_policyName.assign(value); } /** *

The Amazon Resource Name (ARN) of the managed policy that you want @@ -82,7 +82,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline GetPolicyRequest& WithPolicyArn(const Aws::String& value) { SetPolicyArn(value); return *this;} + inline GetPolicyRequest& WithPolicyName(const Aws::String& value) { SetPolicyName(value); return *this;} /** *

The Amazon Resource Name (ARN) of the managed policy that you want @@ -90,7 +90,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline GetPolicyRequest& WithPolicyArn(Aws::String&& value) { SetPolicyArn(std::move(value)); return *this;} + inline GetPolicyRequest& WithPolicyName(Aws::String&& value) { SetPolicyName(std::move(value)); return *this;} /** *

The Amazon Resource Name (ARN) of the managed policy that you want @@ -98,12 +98,12 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline GetPolicyRequest& WithPolicyArn(const char* value) { SetPolicyArn(value); return *this;} + inline GetPolicyRequest& WithPolicyName(const char* value) { SetPolicyName(value); return *this;} private: - Aws::String m_policyArn; - bool m_policyArnHasBeenSet; + Aws::String m_policyName; + bool m_policyNameHasBeenSet; }; } // namespace Model diff --git a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/Policy.h b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/Policy.h index 3a21539f0..d32e659e0 100644 --- a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/Policy.h +++ b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/Policy.h @@ -88,6 +88,45 @@ namespace Model */ inline Policy& WithPolicyName(const char* value) { SetPolicyName(value); return *this;} + /** + *

The friendly name (not ARN) identifying the policy.

+ */ + inline const Aws::String& GetDocument() const{ return m_document; } + + /** + *

The friendly name (not ARN) identifying the policy.

+ */ + inline bool DocumentHasBeenSet() const { return m_documentHasBeenSet; } + + /** + *

The friendly name (not ARN) identifying the policy.

+ */ + inline void SetDocument(const Aws::String& value) { m_documentHasBeenSet = true; m_document = value; } + + /** + *

The friendly name (not ARN) identifying the policy.

+ */ + inline void SetDocument(Aws::String&& value) { m_documentHasBeenSet = true; m_document = std::move(value); } + + /** + *

The friendly name (not ARN) identifying the policy.

+ */ + inline void SetDocument(const char* value) { m_documentHasBeenSet = true; m_document.assign(value); } + + /** + *

The friendly name (not ARN) identifying the policy.

+ */ + inline Policy& WithDocument(const Aws::String& value) { SetDocument(value); return *this;} + + /** + *

The friendly name (not ARN) identifying the policy.

+ */ + inline Policy& WithDocument(Aws::String&& value) { SetDocument(std::move(value)); return *this;} + + /** + *

The friendly name (not ARN) identifying the policy.

+ */ + inline Policy& WithDocument(const char* value) { SetDocument(value); return *this;} /** *

The stable and unique string identifying the policy.

For more @@ -589,6 +628,9 @@ namespace Model Aws::String m_policyName; bool m_policyNameHasBeenSet; + + Aws::String m_document; + bool m_documentHasBeenSet; Aws::String m_policyId; bool m_policyIdHasBeenSet; diff --git a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/GetPolicyRequest.cpp b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/GetPolicyRequest.cpp index 55d8173c3..1fa78dccc 100644 --- a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/GetPolicyRequest.cpp +++ b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/GetPolicyRequest.cpp @@ -11,7 +11,7 @@ using namespace Aws::IAM::Model; using namespace Aws::Utils; GetPolicyRequest::GetPolicyRequest() : - m_policyArnHasBeenSet(false) + m_policyNameHasBeenSet(false) { } @@ -19,9 +19,9 @@ Aws::String GetPolicyRequest::SerializePayload() const { Aws::StringStream ss; ss << "Action=GetPolicy&"; - if(m_policyArnHasBeenSet) + if(m_policyNameHasBeenSet) { - ss << "PolicyArn=" << StringUtils::URLEncode(m_policyArn.c_str()) << "&"; + ss << "PolicyName=" << StringUtils::URLEncode(m_policyName.c_str()) << "&"; } ss << "Version=2010-05-08"; diff --git a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/Policy.cpp b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/Policy.cpp index c9135a56e..a9417bb07 100644 --- a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/Policy.cpp +++ b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/Policy.cpp @@ -22,6 +22,7 @@ namespace Model Policy::Policy() : m_policyNameHasBeenSet(false), + m_documentHasBeenSet(false), m_policyIdHasBeenSet(false), m_arnHasBeenSet(false), m_pathHasBeenSet(false), @@ -41,6 +42,7 @@ Policy::Policy() : Policy::Policy(const XmlNode& xmlNode) : m_policyNameHasBeenSet(false), + m_documentHasBeenSet(false), m_policyIdHasBeenSet(false), m_arnHasBeenSet(false), m_pathHasBeenSet(false), @@ -71,6 +73,12 @@ Policy& Policy::operator =(const XmlNode& xmlNode) m_policyName = Aws::Utils::Xml::DecodeEscapedXmlText(policyNameNode.GetText()); m_policyNameHasBeenSet = true; } + XmlNode documentNode = resultNode.FirstChild("Document"); + if(!documentNode.IsNull()) + { + m_document = Aws::Utils::Xml::DecodeEscapedXmlText(documentNode.GetText()); + m_documentHasBeenSet = true; + } XmlNode policyIdNode = resultNode.FirstChild("PolicyId"); if(!policyIdNode.IsNull()) { @@ -155,6 +163,11 @@ void Policy::OutputToStream(Aws::OStream& oStream, const char* location, unsigne oStream << location << index << locationValue << ".PolicyName=" << StringUtils::URLEncode(m_policyName.c_str()) << "&"; } + if(m_documentHasBeenSet) + { + oStream << location << index << locationValue << ".Document=" << StringUtils::URLEncode(m_document.c_str()) << "&"; + } + if(m_policyIdHasBeenSet) { oStream << location << index << locationValue << ".PolicyId=" << StringUtils::URLEncode(m_policyId.c_str()) << "&"; @@ -224,6 +237,10 @@ void Policy::OutputToStream(Aws::OStream& oStream, const char* location) const { oStream << location << ".PolicyName=" << StringUtils::URLEncode(m_policyName.c_str()) << "&"; } + if(m_documentHasBeenSet) + { + oStream << location << ".Document=" << StringUtils::URLEncode(m_document.c_str()) << "&"; + } if(m_policyIdHasBeenSet) { oStream << location << ".PolicyId=" << StringUtils::URLEncode(m_policyId.c_str()) << "&"; diff --git a/create_policy.cpp b/create_policy.cpp new file mode 100644 index 000000000..6959bce9e --- /dev/null +++ b/create_policy.cpp @@ -0,0 +1,49 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Aws::IAM; +using namespace Aws::IAM::Model; +using namespace Aws::Utils; + + +int main(int argc, char** argv) +{ + Aws::SDKOptions options; + options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace; + InitAPI(options); + + Aws::IAM::IAMClient iamClient = sugonGetIAMClient("Zv33LRIEIjMOOBXX9JmwJlfc048sfUtY", "wikiydsg0u0vmsl0tvaplkkuhh0rhgnf", "http://10.20.0.81:20482"); + + Aws::IAM::Model::CreatePolicyRequest request; + + request.SetPolicyName("C_policy1"); + request.SetPolicyDocument("{\"Version\": \"2012-10-17\", \"Statement\":[{\"Sid\":\"IAMExamplePolicy\", \"Effect\": \"Allow\", \"Action\":\"*\", \"Resource\":\"*\"}]}"); + + CreatePolicyOutcome outcome = iamClient.CreatePolicy(request); + + if (!outcome.IsSuccess()) + { + const Aws::IAM::IAMError &err = outcome.GetError(); + std::cerr << "Error: CreatePolicy: " << + err.GetExceptionName() << ": " << err.GetMessage() << std::endl; + } + else + { + Policy policy = outcome.GetResult().GetPolicy(); + std::cout< +#include +#include +#include +#include +#include +#include +#include + +using namespace Aws::IAM; +using namespace Aws::IAM::Model; +using namespace Aws::Utils; + + +int main(int argc, char** argv) +{ + Aws::SDKOptions options; + options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace; + InitAPI(options); + + Aws::IAM::IAMClient iamClient = sugonGetIAMClient("Zv33LRIEIjMOOBXX9JmwJlfc048sfUtY", "wikiydsg0u0vmsl0tvaplkkuhh0rhgnf", "http://10.20.0.81:20482"); + + Aws::IAM::Model::GetPolicyRequest request; + + request.SetPolicyName("C_policy1"); + + GetPolicyOutcome outcome = iamClient.GetPolicy(request); + + if (!outcome.IsSuccess()) + { + const Aws::IAM::IAMError &err = outcome.GetError(); + std::cerr << "Error: CreatePolicy: " << + err.GetExceptionName() << ": " << err.GetMessage() << std::endl; + } + else + { + Policy policy = outcome.GetResult().GetPolicy(); + std::cout< Date: Sun, 8 Oct 2023 15:57:17 +0800 Subject: [PATCH 2/3] [1] iam policy c++ sdk --- .../aws/iam/model/DeletePolicyRequest.h | 20 ++++---- .../source/model/DeletePolicyRequest.cpp | 6 +-- delete_policy.cpp | 45 +++++++++++++++++ get_policy.cpp | 2 +- list_policy.cpp | 50 +++++++++++++++++++ 5 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 delete_policy.cpp create mode 100644 list_policy.cpp diff --git a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/DeletePolicyRequest.h b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/DeletePolicyRequest.h index 78717a2c3..5bf828841 100644 --- a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/DeletePolicyRequest.h +++ b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/include/aws/iam/model/DeletePolicyRequest.h @@ -42,7 +42,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline const Aws::String& GetPolicyArn() const{ return m_policyArn; } + inline const Aws::String& GetPolicyName() const{ return m_policyName; } /** *

The Amazon Resource Name (ARN) of the IAM policy you want to delete.

@@ -50,7 +50,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline bool PolicyArnHasBeenSet() const { return m_policyArnHasBeenSet; } + inline bool PolicyNameHasBeenSet() const { return m_policyNameHasBeenSet; } /** *

The Amazon Resource Name (ARN) of the IAM policy you want to delete.

@@ -58,7 +58,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline void SetPolicyArn(const Aws::String& value) { m_policyArnHasBeenSet = true; m_policyArn = value; } + inline void SetPolicyName(const Aws::String& value) { m_policyNameHasBeenSet = true; m_policyName = value; } /** *

The Amazon Resource Name (ARN) of the IAM policy you want to delete.

@@ -66,7 +66,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline void SetPolicyArn(Aws::String&& value) { m_policyArnHasBeenSet = true; m_policyArn = std::move(value); } + inline void SetPolicyName(Aws::String&& value) { m_policyNameHasBeenSet = true; m_policyName = std::move(value); } /** *

The Amazon Resource Name (ARN) of the IAM policy you want to delete.

@@ -74,7 +74,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline void SetPolicyArn(const char* value) { m_policyArnHasBeenSet = true; m_policyArn.assign(value); } + inline void SetPolicyName(const char* value) { m_policyNameHasBeenSet = true; m_policyName.assign(value); } /** *

The Amazon Resource Name (ARN) of the IAM policy you want to delete.

@@ -82,7 +82,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline DeletePolicyRequest& WithPolicyArn(const Aws::String& value) { SetPolicyArn(value); return *this;} + inline DeletePolicyRequest& WithPolicyName(const Aws::String& value) { SetPolicyName(value); return *this;} /** *

The Amazon Resource Name (ARN) of the IAM policy you want to delete.

@@ -90,7 +90,7 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline DeletePolicyRequest& WithPolicyArn(Aws::String&& value) { SetPolicyArn(std::move(value)); return *this;} + inline DeletePolicyRequest& WithPolicyName(Aws::String&& value) { SetPolicyName(std::move(value)); return *this;} /** *

The Amazon Resource Name (ARN) of the IAM policy you want to delete.

@@ -98,12 +98,12 @@ namespace Model * href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon * Resource Names (ARNs) in the AWS General Reference.

*/ - inline DeletePolicyRequest& WithPolicyArn(const char* value) { SetPolicyArn(value); return *this;} + inline DeletePolicyRequest& WithPolicyName(const char* value) { SetPolicyName(value); return *this;} private: - Aws::String m_policyArn; - bool m_policyArnHasBeenSet; + Aws::String m_policyName; + bool m_policyNameHasBeenSet; }; } // namespace Model diff --git a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/DeletePolicyRequest.cpp b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/DeletePolicyRequest.cpp index 6bccc6127..5e3847cca 100644 --- a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/DeletePolicyRequest.cpp +++ b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-iam/source/model/DeletePolicyRequest.cpp @@ -11,7 +11,7 @@ using namespace Aws::IAM::Model; using namespace Aws::Utils; DeletePolicyRequest::DeletePolicyRequest() : - m_policyArnHasBeenSet(false) + m_policyNameHasBeenSet(false) { } @@ -19,9 +19,9 @@ Aws::String DeletePolicyRequest::SerializePayload() const { Aws::StringStream ss; ss << "Action=DeletePolicy&"; - if(m_policyArnHasBeenSet) + if(m_policyNameHasBeenSet) { - ss << "PolicyArn=" << StringUtils::URLEncode(m_policyArn.c_str()) << "&"; + ss << "PolicyName=" << StringUtils::URLEncode(m_policyName.c_str()) << "&"; } ss << "Version=2010-05-08"; diff --git a/delete_policy.cpp b/delete_policy.cpp new file mode 100644 index 000000000..623441c81 --- /dev/null +++ b/delete_policy.cpp @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Aws::IAM; +using namespace Aws::IAM::Model; +using namespace Aws::Utils; + + +int main(int argc, char** argv) +{ + Aws::SDKOptions options; + options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace; + InitAPI(options); + + Aws::IAM::IAMClient iamClient = sugonGetIAMClient("Zv33LRIEIjMOOBXX9JmwJlfc048sfUtY", "wikiydsg0u0vmsl0tvaplkkuhh0rhgnf", "http://10.20.0.81:20482"); + + Aws::IAM::Model::DeletePolicyRequest request; + + request.SetPolicyName("C_policy1"); + + DeletePolicyOutcome outcome = iamClient.DeletePolicy(request); + + if (!outcome.IsSuccess()) + { + const Aws::IAM::IAMError &err = outcome.GetError(); + std::cerr << "Error: DeletePolicy: " << + err.GetExceptionName() << ": " << err.GetMessage() << std::endl; + } + else + { + ; + } + + std::cout << "success" << std::endl; + + Aws::ShutdownAPI(options); + + return 0; +} diff --git a/get_policy.cpp b/get_policy.cpp index f793ad6fd..d741f8929 100644 --- a/get_policy.cpp +++ b/get_policy.cpp @@ -29,7 +29,7 @@ int main(int argc, char** argv) if (!outcome.IsSuccess()) { const Aws::IAM::IAMError &err = outcome.GetError(); - std::cerr << "Error: CreatePolicy: " << + std::cerr << "Error: GetPolicy: " << err.GetExceptionName() << ": " << err.GetMessage() << std::endl; } else diff --git a/list_policy.cpp b/list_policy.cpp new file mode 100644 index 000000000..5b7b9d8e2 --- /dev/null +++ b/list_policy.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Aws::IAM; +using namespace Aws::IAM::Model; +using namespace Aws::Utils; + + +int main(int argc, char** argv) +{ + Aws::SDKOptions options; + options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace; + InitAPI(options); + + Aws::IAM::IAMClient iamClient = sugonGetIAMClient("Zv33LRIEIjMOOBXX9JmwJlfc048sfUtY", "wikiydsg0u0vmsl0tvaplkkuhh0rhgnf", "http://10.20.0.81:20482"); + + Aws::IAM::Model::ListPoliciesRequest request; + + request.SetOnlyAttached(false); + request.SetMaxItems(100); + + ListPoliciesOutcome outcome = iamClient.ListPolicies(request); + + if (!outcome.IsSuccess()) + { + const Aws::IAM::IAMError &err = outcome.GetError(); + std::cerr << "Error: ListPolicies: " << + err.GetExceptionName() << ": " << err.GetMessage() << std::endl; + } + else + { + Aws::Vector policies= outcome.GetResult().GetPolicies(); + for (int i = 0; i < policies.size(); i++) { + std::cout< Date: Wed, 22 Nov 2023 16:31:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E4=BA=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/model/BucketOSCPConfiguration.cpp | 92 ++++++++++++------- .../source/model/LifecycleRuleFilter.cpp | 65 +++++++++---- 2 files changed, 108 insertions(+), 49 deletions(-) diff --git a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-s3/source/model/BucketOSCPConfiguration.cpp b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-s3/source/model/BucketOSCPConfiguration.cpp index 2e7bb9ad1..f8c67bded 100644 --- a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-s3/source/model/BucketOSCPConfiguration.cpp +++ b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-s3/source/model/BucketOSCPConfiguration.cpp @@ -249,18 +249,36 @@ BucketOSCPConfiguration& BucketOSCPConfiguration::operator =(const XmlNode& xmlN m_policyFilterSuffix = Aws::Utils::Xml::DecodeEscapedXmlText(suffixNode.GetText()); m_policyFilterSuffixHasBeenSet = true; } - - XmlNode tagsNode = orNode.FirstChild("Tag"); - if(!tagsNode.IsNull()) - { - XmlNode tagMember = tagsNode; - while(!tagMember.IsNull()) - { - m_policyFiltertags.push_back(tagMember); - tagMember = tagMember.NextNode("Tag"); - } - m_policyFiltertagsHasBeenSet = true; - } + + XmlNode tagAndNode = orNode.FirstChild("And"); + if(!tagAndNode.IsNull()) + { + XmlNode tagsNode = tagAndNode.FirstChild("Tag"); + if(!tagsNode.IsNull()) + { + XmlNode tagMember = tagsNode; + while(!tagMember.IsNull()) + { + m_policyFiltertags.push_back(tagMember); + tagMember = tagMember.NextNode("Tag"); + } + m_policyFiltertagsHasBeenSet = true; + } + } + else + { + XmlNode tagsNode = orNode.FirstChild("Tag"); + if(!tagsNode.IsNull()) + { + XmlNode tagMember = tagsNode; + while(!tagMember.IsNull()) + { + m_policyFiltertags.push_back(tagMember); + tagMember = tagMember.NextNode("Tag"); + } + m_policyFiltertagsHasBeenSet = true; + } + } XmlNode suffixNotMatchNode = orNode.FirstChild("SuffixNotMatch"); if(!suffixNotMatchNode.IsNull()) @@ -363,17 +381,17 @@ BucketOSCPConfiguration& BucketOSCPConfiguration::operator =(const XmlNode& xmlN m_policyFilterSuffixHasBeenSet = true; } - XmlNode tagsNode = filterNode.FirstChild("Tag"); - if(!tagsNode.IsNull()) - { - XmlNode tagMember = tagsNode; - while(!tagMember.IsNull()) - { - m_policyFiltertags.push_back(tagMember); - tagMember = tagMember.NextNode("Tag"); - } - m_policyFiltertagsHasBeenSet = true; - } + XmlNode tagsNode = filterNode.FirstChild("Tag"); + if(!tagsNode.IsNull()) + { + XmlNode tagMember = tagsNode; + while(!tagMember.IsNull()) + { + m_policyFiltertags.push_back(tagMember); + tagMember = tagMember.NextNode("Tag"); + } + m_policyFiltertagsHasBeenSet = true; + } XmlNode suffixNotMatchNode = filterNode.FirstChild("SuffixNotMatch"); if(!suffixNotMatchNode.IsNull()) @@ -567,14 +585,26 @@ void BucketOSCPConfiguration::AddToNode(XmlNode& parentNode) const ObjectSizeGreaterThanNode.SetText(m_policyFilterObjectSizeGreaterThan); } - if(m_policyFiltertagsHasBeenSet) - { - for(const auto& item : m_policyFiltertags) - { - XmlNode tagsNode = parentNode.CreateChildElement("Tag"); - item.AddToNode(tagsNode); - } - } + if(m_policyFiltertagsHasBeenSet) + { + if(m_policyOrHasBeenSet && m_policyFiltertags.size() > 1) + { + XmlNode tagAndNode = parentNode.CreateChildElement("And"); + for(const auto& item : m_policyFiltertags) + { + XmlNode tagsNode = tagAndNode.CreateChildElement("Tag"); + item.AddToNode(tagsNode); + } + } + else + { + for(const auto& item : m_policyFiltertags) + { + XmlNode tagsNode = parentNode.CreateChildElement("Tag"); + item.AddToNode(tagsNode); + } + } + } if(m_policyFilterUserMetadataKeyHasBeenSet || m_policyFilterUserMetadataValueHasBeenSet) { diff --git a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-s3/source/model/LifecycleRuleFilter.cpp b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-s3/source/model/LifecycleRuleFilter.cpp index bbddb3423..3c0e6b108 100644 --- a/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-s3/source/model/LifecycleRuleFilter.cpp +++ b/aws-sdk-cpp-1.8.183/aws-sdk-cpp-1.8.183/aws-cpp-sdk-s3/source/model/LifecycleRuleFilter.cpp @@ -159,19 +159,36 @@ LifecycleRuleFilter& LifecycleRuleFilter::operator =(const XmlNode& xmlNode) m_objectSizeBetweenEndHasBeenSet = true; } } - - XmlNode tagsNode = resultNode.FirstChild("Tag"); - if(!tagsNode.IsNull()) - { - XmlNode tagMember = tagsNode; - while(!tagMember.IsNull()) - { - m_tags.push_back(tagMember); - tagMember = tagMember.NextNode("Tag"); - } - m_tagsHasBeenSet = true; - } - + + XmlNode tagAndNode = resultNode.FirstChild("And"); + if(!tagAndNode.IsNull()) + { + XmlNode tagsNode = tagAndNode.FirstChild("Tag"); + if(!tagsNode.IsNull()) + { + XmlNode tagMember = tagsNode; + while(!tagMember.IsNull()) + { + m_tags.push_back(tagMember); + tagMember = tagMember.NextNode("Tag"); + } + m_tagsHasBeenSet = true; + } + } + else + { + XmlNode tagsNode = resultNode.FirstChild("Tag"); + if(!tagsNode.IsNull()) + { + XmlNode tagMember = tagsNode; + while(!tagMember.IsNull()) + { + m_tags.push_back(tagMember); + tagMember = tagMember.NextNode("Tag"); + } + m_tagsHasBeenSet = true; + } + } } @@ -260,11 +277,23 @@ void LifecycleRuleFilter::AddToNode(XmlNode& parentNode) const if(m_tagsHasBeenSet) { - for(const auto& item : m_tags) - { - XmlNode tagsNode = parentNode.CreateChildElement("Tag"); - item.AddToNode(tagsNode); - } + if(m_isOrHasBeenSet && m_tags.size() > 1) + { + XmlNode tagAndNode = parentNode.CreateChildElement("And"); + for(const auto& item : m_tags) + { + XmlNode tagsNode = tagAndNode.CreateChildElement("Tag"); + item.AddToNode(tagsNode); + } + } + else + { + for(const auto& item : m_tags) + { + XmlNode tagsNode = parentNode.CreateChildElement("Tag"); + item.AddToNode(tagsNode); + } + } } } -- Gitee