Template Class ServiceBase

Inheritance Relationships

Base Type

Template Parameter Order

  1. class T

Class Documentation

template<class T>
class ServiceBase : public axr::sdk::IServiceBase

Abstract base class for all Service classes that operate on a given entity type T.

Protected Functions

inline ServiceBase(std::shared_ptr<Configuration> config, std::shared_ptr<net::IApiClient> apiClient)
inline pplx::task<std::vector<std::shared_ptr<T>>> FindAll(const utility::string_t &path, 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(""))

Retrieves a list of objects matching the specified search parameters.

Parameters
  • path – The path to the remote resource to find.

  • searchParams – A map of property names to values to search for.

  • startIndex – The index of the first object to include in the result.

  • maxResults – The maximum number of objects to evaluate during the search.

  • sortBy – The property name and order direction to sort the results using. (e.g. “MyProperty=ASC” to sort by MyProperty in ascending order, “MyProperty=DESC” to sort by MyProperty in descending order).

Returns

A task whose result is a list of objects matching the specified search parameters.

inline pplx::task<std::shared_ptr<T>> Create(const utility::string_t &p, std::shared_ptr<T> obj)

Creates a new instance of T, storing the object on the remote service and returning the final result.

Parameters
  • path – The path to the remote resource to create.

  • obj – The object to persist with the remote service.

Returns

A task whose result is the final object as it was persisted with the remote service.

inline pplx::task<uint64_t> Count(const utility::string_t &path, const std::map<utility::string_t, utility::string_t> *searchParams = nullptr, const uint16_t startIndex = 0, const uint16_t maxResults = 1000)

Retrieves the total number of objects matching the specified search parameters.

Parameters
  • path – The path to the remote resource to count.

  • searchParams – A map of property names to values to search for.

  • startIndex – The index of the first object to include in the result.

  • maxResults – The maximum number of objects to evaluate during the search. Value cannot exceed 1000.

Returns

A task whose result is the number of objects matching the specified search parameters.

inline pplx::task<uint64_t> CountLegacy(const utility::string_t &path, const std::map<utility::string_t, utility::string_t> *searchParams = nullptr, const uint16_t startIndex = 0, const uint16_t maxResults = 1000)

Retrieves the total number of objects matching the specified search parameters. This function uses the deprecated GET method for retrieving the resource count. Note that not all REST API endpoints support this method.

Parameters
  • path – The path to the remote resource to count.

  • searchParams – A map of property names to values to search for.

  • startIndex – The index of the first object to include in the result.

  • maxResults – The maximum number of objects to evaluate during the search. Value cannot exceed 1000.

Returns

A task whose result is the number of objects matching the specified search parameters.

inline pplx::task<std::shared_ptr<T>> FindById(const utility::string_t &path)

Retrieves an instance of T with the specified unique identifier.

Parameters

path – The path to the remote resource to find.

Returns

A task whose result is the object with the specified identifier if found.

inline pplx::task<std::shared_ptr<T>> Update(const utility::string_t &p, std::shared_ptr<T> obj)

Updates an existing instance of T, storing the object on the remote service and returning the final result.

Parameters
  • path – The path to the remote resource to update.

  • obj – The object to update with the remote service.

Returns

A task whose result is the final object as it was persisted with the remote service.

inline pplx::task<void> Delete(const utility::string_t &path)

Deletes an instance of T with the specified unique identifier.

Parameters

path – The path to the remote resource to delete.

Returns

A task.

inline pplx::task<void> Truncate(const utility::string_t &path, const std::map<utility::string_t, utility::string_t> *searchParams = nullptr)

Deletes all instances of T from the service.

Parameters
  • path – The path to the remote resource to truncate.

  • searchParams – A map of property names to values to search for.

Returns

A task.

Protected Attributes

std::shared_ptr<net::IApiClient> m_apiClient
std::shared_ptr<Configuration> m_config