/**
 * Nudr_DataRepository API OpenAPI file
 * Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
 * ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
 *
 * The version of the OpenAPI document: 2.1.2
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator
 * (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
 * the class manually.
 */

#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.h"
#ifdef __linux__
#include <signal.h>
#include <unistd.h>
#include <vector>
#endif

#include "AMF3GPPAccessRegistrationDocumentApiImpl.h"
#include "AMFNon3GPPAccessRegistrationDocumentApiImpl.h"
#include "AccessAndMobilityDataApiImpl.h"
#include "AccessAndMobilityPolicyDataDocumentApiImpl.h"
#include "AccessAndMobilitySubscriptionDataDocumentApiImpl.h"
#include "AmfSubscriptionInfoDocumentApiImpl.h"
#include "ApplicationDataSubscriptionsCollectionApiImpl.h"
#include "AuthenticationSoRDocumentApiImpl.h"
#include "AuthenticationStatusDocumentApiImpl.h"
#include "AuthenticationSubscriptionDocumentApiImpl.h"
#include "AuthenticationUPUDocumentApiImpl.h"
#include "BdtDataStoreApiImpl.h"
#include "BdtPolicyDataStoreApiImpl.h"
#include "CAGACKDocumentApiImpl.h"
#include "CAGUpdateAckDocumentApiImpl.h"
#include "Class5GVNGroupsInternalDocumentApiImpl.h"
#include "Class5GVNGroupsStoreApiImpl.h"
#include "Class5GVnGroupConfigurationDocumentApiImpl.h"
#include "ContextDataDocumentApiImpl.h"
#include "Delete5GVnGroupApiImpl.h"
#include "EnhancedCoverageRestrictionDataApiImpl.h"
#include "EventAMFSubscriptionInfoDocumentApiImpl.h"
#include "EventExposureDataDocumentApiImpl.h"
#include "EventExposureGroupSubscriptionDocumentApiImpl.h"
#include "EventExposureGroupSubscriptionsCollectionApiImpl.h"
#include "EventExposureSubscriptionDocumentApiImpl.h"
#include "EventExposureSubscriptionsCollectionApiImpl.h"
#include "ExposureDataSubscriptionsCollectionApiImpl.h"
#include "GroupIdentifiersApiImpl.h"
#include "IPSMGWRegistrationDocumentApiImpl.h"
#include "IPTVConfigurationDataStoreApiImpl.h"
#include "IndividualApplicationDataSubscriptionDocumentApiImpl.h"
#include "IndividualAppliedBDTPolicyDataDocumentApiImpl.h"
#include "IndividualBDTPolicyDataDocumentApiImpl.h"
#include "IndividualBdtDataDocumentApiImpl.h"
#include "IndividualExposureDataSubscriptionDocumentApiImpl.h"
#include "IndividualIPTVConfigurationDataApiImpl.h"
#include "IndividualIPTVConfigurationDataDocumentApiImpl.h"
#include "IndividualInfluenceDataDocumentApiImpl.h"
#include "IndividualInfluenceDataSubscriptionDocumentApiImpl.h"
#include "IndividualPFDDataDocumentApiImpl.h"
#include "IndividualPolicyDataSubscriptionDocumentApiImpl.h"
#include "InfluenceDataStoreApiImpl.h"
#include "InfluenceDataSubscriptionsCollectionApiImpl.h"
#include "LCSBroadcastAssistanceSubscriptionDataApiImpl.h"
#include "LCSMobileOriginatedSubscriptionDataApiImpl.h"
#include "LCSPrivacySubscriptionDataApiImpl.h"
#include "MessageWaitingDataDocumentApiImpl.h"
#include "Modify5GVnGroupApiImpl.h"
#include "NSSAIACKDocumentApiImpl.h"
#include "NSSAIUpdateAckDocumentApiImpl.h"
#include "OperatorSpecificDataContainerDocumentApiImpl.h"
#include "OperatorSpecificDataDocumentApiImpl.h"
#include "PFDDataStoreApiImpl.h"
#include "ParameterProvisionDocumentApiImpl.h"
#include "PduSessionManagementDataApiImpl.h"
#include "PlmnUePolicySetDocumentApiImpl.h"
#include "PolicyDataSubscriptionsCollectionApiImpl.h"
#include "ProvisionedDataDocumentApiImpl.h"
#include "ProvisionedParameterDataDocumentApiImpl.h"
#include "Query5GVnGroupConfigurationDocumentApiImpl.h"
#include "QueryAMFSubscriptionInfoDocumentApiImpl.h"
#include "QueryIdentityDataBySUPIOrGPSIDocumentApiImpl.h"
#include "QueryNIDDAuthorizationDataGPSIOrExternalGroupIdentifierDocumentApiImpl.h"
#include "QueryODBDataBySUPIOrGPSIDocumentApiImpl.h"
#include "RetrievalOfSharedDataApiImpl.h"
#include "SDMSubscriptionDocumentApiImpl.h"
#include "SDMSubscriptionsCollectionApiImpl.h"
#include "SMFRegistrationDocumentApiImpl.h"
#include "SMFRegistrationsCollectionApiImpl.h"
#include "SMFSelectionSubscriptionDataDocumentApiImpl.h"
#include "SMSF3GPPRegistrationDocumentApiImpl.h"
#include "SMSFNon3GPPRegistrationDocumentApiImpl.h"
#include "SMSManagementSubscriptionDataDocumentApiImpl.h"
#include "SMSSubscriptionDataDocumentApiImpl.h"
#include "SessionManagementPolicyDataDocumentApiImpl.h"
#include "SessionManagementSubscriptionDataApiImpl.h"
#include "SponsorConnectivityDataDocumentApiImpl.h"
#include "SubsToNotifyCollectionApiImpl.h"
#include "SubsToNotifyDocumentApiImpl.h"
#include "TraceDataDocumentApiImpl.h"
#include "UEPolicySetDocumentApiImpl.h"
#include "UEsLocationInformationDocumentApiImpl.h"
#include "UsageMonitoringInformationDocumentApiImpl.h"
#include "V2XSubscriptionDataApiImpl.h"

