diff --git a/.doc_gen/metadata/codebuild_metadata.yaml b/.doc_gen/metadata/codebuild_metadata.yaml index 308496ab4cf..16622d3b9ca 100644 --- a/.doc_gen/metadata/codebuild_metadata.yaml +++ b/.doc_gen/metadata/codebuild_metadata.yaml @@ -16,3 +16,51 @@ codebuild_CreateProject: - javascript.v3.codebuild.actions.CreateProject services: codebuild: {CreateProject} +codebuild_ListBuilds: + title: List &ACB; builds + title_abbrev: List builds + synopsis: list &ACB; builds. + category: + languages: + C++: + versions: + - sdk_version: 1 + github: cpp/example_code/codebuild + excerpts: + - description: + snippet_tags: + - cpp.example_code.codebuild.ListBuilds + services: + codebuild: {ListBuilds} +codebuild_ListProjects: + title: List &ACB; projects + title_abbrev: List projects + synopsis: list &ACB; projects. + category: + languages: + C++: + versions: + - sdk_version: 1 + github: cpp/example_code/codebuild + excerpts: + - description: + snippet_tags: + - cpp.example_code.codebuild.ListProjects + services: + codebuild: {ListProjects} +codebuild_StartBuild: + title: Start an &ACB; build + title_abbrev: Start a build + synopsis: start an &ACB; build. + category: + languages: + C++: + versions: + - sdk_version: 1 + github: cpp/example_code/codebuild + excerpts: + - description: + snippet_tags: + - cpp.example_code.codebuild.StartBuild + services: + codebuild: {StartBuild} diff --git a/cpp/example_code/codebuild/README.md b/cpp/example_code/codebuild/README.md index 51bd1e263df..fc93cbe9337 100644 --- a/cpp/example_code/codebuild/README.md +++ b/cpp/example_code/codebuild/README.md @@ -37,6 +37,15 @@ Next, for information on code example structures and how to build and run the ex +### Single actions + +Code excerpts that show you how to call individual service functions. + +- [List builds](list_builds.cpp#L25) (`ListBuilds`) +- [List projects](list_projects.cpp#L23) (`ListProjects`) +- [Start a build](start_build.cpp#L22) (`StartBuild`) + + diff --git a/cpp/example_code/codebuild/codebuild_samples.h b/cpp/example_code/codebuild/codebuild_samples.h index f31ace733e2..7faedcd2801 100644 --- a/cpp/example_code/codebuild/codebuild_samples.h +++ b/cpp/example_code/codebuild/codebuild_samples.h @@ -18,7 +18,8 @@ namespace AwsDoc { \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ - bool startBuild(const Aws::String &projectName, const Aws::Client::ClientConfiguration &clientConfiguration); + bool startBuild(const Aws::String &projectName, + const Aws::Client::ClientConfiguration &clientConfiguration); //! List the CodeBuild builds. /*! @@ -26,7 +27,8 @@ namespace AwsDoc { \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ - bool listBuilds(Aws::CodeBuild::Model::SortOrderType sortType, const Aws::Client::ClientConfiguration &clientConfiguration); + bool listBuilds(Aws::CodeBuild::Model::SortOrderType sortType, + const Aws::Client::ClientConfiguration &clientConfiguration); //! List the CodeBuild projects. /*! @@ -34,7 +36,8 @@ namespace AwsDoc { \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ - bool listProjects(Aws::CodeBuild::Model::SortOrderType sortType, const Aws::Client::ClientConfiguration &clientConfiguration); + bool listProjects(Aws::CodeBuild::Model::SortOrderType sortType, + const Aws::Client::ClientConfiguration &clientConfiguration); } // CodeBuild } // AwsDoc diff --git a/cpp/example_code/codebuild/list_builds.cpp b/cpp/example_code/codebuild/list_builds.cpp index 090b73ac7a7..44a0818ef77 100644 --- a/cpp/example_code/codebuild/list_builds.cpp +++ b/cpp/example_code/codebuild/list_builds.cpp @@ -22,15 +22,15 @@ * **/ -// snippet-start:[cpp.example_code.codebuild.StartBuild] +// snippet-start:[cpp.example_code.codebuild.ListBuilds] //! List the CodeBuild builds. /*! \param sortType: 'SortOrderType' type. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ -bool AwsDoc::CodeBuild::listBuilds(Aws::CodeBuild::Model::SortOrderType sortType, const Aws::Client::ClientConfiguration &clientConfiguration) -{ +bool AwsDoc::CodeBuild::listBuilds(Aws::CodeBuild::Model::SortOrderType sortType, + const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::CodeBuild::CodeBuildClient codeBuildClient(clientConfiguration); Aws::CodeBuild::Model::ListBuildsRequest listBuildsRequest; @@ -43,30 +43,34 @@ bool AwsDoc::CodeBuild::listBuilds(Aws::CodeBuild::Model::SortOrderType sortType listBuildsRequest.SetNextToken(nextToken); } - Aws::CodeBuild::Model::ListBuildsOutcome listBuildsOutcome = codeBuildClient.ListBuilds(listBuildsRequest); + Aws::CodeBuild::Model::ListBuildsOutcome listBuildsOutcome = codeBuildClient.ListBuilds( + listBuildsRequest); if (listBuildsOutcome.IsSuccess()) { std::cout << "Information about each build:" << std::endl; Aws::CodeBuild::Model::BatchGetBuildsRequest getBuildsRequest; getBuildsRequest.SetIds(listBuildsOutcome.GetResult().GetIds()); - Aws::CodeBuild::Model::BatchGetBuildsOutcome getBuildsOutcome = codeBuildClient.BatchGetBuilds(getBuildsRequest); + Aws::CodeBuild::Model::BatchGetBuildsOutcome getBuildsOutcome = codeBuildClient.BatchGetBuilds( + getBuildsRequest); if (getBuildsOutcome.IsSuccess()) { - const Aws::Vector& builds = getBuildsOutcome.GetResult().GetBuilds(); + const Aws::Vector &builds = getBuildsOutcome.GetResult().GetBuilds(); std::cout << builds.size() << " build(s) found." << std::endl; for (auto val: builds) { std::cout << val.GetId() << std::endl; } } else { - std::cout << "Error getting builds" << getBuildsOutcome.GetError().GetMessage() << std::endl; + std::cout << "Error getting builds" + << getBuildsOutcome.GetError().GetMessage() << std::endl; return false; } nextToken = listBuildsOutcome.GetResult().GetNextToken(); } else { - std::cerr << "Error listing builds" << listBuildsOutcome.GetError().GetMessage() + std::cerr << "Error listing builds" + << listBuildsOutcome.GetError().GetMessage() << std::endl; return false; } @@ -75,7 +79,7 @@ bool AwsDoc::CodeBuild::listBuilds(Aws::CodeBuild::Model::SortOrderType sortType return true; } -// snippet-end:[cpp.example_code.codebuild.StartBuild] +// snippet-end:[cpp.example_code.codebuild.ListBuilds] /* * diff --git a/cpp/example_code/codebuild/list_projects.cpp b/cpp/example_code/codebuild/list_projects.cpp index d5dbc9d12c2..d854e40126b 100644 --- a/cpp/example_code/codebuild/list_projects.cpp +++ b/cpp/example_code/codebuild/list_projects.cpp @@ -27,7 +27,8 @@ \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ -bool AwsDoc::CodeBuild::listProjects(Aws::CodeBuild::Model::SortOrderType sortType, const Aws::Client::ClientConfiguration &clientConfiguration) { +bool AwsDoc::CodeBuild::listProjects(Aws::CodeBuild::Model::SortOrderType sortType, + const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::CodeBuild::CodeBuildClient codeBuildClient(clientConfiguration); Aws::CodeBuild::Model::ListProjectsRequest listProjectsRequest; @@ -41,11 +42,12 @@ bool AwsDoc::CodeBuild::listProjects(Aws::CodeBuild::Model::SortOrderType sortTy listProjectsRequest.SetNextToken(nextToken); } - Aws::CodeBuild::Model::ListProjectsOutcome outcome = codeBuildClient.ListProjects(listProjectsRequest); + Aws::CodeBuild::Model::ListProjectsOutcome outcome = codeBuildClient.ListProjects( + listProjectsRequest); if (outcome.IsSuccess()) { const Aws::Vector &projects = outcome.GetResult().GetProjects(); - allProjects.insert(allProjects.end(), projects.begin(), projects.end()); + allProjects.insert(allProjects.end(), projects.begin(), projects.end()); nextToken = outcome.GetResult().GetNextToken(); } @@ -55,9 +57,9 @@ bool AwsDoc::CodeBuild::listProjects(Aws::CodeBuild::Model::SortOrderType sortTy } } while (!nextToken.empty()); - + std::cout << allProjects.size() << " project(s) found." << std::endl; - for (auto project : allProjects) { + for (auto project: allProjects) { std::cout << project << std::endl; } diff --git a/cpp/example_code/codebuild/start_build.cpp b/cpp/example_code/codebuild/start_build.cpp index 5195216c52d..eba2a511124 100644 --- a/cpp/example_code/codebuild/start_build.cpp +++ b/cpp/example_code/codebuild/start_build.cpp @@ -26,28 +26,28 @@ \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ -bool AwsDoc::CodeBuild::startBuild(const Aws::String &projectName, const Aws::Client::ClientConfiguration &clientConfiguration) -{ - Aws::CodeBuild::CodeBuildClient codeBuildClient(clientConfiguration); +bool AwsDoc::CodeBuild::startBuild(const Aws::String &projectName, + const Aws::Client::ClientConfiguration &clientConfiguration) { + Aws::CodeBuild::CodeBuildClient codeBuildClient(clientConfiguration); - Aws::CodeBuild::Model::StartBuildRequest startBuildRequest; - startBuildRequest.SetProjectName(projectName); + Aws::CodeBuild::Model::StartBuildRequest startBuildRequest; + startBuildRequest.SetProjectName(projectName); - Aws::CodeBuild::Model::StartBuildOutcome outcome = codeBuildClient.StartBuild(startBuildRequest); + Aws::CodeBuild::Model::StartBuildOutcome outcome = codeBuildClient.StartBuild( + startBuildRequest); - if (outcome.IsSuccess()) - { - std::cout << "Successfully started build" << std::endl; - std::cout << "Build ID: " << outcome.GetResult().GetBuild().GetId() << std::endl; - } + if (outcome.IsSuccess()) { + std::cout << "Successfully started build" << std::endl; + std::cout << "Build ID: " << outcome.GetResult().GetBuild().GetId() + << std::endl; + } - else - { - std::cerr << "Error starting build" << outcome.GetError().GetMessage() - << std::endl; - } + else { + std::cerr << "Error starting build" << outcome.GetError().GetMessage() + << std::endl; + } - return outcome.IsSuccess(); + return outcome.IsSuccess(); } // snippet-end:[cpp.example_code.codebuild.StartBuild] diff --git a/cpp/example_code/codebuild/tests/gtest_list_builds.cpp b/cpp/example_code/codebuild/tests/gtest_list_builds.cpp index 715e8cd200d..154243ebd6c 100644 --- a/cpp/example_code/codebuild/tests/gtest_list_builds.cpp +++ b/cpp/example_code/codebuild/tests/gtest_list_builds.cpp @@ -15,10 +15,11 @@ namespace AwsDocTest { // NOLINTNEXTLINE(readability-named-parameter) - TEST_F(CodeBuild_GTests, list_builds_2_) { + TEST_F(CodeBuild_GTests, list_builds_2_ + ) { - auto result = AwsDoc::CodeBuild::listBuilds( - Aws::CodeBuild::Model::SortOrderType::ASCENDING, *s_clientConfig); - ASSERT_TRUE(result); - } + auto result = AwsDoc::CodeBuild::listBuilds( + Aws::CodeBuild::Model::SortOrderType::ASCENDING, *s_clientConfig); + ASSERT_TRUE(result); +} } // namespace AwsDocTest diff --git a/cpp/example_code/codebuild/tests/gtest_list_projects.cpp b/cpp/example_code/codebuild/tests/gtest_list_projects.cpp index 4648cf94e3a..a414211ff70 100644 --- a/cpp/example_code/codebuild/tests/gtest_list_projects.cpp +++ b/cpp/example_code/codebuild/tests/gtest_list_projects.cpp @@ -15,10 +15,11 @@ namespace AwsDocTest { // NOLINTNEXTLINE(readability-named-parameter) - TEST_F(CodeBuild_GTests, list_projects_2_) { + TEST_F(CodeBuild_GTests, list_projects_2_ + ) { - auto result = AwsDoc::CodeBuild::listProjects( - Aws::CodeBuild::Model::SortOrderType::ASCENDING, *s_clientConfig); - ASSERT_TRUE(result); - } + auto result = AwsDoc::CodeBuild::listProjects( + Aws::CodeBuild::Model::SortOrderType::ASCENDING, *s_clientConfig); + ASSERT_TRUE(result); +} } // namespace AwsDocTest diff --git a/cpp/example_code/codebuild/tests/gtest_start_build.cpp b/cpp/example_code/codebuild/tests/gtest_start_build.cpp index 5e3347c97ef..0a18ca6965d 100644 --- a/cpp/example_code/codebuild/tests/gtest_start_build.cpp +++ b/cpp/example_code/codebuild/tests/gtest_start_build.cpp @@ -15,12 +15,19 @@ namespace AwsDocTest { // NOLINTNEXTLINE(readability-named-parameter) - TEST_F(CodeBuild_GTests, start_build_3_) { - MockHTTP mockHttp; - bool result = mockHttp.addResponseWithBody("mock_input/StartBuild.json"); - ASSERT_TRUE(result) << preconditionError() << std::endl; + TEST_F(CodeBuild_GTests, start_build_3_ + ) { + MockHTTP mockHttp; + bool result = mockHttp.addResponseWithBody("mock_input/StartBuild.json"); + ASSERT_TRUE(result) + << - result = AwsDoc::CodeBuild::startBuild("test-project", *s_clientConfig); - ASSERT_TRUE(result); - } + preconditionError() + + << + std::endl; + + result = AwsDoc::CodeBuild::startBuild("test-project", *s_clientConfig); + ASSERT_TRUE(result); +} } // namespace AwsDocTest