diff --git a/VERSION b/VERSION index 8e5c2bafa..405d4e697 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.1484 \ No newline at end of file +1.36.1485 \ No newline at end of file diff --git a/cloud-siem/CMakeLists.txt b/cloud-siem/CMakeLists.txt new file mode 100644 index 000000000..2c7146ce0 --- /dev/null +++ b/cloud-siem/CMakeLists.txt @@ -0,0 +1,94 @@ +# +# Copyright 2009-2017 Alibaba Cloud All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include) + +set(cloud-siem_public_header + include/alibabacloud/cloud-siem/Cloud_siemClient.h + include/alibabacloud/cloud-siem/Cloud_siemExport.h ) + +set(cloud-siem_public_header_model + include/alibabacloud/cloud-siem/model/BatchJobCheckRequest.h + include/alibabacloud/cloud-siem/model/BatchJobCheckResult.h + include/alibabacloud/cloud-siem/model/BatchJobSubmitRequest.h + include/alibabacloud/cloud-siem/model/BatchJobSubmitResult.h + include/alibabacloud/cloud-siem/model/SendMessageRequest.h + include/alibabacloud/cloud-siem/model/SendMessageResult.h ) + +set(cloud-siem_src + src/Cloud-siemClient.cc + src/model/BatchJobCheckRequest.cc + src/model/BatchJobCheckResult.cc + src/model/BatchJobSubmitRequest.cc + src/model/BatchJobSubmitResult.cc + src/model/SendMessageRequest.cc + src/model/SendMessageResult.cc ) + +add_library(cloud-siem ${LIB_TYPE} + ${cloud-siem_public_header} + ${cloud-siem_public_header_model} + ${cloud-siem_src}) + +set_target_properties(cloud-siem + PROPERTIES + LINKER_LANGUAGE CXX + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}cloud-siem + ) + +if(${LIB_TYPE} STREQUAL "SHARED") + set_target_properties(cloud-siem + PROPERTIES + DEFINE_SYMBOL ALIBABACLOUD_CLOUD_SIEM_LIBRARY) +endif() + +target_include_directories(cloud-siem + PRIVATE include + ${CMAKE_SOURCE_DIR}/core/include + ) +target_link_libraries(cloud-siem + core) + +if(CMAKE_HOST_WIN32) + ExternalProject_Get_Property(jsoncpp INSTALL_DIR) + set(jsoncpp_install_dir ${INSTALL_DIR}) + add_dependencies(cloud-siem + jsoncpp) + target_include_directories(cloud-siem + PRIVATE ${jsoncpp_install_dir}/include) + target_link_libraries(cloud-siem + ${jsoncpp_install_dir}/lib/jsoncpp.lib) + set_target_properties(cloud-siem + PROPERTIES + COMPILE_OPTIONS "/bigobj") +else() + target_include_directories(cloud-siem + PRIVATE /usr/include/jsoncpp) + target_link_libraries(cloud-siem + jsoncpp) +endif() + +install(FILES ${cloud-siem_public_header} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/cloud-siem) +install(FILES ${cloud-siem_public_header_model} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/cloud-siem/model) +install(TARGETS cloud-siem + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) \ No newline at end of file diff --git a/cloud-siem/include/alibabacloud/cloud-siem/Cloud_siemClient.h b/cloud-siem/include/alibabacloud/cloud-siem/Cloud_siemClient.h new file mode 100644 index 000000000..f2e04be15 --- /dev/null +++ b/cloud-siem/include/alibabacloud/cloud-siem/Cloud_siemClient.h @@ -0,0 +1,70 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_CLOUD_SIEM_CLOUD_SIEMCLIENT_H_ +#define ALIBABACLOUD_CLOUD_SIEM_CLOUD_SIEMCLIENT_H_ + +#include +#include +#include +#include +#include "Cloud_siemExport.h" +#include "model/BatchJobCheckRequest.h" +#include "model/BatchJobCheckResult.h" +#include "model/BatchJobSubmitRequest.h" +#include "model/BatchJobSubmitResult.h" +#include "model/SendMessageRequest.h" +#include "model/SendMessageResult.h" + + +namespace AlibabaCloud +{ + namespace Cloud_siem + { + class ALIBABACLOUD_CLOUD_SIEM_EXPORT Cloud_siemClient : public RpcServiceClient + { + public: + typedef Outcome BatchJobCheckOutcome; + typedef std::future BatchJobCheckOutcomeCallable; + typedef std::function&)> BatchJobCheckAsyncHandler; + typedef Outcome BatchJobSubmitOutcome; + typedef std::future BatchJobSubmitOutcomeCallable; + typedef std::function&)> BatchJobSubmitAsyncHandler; + typedef Outcome SendMessageOutcome; + typedef std::future SendMessageOutcomeCallable; + typedef std::function&)> SendMessageAsyncHandler; + + Cloud_siemClient(const Credentials &credentials, const ClientConfiguration &configuration); + Cloud_siemClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); + Cloud_siemClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); + ~Cloud_siemClient(); + BatchJobCheckOutcome batchJobCheck(const Model::BatchJobCheckRequest &request)const; + void batchJobCheckAsync(const Model::BatchJobCheckRequest& request, const BatchJobCheckAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + BatchJobCheckOutcomeCallable batchJobCheckCallable(const Model::BatchJobCheckRequest& request) const; + BatchJobSubmitOutcome batchJobSubmit(const Model::BatchJobSubmitRequest &request)const; + void batchJobSubmitAsync(const Model::BatchJobSubmitRequest& request, const BatchJobSubmitAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + BatchJobSubmitOutcomeCallable batchJobSubmitCallable(const Model::BatchJobSubmitRequest& request) const; + SendMessageOutcome sendMessage(const Model::SendMessageRequest &request)const; + void sendMessageAsync(const Model::SendMessageRequest& request, const SendMessageAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + SendMessageOutcomeCallable sendMessageCallable(const Model::SendMessageRequest& request) const; + + private: + std::shared_ptr endpointProvider_; + }; + } +} + +#endif // !ALIBABACLOUD_CLOUD_SIEM_CLOUD_SIEMCLIENT_H_ diff --git a/cloud-siem/include/alibabacloud/cloud-siem/Cloud_siemExport.h b/cloud-siem/include/alibabacloud/cloud-siem/Cloud_siemExport.h new file mode 100644 index 000000000..8aecc9b3c --- /dev/null +++ b/cloud-siem/include/alibabacloud/cloud-siem/Cloud_siemExport.h @@ -0,0 +1,32 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_CLOUD_SIEM_CLOUD_SIEMEXPORT_H_ +#define ALIBABACLOUD_CLOUD_SIEM_CLOUD_SIEMEXPORT_H_ + +#include + +#if defined(ALIBABACLOUD_SHARED) +# if defined(ALIBABACLOUD_CLOUD_SIEM_LIBRARY) +# define ALIBABACLOUD_CLOUD_SIEM_EXPORT ALIBABACLOUD_DECL_EXPORT +# else +# define ALIBABACLOUD_CLOUD_SIEM_EXPORT ALIBABACLOUD_DECL_IMPORT +# endif +#else +# define ALIBABACLOUD_CLOUD_SIEM_EXPORT +#endif + +#endif // !ALIBABACLOUD_CLOUD_SIEM_CLOUD_SIEMEXPORT_H_ \ No newline at end of file diff --git a/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobCheckRequest.h b/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobCheckRequest.h new file mode 100644 index 000000000..0428966d9 --- /dev/null +++ b/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobCheckRequest.h @@ -0,0 +1,45 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBCHECKREQUEST_H_ +#define ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBCHECKREQUEST_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud { +namespace Cloud_siem { +namespace Model { +class ALIBABACLOUD_CLOUD_SIEM_EXPORT BatchJobCheckRequest : public RpcServiceRequest { +public: + BatchJobCheckRequest(); + ~BatchJobCheckRequest(); + std::string getRegionId() const; + void setRegionId(const std::string ®ionId); + std::string getSubmitId() const; + void setSubmitId(const std::string &submitId); + +private: + std::string regionId_; + std::string submitId_; +}; +} // namespace Model +} // namespace Cloud_siem +} // namespace AlibabaCloud +#endif // !ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBCHECKREQUEST_H_ diff --git a/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobCheckResult.h b/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobCheckResult.h new file mode 100644 index 000000000..4dfa9bc48 --- /dev/null +++ b/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobCheckResult.h @@ -0,0 +1,88 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBCHECKRESULT_H_ +#define ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBCHECKRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Cloud_siem + { + namespace Model + { + class ALIBABACLOUD_CLOUD_SIEM_EXPORT BatchJobCheckResult : public ServiceResult + { + public: + struct Data + { + struct ErrTaskListItem + { + struct ProductListItem + { + struct LogListItem + { + std::string projectNamePattern; + std::string regionCode; + std::string logStoreNamePattern; + std::string productCode; + std::string errorCode; + std::string logCode; + }; + std::vector logList; + std::string productCode; + }; + std::vector productList; + long userId; + }; + int taskCount; + int finishCount; + int failedCount; + std::string configId; + std::string folderId; + std::string taskStatus; + std::vector errTaskList; + }; + + + BatchJobCheckResult(); + explicit BatchJobCheckResult(const std::string &payload); + ~BatchJobCheckResult(); + std::string getMessage()const; + Data getData()const; + int getCode()const; + bool getSuccess()const; + std::string getErrCode()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + Data data_; + int code_; + bool success_; + std::string errCode_; + + }; + } + } +} +#endif // !ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBCHECKRESULT_H_ \ No newline at end of file diff --git a/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobSubmitRequest.h b/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobSubmitRequest.h new file mode 100644 index 000000000..b43e7e680 --- /dev/null +++ b/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobSubmitRequest.h @@ -0,0 +1,45 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBSUBMITREQUEST_H_ +#define ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBSUBMITREQUEST_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud { +namespace Cloud_siem { +namespace Model { +class ALIBABACLOUD_CLOUD_SIEM_EXPORT BatchJobSubmitRequest : public RpcServiceRequest { +public: + BatchJobSubmitRequest(); + ~BatchJobSubmitRequest(); + std::string getRegionId() const; + void setRegionId(const std::string ®ionId); + std::string getJsonConfig() const; + void setJsonConfig(const std::string &jsonConfig); + +private: + std::string regionId_; + std::string jsonConfig_; +}; +} // namespace Model +} // namespace Cloud_siem +} // namespace AlibabaCloud +#endif // !ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBSUBMITREQUEST_H_ diff --git a/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobSubmitResult.h b/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobSubmitResult.h new file mode 100644 index 000000000..62b5f6e6c --- /dev/null +++ b/cloud-siem/include/alibabacloud/cloud-siem/model/BatchJobSubmitResult.h @@ -0,0 +1,85 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBSUBMITRESULT_H_ +#define ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBSUBMITRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Cloud_siem + { + namespace Model + { + class ALIBABACLOUD_CLOUD_SIEM_EXPORT BatchJobSubmitResult : public ServiceResult + { + public: + struct Data + { + struct ConfigListItem + { + struct ProductListItem + { + struct LogListItem + { + std::string projectNamePattern; + std::string regionCode; + std::string logStoreNamePattern; + std::string productCode; + std::string errorCode; + std::string logCode; + }; + std::vector logList; + std::string productCode; + }; + std::vector productList; + long userId; + }; + std::string submitId; + int taskCount; + std::string configId; + std::vector configList; + }; + + + BatchJobSubmitResult(); + explicit BatchJobSubmitResult(const std::string &payload); + ~BatchJobSubmitResult(); + std::string getMessage()const; + Data getData()const; + int getCode()const; + bool getSuccess()const; + std::string getErrCode()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + Data data_; + int code_; + bool success_; + std::string errCode_; + + }; + } + } +} +#endif // !ALIBABACLOUD_CLOUD_SIEM_MODEL_BATCHJOBSUBMITRESULT_H_ \ No newline at end of file diff --git a/cloud-siem/include/alibabacloud/cloud-siem/model/SendMessageRequest.h b/cloud-siem/include/alibabacloud/cloud-siem/model/SendMessageRequest.h new file mode 100644 index 000000000..f371939bd --- /dev/null +++ b/cloud-siem/include/alibabacloud/cloud-siem/model/SendMessageRequest.h @@ -0,0 +1,48 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_CLOUD_SIEM_MODEL_SENDMESSAGEREQUEST_H_ +#define ALIBABACLOUD_CLOUD_SIEM_MODEL_SENDMESSAGEREQUEST_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud { +namespace Cloud_siem { +namespace Model { +class ALIBABACLOUD_CLOUD_SIEM_EXPORT SendMessageRequest : public RpcServiceRequest { +public: + SendMessageRequest(); + ~SendMessageRequest(); + std::string getRegionId() const; + void setRegionId(const std::string ®ionId); + int getChannelType() const; + void setChannelType(int channelType); + long getReceiveUid() const; + void setReceiveUid(long receiveUid); + +private: + std::string regionId_; + int channelType_; + long receiveUid_; +}; +} // namespace Model +} // namespace Cloud_siem +} // namespace AlibabaCloud +#endif // !ALIBABACLOUD_CLOUD_SIEM_MODEL_SENDMESSAGEREQUEST_H_ diff --git a/cloud-siem/include/alibabacloud/cloud-siem/model/SendMessageResult.h b/cloud-siem/include/alibabacloud/cloud-siem/model/SendMessageResult.h new file mode 100644 index 000000000..2d33a5c2e --- /dev/null +++ b/cloud-siem/include/alibabacloud/cloud-siem/model/SendMessageResult.h @@ -0,0 +1,59 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_CLOUD_SIEM_MODEL_SENDMESSAGERESULT_H_ +#define ALIBABACLOUD_CLOUD_SIEM_MODEL_SENDMESSAGERESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Cloud_siem + { + namespace Model + { + class ALIBABACLOUD_CLOUD_SIEM_EXPORT SendMessageResult : public ServiceResult + { + public: + + + SendMessageResult(); + explicit SendMessageResult(const std::string &payload); + ~SendMessageResult(); + std::string getMessage()const; + bool getData()const; + int getCode()const; + bool getSuccess()const; + std::string getErrCode()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + bool data_; + int code_; + bool success_; + std::string errCode_; + + }; + } + } +} +#endif // !ALIBABACLOUD_CLOUD_SIEM_MODEL_SENDMESSAGERESULT_H_ \ No newline at end of file diff --git a/cloud-siem/src/Cloud-siemClient.cc b/cloud-siem/src/Cloud-siemClient.cc new file mode 100644 index 000000000..446b021f5 --- /dev/null +++ b/cloud-siem/src/Cloud-siemClient.cc @@ -0,0 +1,161 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +using namespace AlibabaCloud; +using namespace AlibabaCloud::Location; +using namespace AlibabaCloud::Cloud_siem; +using namespace AlibabaCloud::Cloud_siem::Model; + +namespace +{ + const std::string SERVICE_NAME = "cloud-siem"; +} + +Cloud_siemClient::Cloud_siemClient(const Credentials &credentials, const ClientConfiguration &configuration) : + RpcServiceClient(SERVICE_NAME, std::make_shared(credentials), configuration) +{ + auto locationClient = std::make_shared(credentials, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "cloud-siem"); +} + +Cloud_siemClient::Cloud_siemClient(const std::shared_ptr& credentialsProvider, const ClientConfiguration & configuration) : + RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) +{ + auto locationClient = std::make_shared(credentialsProvider, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "cloud-siem"); +} + +Cloud_siemClient::Cloud_siemClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) : + RpcServiceClient(SERVICE_NAME, std::make_shared(accessKeyId, accessKeySecret), configuration) +{ + auto locationClient = std::make_shared(accessKeyId, accessKeySecret, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "cloud-siem"); +} + +Cloud_siemClient::~Cloud_siemClient() +{} + +Cloud_siemClient::BatchJobCheckOutcome Cloud_siemClient::batchJobCheck(const BatchJobCheckRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return BatchJobCheckOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return BatchJobCheckOutcome(BatchJobCheckResult(outcome.result())); + else + return BatchJobCheckOutcome(outcome.error()); +} + +void Cloud_siemClient::batchJobCheckAsync(const BatchJobCheckRequest& request, const BatchJobCheckAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, batchJobCheck(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +Cloud_siemClient::BatchJobCheckOutcomeCallable Cloud_siemClient::batchJobCheckCallable(const BatchJobCheckRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->batchJobCheck(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + +Cloud_siemClient::BatchJobSubmitOutcome Cloud_siemClient::batchJobSubmit(const BatchJobSubmitRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return BatchJobSubmitOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return BatchJobSubmitOutcome(BatchJobSubmitResult(outcome.result())); + else + return BatchJobSubmitOutcome(outcome.error()); +} + +void Cloud_siemClient::batchJobSubmitAsync(const BatchJobSubmitRequest& request, const BatchJobSubmitAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, batchJobSubmit(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +Cloud_siemClient::BatchJobSubmitOutcomeCallable Cloud_siemClient::batchJobSubmitCallable(const BatchJobSubmitRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->batchJobSubmit(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + +Cloud_siemClient::SendMessageOutcome Cloud_siemClient::sendMessage(const SendMessageRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return SendMessageOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return SendMessageOutcome(SendMessageResult(outcome.result())); + else + return SendMessageOutcome(outcome.error()); +} + +void Cloud_siemClient::sendMessageAsync(const SendMessageRequest& request, const SendMessageAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, sendMessage(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +Cloud_siemClient::SendMessageOutcomeCallable Cloud_siemClient::sendMessageCallable(const SendMessageRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->sendMessage(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/cloud-siem/src/model/BatchJobCheckRequest.cc b/cloud-siem/src/model/BatchJobCheckRequest.cc new file mode 100644 index 000000000..a43307940 --- /dev/null +++ b/cloud-siem/src/model/BatchJobCheckRequest.cc @@ -0,0 +1,45 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +using AlibabaCloud::Cloud_siem::Model::BatchJobCheckRequest; + +BatchJobCheckRequest::BatchJobCheckRequest() + : RpcServiceRequest("cloud-siem", "2022-06-16", "BatchJobCheck") { + setMethod(HttpRequest::Method::Post); +} + +BatchJobCheckRequest::~BatchJobCheckRequest() {} + +std::string BatchJobCheckRequest::getRegionId() const { + return regionId_; +} + +void BatchJobCheckRequest::setRegionId(const std::string ®ionId) { + regionId_ = regionId; + setBodyParameter(std::string("RegionId"), regionId); +} + +std::string BatchJobCheckRequest::getSubmitId() const { + return submitId_; +} + +void BatchJobCheckRequest::setSubmitId(const std::string &submitId) { + submitId_ = submitId; + setBodyParameter(std::string("SubmitId"), submitId); +} + diff --git a/cloud-siem/src/model/BatchJobCheckResult.cc b/cloud-siem/src/model/BatchJobCheckResult.cc new file mode 100644 index 000000000..b877f0bc3 --- /dev/null +++ b/cloud-siem/src/model/BatchJobCheckResult.cc @@ -0,0 +1,124 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +using namespace AlibabaCloud::Cloud_siem; +using namespace AlibabaCloud::Cloud_siem::Model; + +BatchJobCheckResult::BatchJobCheckResult() : + ServiceResult() +{} + +BatchJobCheckResult::BatchJobCheckResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +BatchJobCheckResult::~BatchJobCheckResult() +{} + +void BatchJobCheckResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + auto dataNode = value["Data"]; + if(!dataNode["TaskCount"].isNull()) + data_.taskCount = std::stoi(dataNode["TaskCount"].asString()); + if(!dataNode["FinishCount"].isNull()) + data_.finishCount = std::stoi(dataNode["FinishCount"].asString()); + if(!dataNode["FailedCount"].isNull()) + data_.failedCount = std::stoi(dataNode["FailedCount"].asString()); + if(!dataNode["TaskStatus"].isNull()) + data_.taskStatus = dataNode["TaskStatus"].asString(); + if(!dataNode["ConfigId"].isNull()) + data_.configId = dataNode["ConfigId"].asString(); + if(!dataNode["FolderId"].isNull()) + data_.folderId = dataNode["FolderId"].asString(); + auto allErrTaskListNode = dataNode["ErrTaskList"]["ErrTaskListItem"]; + for (auto dataNodeErrTaskListErrTaskListItem : allErrTaskListNode) + { + Data::ErrTaskListItem errTaskListItemObject; + if(!dataNodeErrTaskListErrTaskListItem["UserId"].isNull()) + errTaskListItemObject.userId = std::stol(dataNodeErrTaskListErrTaskListItem["UserId"].asString()); + auto allProductListNode = dataNodeErrTaskListErrTaskListItem["ProductList"]["ProductListItem"]; + for (auto dataNodeErrTaskListErrTaskListItemProductListProductListItem : allProductListNode) + { + Data::ErrTaskListItem::ProductListItem productListObject; + if(!dataNodeErrTaskListErrTaskListItemProductListProductListItem["ProductCode"].isNull()) + productListObject.productCode = dataNodeErrTaskListErrTaskListItemProductListProductListItem["ProductCode"].asString(); + auto allLogListNode = dataNodeErrTaskListErrTaskListItemProductListProductListItem["LogList"]["LogListItem"]; + for (auto dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem : allLogListNode) + { + Data::ErrTaskListItem::ProductListItem::LogListItem logListObject; + if(!dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["ProductCode"].isNull()) + logListObject.productCode = dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["ProductCode"].asString(); + if(!dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["LogCode"].isNull()) + logListObject.logCode = dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["LogCode"].asString(); + if(!dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["RegionCode"].isNull()) + logListObject.regionCode = dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["RegionCode"].asString(); + if(!dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["ProjectNamePattern"].isNull()) + logListObject.projectNamePattern = dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["ProjectNamePattern"].asString(); + if(!dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["LogStoreNamePattern"].isNull()) + logListObject.logStoreNamePattern = dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["LogStoreNamePattern"].asString(); + if(!dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["ErrorCode"].isNull()) + logListObject.errorCode = dataNodeErrTaskListErrTaskListItemProductListProductListItemLogListLogListItem["ErrorCode"].asString(); + productListObject.logList.push_back(logListObject); + } + errTaskListItemObject.productList.push_back(productListObject); + } + data_.errTaskList.push_back(errTaskListItemObject); + } + if(!value["Success"].isNull()) + success_ = value["Success"].asString() == "true"; + if(!value["Code"].isNull()) + code_ = std::stoi(value["Code"].asString()); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + if(!value["ErrCode"].isNull()) + errCode_ = value["ErrCode"].asString(); + +} + +std::string BatchJobCheckResult::getMessage()const +{ + return message_; +} + +BatchJobCheckResult::Data BatchJobCheckResult::getData()const +{ + return data_; +} + +int BatchJobCheckResult::getCode()const +{ + return code_; +} + +bool BatchJobCheckResult::getSuccess()const +{ + return success_; +} + +std::string BatchJobCheckResult::getErrCode()const +{ + return errCode_; +} + diff --git a/cloud-siem/src/model/BatchJobSubmitRequest.cc b/cloud-siem/src/model/BatchJobSubmitRequest.cc new file mode 100644 index 000000000..7b74489e2 --- /dev/null +++ b/cloud-siem/src/model/BatchJobSubmitRequest.cc @@ -0,0 +1,45 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +using AlibabaCloud::Cloud_siem::Model::BatchJobSubmitRequest; + +BatchJobSubmitRequest::BatchJobSubmitRequest() + : RpcServiceRequest("cloud-siem", "2022-06-16", "BatchJobSubmit") { + setMethod(HttpRequest::Method::Post); +} + +BatchJobSubmitRequest::~BatchJobSubmitRequest() {} + +std::string BatchJobSubmitRequest::getRegionId() const { + return regionId_; +} + +void BatchJobSubmitRequest::setRegionId(const std::string ®ionId) { + regionId_ = regionId; + setBodyParameter(std::string("RegionId"), regionId); +} + +std::string BatchJobSubmitRequest::getJsonConfig() const { + return jsonConfig_; +} + +void BatchJobSubmitRequest::setJsonConfig(const std::string &jsonConfig) { + jsonConfig_ = jsonConfig; + setBodyParameter(std::string("JsonConfig"), jsonConfig); +} + diff --git a/cloud-siem/src/model/BatchJobSubmitResult.cc b/cloud-siem/src/model/BatchJobSubmitResult.cc new file mode 100644 index 000000000..521e6cb4f --- /dev/null +++ b/cloud-siem/src/model/BatchJobSubmitResult.cc @@ -0,0 +1,118 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +using namespace AlibabaCloud::Cloud_siem; +using namespace AlibabaCloud::Cloud_siem::Model; + +BatchJobSubmitResult::BatchJobSubmitResult() : + ServiceResult() +{} + +BatchJobSubmitResult::BatchJobSubmitResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +BatchJobSubmitResult::~BatchJobSubmitResult() +{} + +void BatchJobSubmitResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + auto dataNode = value["Data"]; + if(!dataNode["SubmitId"].isNull()) + data_.submitId = dataNode["SubmitId"].asString(); + if(!dataNode["TaskCount"].isNull()) + data_.taskCount = std::stoi(dataNode["TaskCount"].asString()); + if(!dataNode["ConfigId"].isNull()) + data_.configId = dataNode["ConfigId"].asString(); + auto allConfigListNode = dataNode["ConfigList"]["ConfigListItem"]; + for (auto dataNodeConfigListConfigListItem : allConfigListNode) + { + Data::ConfigListItem configListItemObject; + if(!dataNodeConfigListConfigListItem["UserId"].isNull()) + configListItemObject.userId = std::stol(dataNodeConfigListConfigListItem["UserId"].asString()); + auto allProductListNode = dataNodeConfigListConfigListItem["ProductList"]["ProductListItem"]; + for (auto dataNodeConfigListConfigListItemProductListProductListItem : allProductListNode) + { + Data::ConfigListItem::ProductListItem productListObject; + if(!dataNodeConfigListConfigListItemProductListProductListItem["ProductCode"].isNull()) + productListObject.productCode = dataNodeConfigListConfigListItemProductListProductListItem["ProductCode"].asString(); + auto allLogListNode = dataNodeConfigListConfigListItemProductListProductListItem["LogList"]["LogListItem"]; + for (auto dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem : allLogListNode) + { + Data::ConfigListItem::ProductListItem::LogListItem logListObject; + if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ProductCode"].isNull()) + logListObject.productCode = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ProductCode"].asString(); + if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["LogCode"].isNull()) + logListObject.logCode = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["LogCode"].asString(); + if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["RegionCode"].isNull()) + logListObject.regionCode = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["RegionCode"].asString(); + if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ProjectNamePattern"].isNull()) + logListObject.projectNamePattern = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ProjectNamePattern"].asString(); + if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["LogStoreNamePattern"].isNull()) + logListObject.logStoreNamePattern = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["LogStoreNamePattern"].asString(); + if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ErrorCode"].isNull()) + logListObject.errorCode = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ErrorCode"].asString(); + productListObject.logList.push_back(logListObject); + } + configListItemObject.productList.push_back(productListObject); + } + data_.configList.push_back(configListItemObject); + } + if(!value["Success"].isNull()) + success_ = value["Success"].asString() == "true"; + if(!value["Code"].isNull()) + code_ = std::stoi(value["Code"].asString()); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + if(!value["ErrCode"].isNull()) + errCode_ = value["ErrCode"].asString(); + +} + +std::string BatchJobSubmitResult::getMessage()const +{ + return message_; +} + +BatchJobSubmitResult::Data BatchJobSubmitResult::getData()const +{ + return data_; +} + +int BatchJobSubmitResult::getCode()const +{ + return code_; +} + +bool BatchJobSubmitResult::getSuccess()const +{ + return success_; +} + +std::string BatchJobSubmitResult::getErrCode()const +{ + return errCode_; +} + diff --git a/cloud-siem/src/model/SendMessageRequest.cc b/cloud-siem/src/model/SendMessageRequest.cc new file mode 100644 index 000000000..6866bb783 --- /dev/null +++ b/cloud-siem/src/model/SendMessageRequest.cc @@ -0,0 +1,54 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +using AlibabaCloud::Cloud_siem::Model::SendMessageRequest; + +SendMessageRequest::SendMessageRequest() + : RpcServiceRequest("cloud-siem", "2022-06-16", "SendMessage") { + setMethod(HttpRequest::Method::Post); +} + +SendMessageRequest::~SendMessageRequest() {} + +std::string SendMessageRequest::getRegionId() const { + return regionId_; +} + +void SendMessageRequest::setRegionId(const std::string ®ionId) { + regionId_ = regionId; + setBodyParameter(std::string("RegionId"), regionId); +} + +int SendMessageRequest::getChannelType() const { + return channelType_; +} + +void SendMessageRequest::setChannelType(int channelType) { + channelType_ = channelType; + setBodyParameter(std::string("ChannelType"), std::to_string(channelType)); +} + +long SendMessageRequest::getReceiveUid() const { + return receiveUid_; +} + +void SendMessageRequest::setReceiveUid(long receiveUid) { + receiveUid_ = receiveUid; + setBodyParameter(std::string("ReceiveUid"), std::to_string(receiveUid)); +} + diff --git a/cloud-siem/src/model/SendMessageResult.cc b/cloud-siem/src/model/SendMessageResult.cc new file mode 100644 index 000000000..2ebd20c62 --- /dev/null +++ b/cloud-siem/src/model/SendMessageResult.cc @@ -0,0 +1,79 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +using namespace AlibabaCloud::Cloud_siem; +using namespace AlibabaCloud::Cloud_siem::Model; + +SendMessageResult::SendMessageResult() : + ServiceResult() +{} + +SendMessageResult::SendMessageResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +SendMessageResult::~SendMessageResult() +{} + +void SendMessageResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + if(!value["Data"].isNull()) + data_ = value["Data"].asString() == "true"; + if(!value["Success"].isNull()) + success_ = value["Success"].asString() == "true"; + if(!value["Code"].isNull()) + code_ = std::stoi(value["Code"].asString()); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + if(!value["ErrCode"].isNull()) + errCode_ = value["ErrCode"].asString(); + +} + +std::string SendMessageResult::getMessage()const +{ + return message_; +} + +bool SendMessageResult::getData()const +{ + return data_; +} + +int SendMessageResult::getCode()const +{ + return code_; +} + +bool SendMessageResult::getSuccess()const +{ + return success_; +} + +std::string SendMessageResult::getErrCode()const +{ + return errCode_; +} +