#include <mysql/mysql.h>

#define PISTACHE_SERVER_THREADS 2
#define PISTACHE_SERVER_MAX_REQUEST_SIZE 32768
#define PISTACHE_SERVER_MAX_RESPONSE_SIZE 32768

static Pistache::Http::Endpoint *httpEndpoint;
#ifdef __linux__
static void sigHandler [[noreturn]] (int sig) {
  switch (sig) {
  case SIGINT:
  case SIGQUIT:
  case SIGTERM:
  case SIGHUP:
  default:
    httpEndpoint->shutdown();
    break;
  }
  exit(0);
}

static void setUpUnixSignals(std::vector<int> quitSignals) {
  sigset_t blocking_mask;
  sigemptyset(&blocking_mask);
  for (auto sig : quitSignals)
    sigaddset(&blocking_mask, sig);

  struct sigaction sa;
  sa.sa_handler = sigHandler;
  sa.sa_mask = blocking_mask;
  sa.sa_flags = 0;

  for (auto sig : quitSignals)
    sigaction(sig, &sa, nullptr);
}
#endif

using namespace org::openapitools::server::api;

int main() {
#ifdef __linux__
  std::vector<int> sigs{SIGQUIT, SIGINT, SIGTERM, SIGHUP};
  setUpUnixSignals(sigs);
#endif
  Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(8080));

  httpEndpoint = new Pistache::Http::Endpoint((addr));
  auto router = std::make_shared<Pistache::Rest::Router>();

  auto opts =
      Pistache::Http::Endpoint::options().threads(PISTACHE_SERVER_THREADS);
  opts.flags(Pistache::Tcp::Options::ReuseAddr);
  opts.maxRequestSize(PISTACHE_SERVER_MAX_REQUEST_SIZE);
  opts.maxResponseSize(PISTACHE_SERVER_MAX_RESPONSE_SIZE);
  httpEndpoint->init(opts);

  MYSQL mysql;
  mysql_init(&mysql);
  if (!mysql_real_connect(&mysql, "127.0.0.1", "yunshou", "123456",
                          "Witcomm-UDR-DB", 0, 0, 0)) {
    std::cout << "mysql_real_connect failure！" << std::endl;
    return 0;
  }

  AMF3GPPAccessRegistrationDocumentApiImpl
      AMF3GPPAccessRegistrationDocumentApiserver(router, &mysql);
  AMF3GPPAccessRegistrationDocumentApiserver.init();
  AMFNon3GPPAccessRegistrationDocumentApiImpl
      AMFNon3GPPAccessRegistrationDocumentApiserver(router);
  AMFNon3GPPAccessRegistrationDocumentApiserver.init();
  AccessAndMobilityDataApiImpl AccessAndMobilityDataApiserver(router);
  AccessAndMobilityDataApiserver.init();
  AccessAndMobilityPolicyDataDocumentApiImpl
      AccessAndMobilityPolicyDataDocumentApiserver(router);
  AccessAndMobilityPolicyDataDocumentApiserver.init();
  AccessAndMobilitySubscriptionDataDocumentApiImpl
      AccessAndMobilitySubscriptionDataDocumentApiserver(router, &mysql);
  AccessAndMobilitySubscriptionDataDocumentApiserver.init();
  AmfSubscriptionInfoDocumentApiImpl AmfSubscriptionInfoDocumentApiserver(
      router);
  AmfSubscriptionInfoDocumentApiserver.init();
  ApplicationDataSubscriptionsCollectionApiImpl
      ApplicationDataSubscriptionsCollectionApiserver(router);
  ApplicationDataSubscriptionsCollectionApiserver.init();
  AuthenticationSoRDocumentApiImpl AuthenticationSoRDocumentApiserver(router);
  AuthenticationSoRDocumentApiserver.init();
  AuthenticationStatusDocumentApiImpl AuthenticationStatusDocumentApiserver(
      router, &mysql);
  AuthenticationStatusDocumentApiserver.init();
  AuthenticationSubscriptionDocumentApiImpl
      AuthenticationSubscriptionDocumentApiserver(router, &mysql);
  AuthenticationSubscriptionDocumentApiserver.init();
  AuthenticationUPUDocumentApiImpl AuthenticationUPUDocumentApiserver(router);
  AuthenticationUPUDocumentApiserver.init();
  BdtDataStoreApiImpl BdtDataStoreApiserver(router);
  BdtDataStoreApiserver.init();
  BdtPolicyDataStoreApiImpl BdtPolicyDataStoreApiserver(router);
  BdtPolicyDataStoreApiserver.init();
  CAGACKDocumentApiImpl CAGACKDocumentApiserver(router);
  CAGACKDocumentApiserver.init();
  CAGUpdateAckDocumentApiImpl CAGUpdateAckDocumentApiserver(router);
  CAGUpdateAckDocumentApiserver.init();
  Class5GVNGroupsInternalDocumentApiImpl
      Class5GVNGroupsInternalDocumentApiserver(router);
  Class5GVNGroupsInternalDocumentApiserver.init();
  Class5GVNGroupsStoreApiImpl Class5GVNGroupsStoreApiserver(router);
  Class5GVNGroupsStoreApiserver.init();
  Class5GVnGroupConfigurationDocumentApiImpl
      Class5GVnGroupConfigurationDocumentApiserver(router);
  Class5GVnGroupConfigurationDocumentApiserver.init();
  ContextDataDocumentApiImpl ContextDataDocumentApiserver(router);
  ContextDataDocumentApiserver.init();
  Delete5GVnGroupApiImpl Delete5GVnGroupApiserver(router);
  Delete5GVnGroupApiserver.init();
  EnhancedCoverageRestrictionDataApiImpl
      EnhancedCoverageRestrictionDataApiserver(router);
  EnhancedCoverageRestrictionDataApiserver.init();
  EventAMFSubscriptionInfoDocumentApiImpl
      EventAMFSubscriptionInfoDocumentApiserver(router);
  EventAMFSubscriptionInfoDocumentApiserver.init();
  EventExposureDataDocumentApiImpl EventExposureDataDocumentApiserver(router);
  EventExposureDataDocumentApiserver.init();
  EventExposureGroupSubscriptionDocumentApiImpl
      EventExposureGroupSubscriptionDocumentApiserver(router);
  EventExposureGroupSubscriptionDocumentApiserver.init();
  EventExposureGroupSubscriptionsCollectionApiImpl
      EventExposureGroupSubscriptionsCollectionApiserver(router);
  EventExposureGroupSubscriptionsCollectionApiserver.init();
  EventExposureSubscriptionDocumentApiImpl
      EventExposureSubscriptionDocumentApiserver(router);
  EventExposureSubscriptionDocumentApiserver.init();
  EventExposureSubscriptionsCollectionApiImpl
      EventExposureSubscriptionsCollectionApiserver(router);
  EventExposureSubscriptionsCollectionApiserver.init();
  ExposureDataSubscriptionsCollectionApiImpl
      ExposureDataSubscriptionsCollectionApiserver(router);
  ExposureDataSubscriptionsCollectionApiserver.init();
  GroupIdentifiersApiImpl GroupIdentifiersApiserver(router);
  GroupIdentifiersApiserver.init();
  IPSMGWRegistrationDocumentApiImpl IPSMGWRegistrationDocumentApiserver(router);
  IPSMGWRegistrationDocumentApiserver.init();
  IPTVConfigurationDataStoreApiImpl IPTVConfigurationDataStoreApiserver(router);
  IPTVConfigurationDataStoreApiserver.init();
  IndividualApplicationDataSubscriptionDocumentApiImpl
      IndividualApplicationDataSubscriptionDocumentApiserver(router);
  IndividualApplicationDataSubscriptionDocumentApiserver.init();
  IndividualAppliedBDTPolicyDataDocumentApiImpl
      IndividualAppliedBDTPolicyDataDocumentApiserver(router);
  IndividualAppliedBDTPolicyDataDocumentApiserver.init();
  IndividualBDTPolicyDataDocumentApiImpl
      IndividualBDTPolicyDataDocumentApiserver(router);
  IndividualBDTPolicyDataDocumentApiserver.init();
  IndividualBdtDataDocumentApiImpl IndividualBdtDataDocumentApiserver(router);
  IndividualBdtDataDocumentApiserver.init();
  IndividualExposureDataSubscriptionDocumentApiImpl
      IndividualExposureDataSubscriptionDocumentApiserver(router);
  IndividualExposureDataSubscriptionDocumentApiserver.init();
  IndividualIPTVConfigurationDataApiImpl
      IndividualIPTVConfigurationDataApiserver(router);
  IndividualIPTVConfigurationDataApiserver.init();
  IndividualIPTVConfigurationDataDocumentApiImpl
      IndividualIPTVConfigurationDataDocumentApiserver(router);
  IndividualIPTVConfigurationDataDocumentApiserver.init();
  IndividualInfluenceDataDocumentApiImpl
      IndividualInfluenceDataDocumentApiserver(router);
  IndividualInfluenceDataDocumentApiserver.init();
  IndividualInfluenceDataSubscriptionDocumentApiImpl
      IndividualInfluenceDataSubscriptionDocumentApiserver(router);
  IndividualInfluenceDataSubscriptionDocumentApiserver.init();
  IndividualPFDDataDocumentApiImpl IndividualPFDDataDocumentApiserver(router);
  IndividualPFDDataDocumentApiserver.init();
  IndividualPolicyDataSubscriptionDocumentApiImpl
      IndividualPolicyDataSubscriptionDocumentApiserver(router);
  IndividualPolicyDataSubscriptionDocumentApiserver.init();
  InfluenceDataStoreApiImpl InfluenceDataStoreApiserver(router);
  InfluenceDataStoreApiserver.init();
  InfluenceDataSubscriptionsCollectionApiImpl
      InfluenceDataSubscriptionsCollectionApiserver(router);
  InfluenceDataSubscriptionsCollectionApiserver.init();
  LCSBroadcastAssistanceSubscriptionDataApiImpl
      LCSBroadcastAssistanceSubscriptionDataApiserver(router);
  LCSBroadcastAssistanceSubscriptionDataApiserver.init();
  LCSMobileOriginatedSubscriptionDataApiImpl
      LCSMobileOriginatedSubscriptionDataApiserver(router);
  LCSMobileOriginatedSubscriptionDataApiserver.init();
  LCSPrivacySubscriptionDataApiImpl LCSPrivacySubscriptionDataApiserver(router);
  LCSPrivacySubscriptionDataApiserver.init();
  MessageWaitingDataDocumentApiImpl MessageWaitingDataDocumentApiserver(router);
  MessageWaitingDataDocumentApiserver.init();
  Modify5GVnGroupApiImpl Modify5GVnGroupApiserver(router);
  Modify5GVnGroupApiserver.init();
  NSSAIACKDocumentApiImpl NSSAIACKDocumentApiserver(router);
  NSSAIACKDocumentApiserver.init();
  NSSAIUpdateAckDocumentApiImpl NSSAIUpdateAckDocumentApiserver(router);
  NSSAIUpdateAckDocumentApiserver.init();
  OperatorSpecificDataContainerDocumentApiImpl
      OperatorSpecificDataContainerDocumentApiserver(router);
  OperatorSpecificDataContainerDocumentApiserver.init();
  OperatorSpecificDataDocumentApiImpl OperatorSpecificDataDocumentApiserver(
      router);
  OperatorSpecificDataDocumentApiserver.init();
  PFDDataStoreApiImpl PFDDataStoreApiserver(router);
  PFDDataStoreApiserver.init();
  ParameterProvisionDocumentApiImpl ParameterProvisionDocumentApiserver(router);
  ParameterProvisionDocumentApiserver.init();
  PduSessionManagementDataApiImpl PduSessionManagementDataApiserver(router);
  PduSessionManagementDataApiserver.init();
  PlmnUePolicySetDocumentApiImpl PlmnUePolicySetDocumentApiserver(router);
  PlmnUePolicySetDocumentApiserver.init();
  PolicyDataSubscriptionsCollectionApiImpl
      PolicyDataSubscriptionsCollectionApiserver(router);
  PolicyDataSubscriptionsCollectionApiserver.init();
  ProvisionedDataDocumentApiImpl ProvisionedDataDocumentApiserver(router);
  ProvisionedDataDocumentApiserver.init();
  ProvisionedParameterDataDocumentApiImpl
      ProvisionedParameterDataDocumentApiserver(router);
  ProvisionedParameterDataDocumentApiserver.init();
  Query5GVnGroupConfigurationDocumentApiImpl
      Query5GVnGroupConfigurationDocumentApiserver(router);
  Query5GVnGroupConfigurationDocumentApiserver.init();
  QueryAMFSubscriptionInfoDocumentApiImpl
      QueryAMFSubscriptionInfoDocumentApiserver(router);
  QueryAMFSubscriptionInfoDocumentApiserver.init();
  QueryIdentityDataBySUPIOrGPSIDocumentApiImpl
      QueryIdentityDataBySUPIOrGPSIDocumentApiserver(router);
  QueryIdentityDataBySUPIOrGPSIDocumentApiserver.init();
  QueryNIDDAuthorizationDataGPSIOrExternalGroupIdentifierDocumentApiImpl
      QueryNIDDAuthorizationDataGPSIOrExternalGroupIdentifierDocumentApiserver(
          router);
  QueryNIDDAuthorizationDataGPSIOrExternalGroupIdentifierDocumentApiserver
      .init();
  QueryODBDataBySUPIOrGPSIDocumentApiImpl
      QueryODBDataBySUPIOrGPSIDocumentApiserver(router);
  QueryODBDataBySUPIOrGPSIDocumentApiserver.init();
  RetrievalOfSharedDataApiImpl RetrievalOfSharedDataApiserver(router);
  RetrievalOfSharedDataApiserver.init();
  SDMSubscriptionDocumentApiImpl SDMSubscriptionDocumentApiserver(router,
                                                                  &mysql);
  SDMSubscriptionDocumentApiserver.init();
  SDMSubscriptionsCollectionApiImpl SDMSubscriptionsCollectionApiserver(router,
                                                                        &mysql);
  SDMSubscriptionsCollectionApiserver.init();
  SMFRegistrationDocumentApiImpl SMFRegistrationDocumentApiserver(router,
                                                                  &mysql);
  SMFRegistrationDocumentApiserver.init();
  SMFRegistrationsCollectionApiImpl SMFRegistrationsCollectionApiserver(router,
                                                                        &mysql);
  SMFRegistrationsCollectionApiserver.init();
  SMFSelectionSubscriptionDataDocumentApiImpl
      SMFSelectionSubscriptionDataDocumentApiserver(router, &mysql);
  SMFSelectionSubscriptionDataDocumentApiserver.init();
  SMSF3GPPRegistrationDocumentApiImpl SMSF3GPPRegistrationDocumentApiserver(
      router);
  SMSF3GPPRegistrationDocumentApiserver.init();
  SMSFNon3GPPRegistrationDocumentApiImpl
      SMSFNon3GPPRegistrationDocumentApiserver(router);
  SMSFNon3GPPRegistrationDocumentApiserver.init();
  SMSManagementSubscriptionDataDocumentApiImpl
      SMSManagementSubscriptionDataDocumentApiserver(router);
  SMSManagementSubscriptionDataDocumentApiserver.init();
  SMSSubscriptionDataDocumentApiImpl SMSSubscriptionDataDocumentApiserver(
      router);
  SMSSubscriptionDataDocumentApiserver.init();
  SessionManagementPolicyDataDocumentApiImpl
      SessionManagementPolicyDataDocumentApiserver(router);
  SessionManagementPolicyDataDocumentApiserver.init();
  SessionManagementSubscriptionDataApiImpl
      SessionManagementSubscriptionDataApiserver(router, &mysql);
  SessionManagementSubscriptionDataApiserver.init();
  SponsorConnectivityDataDocumentApiImpl
      SponsorConnectivityDataDocumentApiserver(router);
  SponsorConnectivityDataDocumentApiserver.init();
  SubsToNotifyCollectionApiImpl SubsToNotifyCollectionApiserver(router);
  SubsToNotifyCollectionApiserver.init();
  SubsToNotifyDocumentApiImpl SubsToNotifyDocumentApiserver(router);
  SubsToNotifyDocumentApiserver.init();
  TraceDataDocumentApiImpl TraceDataDocumentApiserver(router);
  TraceDataDocumentApiserver.init();
  UEPolicySetDocumentApiImpl UEPolicySetDocumentApiserver(router);
  UEPolicySetDocumentApiserver.init();
  UEsLocationInformationDocumentApiImpl UEsLocationInformationDocumentApiserver(
      router);
  UEsLocationInformationDocumentApiserver.init();
  UsageMonitoringInformationDocumentApiImpl
      UsageMonitoringInformationDocumentApiserver(router);
  UsageMonitoringInformationDocumentApiserver.init();
  V2XSubscriptionDataApiImpl V2XSubscriptionDataApiserver(router);
  V2XSubscriptionDataApiserver.init();

  httpEndpoint->setHandler(router->handler());
  httpEndpoint->serve();

  httpEndpoint->shutdown();
  mysql_close(&mysql);
}
