com.cognite.sdk.scala.v1.resources.spaces.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognite-sdk-scala_3 Show documentation
Show all versions of cognite-sdk-scala_3 Show documentation
Scala SDK for Cognite Data Fusion.
// Copyright 2020 Cognite AS
// SPDX-License-Identifier: Apache-2.0
package com.cognite.sdk.scala.v1.resources
import com.cognite.sdk.scala.common._
import com.cognite.sdk.scala.v1._
import io.circe.generic.semiauto.deriveDecoder
import io.circe.{Decoder, Printer}
import sttp.client3._
import sttp.client3.circe._
class Spaces[F[_]](val requestSession: RequestSession[F])
extends WithRequestSession[F]
with BaseUrl {
import Spaces._
override val baseUrl = uri"${requestSession.baseUrl}/datamodelstorage/spaces"
def createItems(externalIds: Seq[String]): F[Seq[String]] = {
implicit val printer: Printer = Printer.noSpaces.copy(dropNullValues = true)
requestSession.post[Seq[String], Items[CogniteExternalId], Items[CogniteId]](
Items(externalIds.map(CogniteExternalId(_))),
uri"$baseUrl",
value => value.items.map(_.externalId)
)
}
def deleteItems(externalIds: Seq[String]): F[Unit] =
requestSession.post[Unit, Unit, Items[CogniteId]](
Items(externalIds.map(CogniteExternalId(_))),
uri"$baseUrl/delete",
_ => ()
)
def list(): F[Seq[String]] =
requestSession.post[Seq[String], Items[CogniteExternalId], Unit](
(),
uri"$baseUrl/list",
value => value.items.map(_.externalId)
)
def retrieveByExternalIds(
externalIds: Seq[String]
): F[Seq[String]] =
requestSession
.post[Seq[String], Items[CogniteExternalId], Items[CogniteId]](
Items(
externalIds.map(CogniteExternalId(_))
),
uri"$baseUrl/byids",
value => value.items.map(_.externalId)
)
}
object Spaces {
implicit val externalIdItemsDecoder: Decoder[Items[CogniteExternalId]] =
deriveDecoder[Items[CogniteExternalId]]
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy