scala.googleapis.storage.ProjectsHmacKeysClient.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 ProjectsHmacKeysClient[F[_]: Concurrent](client: Client[F])
extends AbstractClient[F](client) {
val baseUri = uri"https://storage.googleapis.com/storage/v1"
def create(
/** Project ID owning the service account.
*/
projectId: String,
query: ProjectsHmacKeysClient.CreateParams = ProjectsHmacKeysClient.CreateParams(),
): F[HmacKey] = expectJson[HmacKey](
request(
method = Method.POST,
uri = (baseUri / "projects" / s"${projectId}" / "hmacKeys").copy(query =
Query(
"serviceAccountEmail" -> query.serviceAccountEmail,
"userProject" -> query.userProject,
)
),
)
)
def delete(
/** Project ID owning the requested key
*/
projectId: String,
/** Name of the HMAC key to be deleted.
*/
accessId: String,
query: ProjectsHmacKeysClient.DeleteParams = ProjectsHmacKeysClient.DeleteParams(),
): F[Status] = client.status(
request(
method = Method.DELETE,
uri = (baseUri / "projects" / s"${projectId}" / "hmacKeys" / s"${accessId}")
.copy(query = Query("userProject" -> query.userProject)),
)
)
def get(
/** Project ID owning the service account of the requested key.
*/
projectId: String,
/** Name of the HMAC key.
*/
accessId: String,
query: ProjectsHmacKeysClient.GetParams = ProjectsHmacKeysClient.GetParams(),
): F[HmacKeyMetadata] = expectJson[HmacKeyMetadata](
request(
method = Method.GET,
uri = (baseUri / "projects" / s"${projectId}" / "hmacKeys" / s"${accessId}")
.copy(query = Query("userProject" -> query.userProject)),
)
)
def update(
/** Project ID owning the service account of the updated key.
*/
projectId: String,
/** Name of the HMAC key being updated.
*/
accessId: String,
query: ProjectsHmacKeysClient.UpdateParams = ProjectsHmacKeysClient.UpdateParams(),
)(input: HmacKeyMetadata): F[HmacKeyMetadata] = expectJson[HmacKeyMetadata](
requestWithBody(
method = Method.PUT,
uri = (baseUri / "projects" / s"${projectId}" / "hmacKeys" / s"${accessId}")
.copy(query = Query("userProject" -> query.userProject)),
)(input)
)
def list(
/** Name of the project in which to look for HMAC keys.
*/
projectId: String,
query: ProjectsHmacKeysClient.ListParams = ProjectsHmacKeysClient.ListParams(),
): F[HmacKeysMetadata] = expectJson[HmacKeysMetadata](
request(
method = Method.GET,
uri = (baseUri / "projects" / s"${projectId}" / "hmacKeys").copy(query =
Query(
"maxResults" -> query.maxResults.map(s => QueryParamEncoder[Int].encode(s).value),
"pageToken" -> query.pageToken,
"serviceAccountEmail" -> query.serviceAccountEmail,
"showDeletedKeys" -> query.showDeletedKeys.map(s =>
QueryParamEncoder[Boolean].encode(s).value
),
"userProject" -> query.userProject,
)
),
)
)
}
object ProjectsHmacKeysClient {
final case class CreateParams(
/** Email address of the service account.
*/
serviceAccountEmail: Option[String] = None,
/** The project to be billed for this request.
*/
userProject: Option[String] = None,
)
final case class DeleteParams(
/** The project to be billed for this request.
*/
userProject: Option[String] = None
)
final case class GetParams(
/** The project to be billed for this request.
*/
userProject: Option[String] = None
)
final case class UpdateParams(
/** The project to be billed for this request.
*/
userProject: Option[String] = None
)
final case class ListParams(
/** Maximum number of items to return in a single page of responses. The service uses this parameter or 250 items, whichever is smaller. The max number of items per page will also be limited by the number of distinct service accounts in the response. If the number of service accounts in a single response is too high, the page will truncated and a next page token will be returned.
*/
maxResults: Option[Int] = None,
/** A previously-returned page token representing part of the larger set of results to view.
*/
pageToken: Option[String] = None,
/** If present, only keys for the given service account are returned.
*/
serviceAccountEmail: Option[String] = None,
/** Whether or not to show keys in the DELETED state.
*/
showDeletedKeys: Option[Boolean] = None,
/** The project to be billed for this request.
*/
userProject: Option[String] = None,
)
}