CreateOperations

pt.tecnico.dsi.openstack.common.services.CreateOperations
trait CreateOperations[F[_], Model, Create, Update]

Idempotent create operations for a domain model of an Openstack REST API.

Attributes

Source
CreateOperations.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CrudService[F, Model, Create, Update]
Self type
PartialCrudService[F] & CreateNonIdempotentOperations[F, Model, Create] & UpdateOperations[F, Model, Update]

Members list

Value members

Abstract methods

def createOrUpdate(create: Create, keepExistingElements: Boolean, extraHeaders: Seq[ToRaw])(resolveConflict: (Model, Create) => F[Model]): F[Model]

An idempotent create. If the model that is to be created already exists then it will be updated, or simply returned if no modifications are necessary. The definition on what is considered already existing is left to the implementation as it is specific to the Model in question.

An idempotent create. If the model that is to be created already exists then it will be updated, or simply returned if no modifications are necessary. The definition on what is considered already existing is left to the implementation as it is specific to the Model in question.

Value parameters

create

the values to use in the create.

extraHeaders

extra headers to be used. The authToken header is always added.

keepExistingElements

the create operation can be interpreted with two possible meanings:

  1. Create a Model with the settings in Create. Extra settings that may already exist (when the model is being updated) will be preserved as much as possible.
  2. Create a Model with exactly the settings in Create. Extra settings that may already exist are removed. This is done in a best effort approach, since its not achievable in the general case, as some settings are not updatable after creating the Model (the create and the update are asymmetric). Setting keepExistingElements to true will follow the logic in point 1. Setting it to false will follow the logic in point 2, thus making the update more stringent. In most cases removing extra settings will break things, so this flag is set to true by default.
resolveConflict

the function used to resolve the conflict that will arise when the create is being performed on a model that already exists. By default it just invokes defaultResolveConflict.

Attributes

Returns

the created domainModel, or if it already exists the existing or updated model.

Source
CreateOperations.scala
def defaultResolveConflict(existing: Model, create: Create, keepExistingElements: Boolean, extraHeaders: Seq[ToRaw]): F[Model]

Default implementation to resolve the conflict that arises when implementing the createOrUpdate. In other words implements the idempotency logic of the create.

Default implementation to resolve the conflict that arises when implementing the createOrUpdate. In other words implements the idempotency logic of the create.

Value parameters

create

the values to use in the create.

existing

the existing domainModel.

extraHeaders

extra headers to be used. The authToken header is always added.

keepExistingElements

whether to keep existing elements. See createOrUpdate for a more detailed explanation.

Attributes

Returns

the existing model if no modifications are required, otherwise the updated model.

Source
CreateOperations.scala

Concrete methods

protected def createHandleConflict(create: Create, uri: Uri, extraHeaders: Seq[ToRaw])(onConflict: F[Model]): F[Model]

Creates a new domainModel with the given create values using uri. If a Conflict is returned execute onConflict to resolve it.

Creates a new domainModel with the given create values using uri. If a Conflict is returned execute onConflict to resolve it.

Value parameters

create

the values to use in the create.

extraHeaders

extra headers to be used. The authToken header is always added.

onConflict

the computation returning a domainModel to execute when a Conflict is returned in the create.

uri

the uri to which the request will be made.

Attributes

Returns

the created domainModel, or the updated domainModel by onConflict.

Source
CreateOperations.scala
protected def createHandleConflictWithError[E <: Throwable](create: Create, uri: Uri, extraHeaders: Seq[ToRaw])(onConflict: PartialFunction[E, F[Model]])(using evidence$1: Decoder[E]): F[Model]

Creates a new domainModel with the given create values using uri. If the create is not successful the response will be parsed to an E and the onConflict partial function will be called. If the function is defined for the given E the computation returned by it will be used to resolve the conflict. If the function is not defined F will contain the parsed E.

Creates a new domainModel with the given create values using uri. If the create is not successful the response will be parsed to an E and the onConflict partial function will be called. If the function is defined for the given E the computation returned by it will be used to resolve the conflict. If the function is not defined F will contain the parsed E.

Value parameters

create

the values to use in the create.

extraHeaders

extra headers to be used. The authToken header is always added.

onConflict

the computation returning a domainModel to execute when a Conflict is returned in the create.

uri

the uri to which the request will be made.

Attributes

Returns

the created domainModel, or the updated domainModel by onConflict.

Source
CreateOperations.scala
def createOrUpdate(create: Create, extraHeaders: ToRaw*): F[Model]

An idempotent create. If the model that is to be created already exists then it will be updated, or simply returned if no modifications are necessary. The definition on what is considered already existing is left to the implementation as it is specific to the Model in question.

An idempotent create. If the model that is to be created already exists then it will be updated, or simply returned if no modifications are necessary. The definition on what is considered already existing is left to the implementation as it is specific to the Model in question.

This function simply calls the overloaded version passing in keepExistingElements set to true.

Value parameters

create

the values to use in the create.

extraHeaders

extra headers to be used. The authToken header is always added.

Attributes

Returns

the created domainModel, or if it already exists the existing or updated model.

Source
CreateOperations.scala
def createOrUpdate(create: Create, keepExistingElements: Boolean, extraHeaders: ToRaw*): F[Model]

An idempotent create. If the model that is to be created already exists then it will be updated, or simply returned if no modifications are necessary. The definition on what is considered already existing is left to the implementation as it is specific to the Model in question. defaultResolveConflict will be invoked to resolve the conflict that will arise when the create is being performed on a model that already exists.

An idempotent create. If the model that is to be created already exists then it will be updated, or simply returned if no modifications are necessary. The definition on what is considered already existing is left to the implementation as it is specific to the Model in question. defaultResolveConflict will be invoked to resolve the conflict that will arise when the create is being performed on a model that already exists.

Value parameters

create

the values to use in the create.

extraHeaders

extra headers to be used. The authToken header is always added.

keepExistingElements

the create operation can be interpreted with two possible meanings:

  1. Create a Model with the settings in Create. Extra settings that may already exist (when the model is being updated) will be preserved as much as possible.
  2. Create a Model with exactly the settings in Create. Extra settings that may already exist are removed. This is done in a best effort approach, since its not achievable in the general case, as some settings are not updatable after creating the Model (the create and the update are asymmetric). Setting keepExistingElements to true will follow the logic in point 1. Setting it to false will follow point 2, thus making the update more stringent.

Attributes

Returns

the created domainModel, or if it already exists the existing or updated model.

Source
CreateOperations.scala