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

scala.googleapis.bigquery.TabledataClient.scala Maven / Gradle / Ivy

There is a newer version: 0.4.5-v2-20240905
Show newest version
package googleapis.bigquery

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

class TabledataClient[F[_]: Concurrent](client: Client[F]) extends AbstractClient[F](client) {
  val baseUri = uri"https://bigquery.googleapis.com/bigquery/v2"
  def insertAll(
      /** Required. Project ID of the destination.
        */
      projectId: String,
      /** Required. Dataset ID of the destination.
        */
      datasetId: String,
      /** Required. Table ID of the destination.
        */
      tableId: String,
  )(input: TableDataInsertAllRequest): F[TableDataInsertAllResponse] =
    expectJson[TableDataInsertAllResponse](
      requestWithBody(
        method = Method.POST,
        uri =
          baseUri / "projects" / s"${projectId}" / "datasets" / s"${datasetId}" / "tables" / s"${tableId}" / "insertAll",
      )(input)
    )
  def list(
      /** Required. Project id of the table to list.
        */
      projectId: String,
      /** Required. Dataset id of the table to list.
        */
      datasetId: String,
      /** Required. Table id of the table to list.
        */
      tableId: String,
      query: TabledataClient.ListParams = TabledataClient.ListParams(),
  ): F[TableDataList] = expectJson[TableDataList](
    request(
      method = Method.GET,
      uri =
        (baseUri / "projects" / s"${projectId}" / "datasets" / s"${datasetId}" / "tables" / s"${tableId}" / "data")
          .copy(query =
            Query.fromVector(
              Vector(
                List(
                  "formatOptions.useInt64Timestamp" -> query.formatOptions_useInt64Timestamp.map(
                    s => QueryParamEncoder[Boolean].encode(s).value
                  )
                ).flatMap { case (k, v) => v.map(vv => k -> Option(vv)) },
                List(
                  "maxResults" -> query.maxResults.map(s => QueryParamEncoder[Int].encode(s).value)
                ).flatMap { case (k, v) => v.map(vv => k -> Option(vv)) },
                List("pageToken" -> query.pageToken).flatMap { case (k, v) =>
                  v.map(vv => k -> Option(vv))
                },
                List("selectedFields" -> query.selectedFields).flatMap { case (k, v) =>
                  v.map(vv => k -> Option(vv))
                },
                List("startIndex" -> query.startIndex).flatMap { case (k, v) =>
                  v.map(vv => k -> Option(vv))
                },
              ).flatten
            )
          ),
    )
  )
}
object TabledataClient {
  final case class ListParams(
      /** Optional. Output timestamp as usec int64. Default is false.
        */
      formatOptions_useInt64Timestamp: Option[Boolean] = None,
      /** Row limit of the table.
        */
      maxResults: Option[Int] = None,
      /** To retrieve the next page of table data, set this field to the string provided in the pageToken field of the response body from your previous call to tabledata.list.
        */
      pageToken: Option[String] = None,
      /** Subset of fields to return, supports select into sub fields. Example: selected_fields = "a,e.d.f";
        */
      selectedFields: Option[String] = None,
      /** Start row index of the table.
        */
      startIndex: Option[String] = None,
  )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy