All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scala.googleapis.storage.OperationsClient.scala Maven / Gradle / Ivy

The newest version!
package googleapis.storage

import cats.effect.Concurrent
import org.http4s._
import org.http4s.implicits._
import org.http4s.client.Client

class OperationsClient[F[_]: Concurrent](client: Client[F]) extends AbstractClient[F](client) {
  val baseUri = uri"https://storage.googleapis.com/storage/v1"
  def cancel(
      /** The parent bucket of the operation resource.
        */
      bucket: String,
      /** The ID of the operation resource.
        */
      operationId: String,
  ): F[Status] = client.status(
    request(
      method = Method.POST,
      uri = baseUri / "b" / s"${bucket}" / "operations" / s"${operationId}" / "cancel",
    )
  )
  def get(
      /** The parent bucket of the operation resource.
        */
      bucket: String,
      /** The ID of the operation resource.
        */
      operationId: String,
  ): F[GoogleLongrunningOperation] = expectJson[GoogleLongrunningOperation](
    request(
      method = Method.GET,
      uri = baseUri / "b" / s"${bucket}" / "operations" / s"${operationId}",
    )
  )
  def list(
      /** Name of the bucket in which to look for operations.
        */
      bucket: String,
      query: OperationsClient.ListParams = OperationsClient.ListParams(),
  ): F[GoogleLongrunningListOperationsResponse] =
    expectJson[GoogleLongrunningListOperationsResponse](
      request(
        method = Method.GET,
        uri = (baseUri / "b" / s"${bucket}" / "operations").copy(query =
          Query(
            "filter" -> query.filter,
            "pageSize" -> query.pageSize.map(s => QueryParamEncoder[Int].encode(s).value),
            "pageToken" -> query.pageToken,
          )
        ),
      )
    )
}
object OperationsClient {
  final case class ListParams(
      /** A filter to narrow down results to a preferred subset. The filtering language is documented in more detail in [AIP-160](https://google.aip.dev/160).
        */
      filter: Option[String] = None,
      /** Maximum number of items to return in a single page of responses. Fewer total results may be returned than requested. The service uses this parameter or 100 items, whichever is smaller.
        */
      pageSize: Option[Int] = None,
      /** A previously-returned page token representing part of the larger set of results to view.
        */
      pageToken: Option[String] = None,
  )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy