Program Listing for File ServerInstanceService.h

Return to documentation for file (axr.sdk/services/ServerInstanceService.h)

// Copyright (C) AcceleratXR, Inc. All rights reserved.
#pragma once

#include "axr.sdk/net/IApiClient.h"
#include "axr.sdk/ServiceBase.h"
#include "axr.sdk/models/ServerInstance.h"
#include "axr.sdk/utils/StringUtils.h"
#include "axr.sdk/models/Count.h"
#include "axr.sdk/utils/EntityWatchdog.h"

#include <cpprest/details/basic_types.h>
#include <map>
#include <memory>
#include <vector>

DEFINE_ENTITYWATCHDOG_SPEC(ServerInstance)

namespace axr {
namespace sdk {
namespace services {

using namespace axr::sdk::models;

class ServerInstanceService : public ServiceBase<ServerInstance>{
public:
    ServerInstanceService(std::shared_ptr<Configuration> config, std::shared_ptr<net::IApiClient> apiClient)
        : ServiceBase(config, apiClient)
    {}

    ~ServerInstanceService() {}

    static const utility::char_t* ClassName()
    {
        return _XPLATSTR("axr::sdk::services::ServerInstanceService");
    }

    pplx::task<std::shared_ptr<ServerInstance>> Assign(std::shared_ptr<AssignServerInstance> obj);

#ifdef AXR_COMPILE_SERVER
    pplx::task<std::shared_ptr<ServerInstance>> Create(std::shared_ptr<ServerInstance> obj);
#endif // AXR_COMPILE_SERVER
    pplx::task<uint64_t> Count(const std::map<utility::string_t, utility::string_t>* searchParams = nullptr, const uint16_t startIndex = 0, const uint16_t maxResults = 1000);
#ifdef AXR_COMPILE_SERVER
    pplx::task<void> Delete(const utility::string_t& id);
#endif // AXR_COMPILE_SERVER
    pplx::task<std::vector<std::shared_ptr<ServerInstance>>> FindAll(const std::map<utility::string_t, utility::string_t>* searchParams = nullptr, const uint16_t startIndex = 0, const uint16_t maxResults = 1000, const utility::string_t& sortBy = _XPLATSTR(""));

    pplx::task<std::shared_ptr<ServerInstance>> FindById(const utility::string_t& id);
#ifdef AXR_COMPILE_SERVER
    pplx::task<std::shared_ptr<ServerInstance>> Update(const utility::string_t& id, std::shared_ptr<ServerInstance> obj);

    pplx::task<std::shared_ptr<ServerInstance>> UpdateHeartbeat(const utility::string_t& id);
#endif // AXR_COMPILE_SERVER

private:
    pplx::task<std::shared_ptr<ServerInstance>> SendAgonesHeartbeat(std::shared_ptr<ServerInstance> instance);

    pplx::task<std::shared_ptr<ServerInstance>> SendAgonesUpdate(std::shared_ptr<ServerInstance> instance);

    std::shared_ptr<axr::sdk::net::IApiClient> agonesClient = nullptr;
};

} // namespace services
} // namespace axr
} // namespace sdk