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

scala.googleapis.bigquery.ProjectsClient.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 ProjectsClient[F[_]: Concurrent](client: Client[F]) extends AbstractClient[F](client) {
  val baseUri = uri"https://bigquery.googleapis.com/bigquery/v2"
  def getServiceAccount(
      /** Required. ID of the project.
        */
      projectId: String
  ): F[GetServiceAccountResponse] = expectJson[GetServiceAccountResponse](
    request(method = Method.GET, uri = baseUri / "projects" / s"${projectId}" / "serviceAccount")
  )
  def list(
      query: ProjectsClient.ListParams = ProjectsClient.ListParams()
  ): F[ProjectList] = expectJson[ProjectList](
    request(
      method = Method.GET,
      uri = (baseUri / "projects").copy(query =
        Query.fromVector(
          Vector(
            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))
            },
          ).flatten
        )
      ),
    )
  )
}
object ProjectsClient {
  final case class ListParams(
      /** `maxResults` unset returns all results, up to 50 per page. Additionally, the number of projects in a page may be fewer than `maxResults` because projects are retrieved and then filtered to only projects with the BigQuery API enabled.
        */
      maxResults: Option[Int] = None,
      /** Page token, returned by a previous call, to request the next page of results. If not present, no further pages are present.
        */
      pageToken: Option[String] = None,
  )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy