scala.googleapis.storage.FoldersClient.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 FoldersClient[F[_]: Concurrent](client: Client[F]) extends AbstractClient[F](client) {
val baseUri = uri"https://storage.googleapis.com/storage/v1"
def insert(
/** Name of the bucket in which the folder resides.
*/
bucket: String,
query: FoldersClient.InsertParams = FoldersClient.InsertParams(),
)(input: Folder): F[Folder] = expectJson[Folder](
requestWithBody(
method = Method.POST,
uri = (baseUri / "b" / s"${bucket}" / "folders").copy(query =
Query("recursive" -> query.recursive.map(s => QueryParamEncoder[Boolean].encode(s).value))
),
)(input)
)
def rename(
/** Name of the bucket in which the folders are in.
*/
bucket: String,
/** Name of the source folder.
*/
sourceFolder: String,
/** Name of the destination folder.
*/
destinationFolder: String,
query: FoldersClient.RenameParams = FoldersClient.RenameParams(),
): F[GoogleLongrunningOperation] = expectJson[GoogleLongrunningOperation](
request(
method = Method.POST,
uri =
(baseUri / "b" / s"${bucket}" / "folders" / s"${sourceFolder}" / "renameTo" / "folders" / s"${destinationFolder}")
.copy(query =
Query(
"ifSourceMetagenerationMatch" -> query.ifSourceMetagenerationMatch,
"ifSourceMetagenerationNotMatch" -> query.ifSourceMetagenerationNotMatch,
)
),
)
)
def delete(
/** Name of the bucket in which the folder resides.
*/
bucket: String,
/** Name of a folder.
*/
folder: String,
query: FoldersClient.DeleteParams = FoldersClient.DeleteParams(),
): F[Status] = client.status(
request(
method = Method.DELETE,
uri = (baseUri / "b" / s"${bucket}" / "folders" / s"${folder}").copy(query =
Query(
"ifMetagenerationMatch" -> query.ifMetagenerationMatch,
"ifMetagenerationNotMatch" -> query.ifMetagenerationNotMatch,
)
),
)
)
def get(
/** Name of the bucket in which the folder resides.
*/
bucket: String,
/** Name of a folder.
*/
folder: String,
query: FoldersClient.GetParams = FoldersClient.GetParams(),
): F[Folder] = expectJson[Folder](
request(
method = Method.GET,
uri = (baseUri / "b" / s"${bucket}" / "folders" / s"${folder}").copy(query =
Query(
"ifMetagenerationMatch" -> query.ifMetagenerationMatch,
"ifMetagenerationNotMatch" -> query.ifMetagenerationNotMatch,
)
),
)
)
def list(
/** Name of the bucket in which to look for folders.
*/
bucket: String,
query: FoldersClient.ListParams = FoldersClient.ListParams(),
): F[Folders] = expectJson[Folders](
request(
method = Method.GET,
uri = (baseUri / "b" / s"${bucket}" / "folders").copy(query =
Query(
"delimiter" -> query.delimiter,
"endOffset" -> query.endOffset,
"pageSize" -> query.pageSize.map(s => QueryParamEncoder[Int].encode(s).value),
"pageToken" -> query.pageToken,
"prefix" -> query.prefix,
"startOffset" -> query.startOffset,
)
),
)
)
}
object FoldersClient {
final case class InsertParams(
/** If true, any parent folder which doesn’t exist will be created automatically.
*/
recursive: Option[Boolean] = None
)
final case class RenameParams(
/** Makes the operation conditional on whether the source object's current metageneration matches the given value.
*/
ifSourceMetagenerationMatch: Option[String] = None,
/** Makes the operation conditional on whether the source object's current metageneration does not match the given value.
*/
ifSourceMetagenerationNotMatch: Option[String] = None,
)
final case class DeleteParams(
/** If set, only deletes the folder if its metageneration matches this value.
*/
ifMetagenerationMatch: Option[String] = None,
/** If set, only deletes the folder if its metageneration does not match this value.
*/
ifMetagenerationNotMatch: Option[String] = None,
)
final case class GetParams(
/** Makes the return of the folder metadata conditional on whether the folder's current metageneration matches the given value.
*/
ifMetagenerationMatch: Option[String] = None,
/** Makes the return of the folder metadata conditional on whether the folder's current metageneration does not match the given value.
*/
ifMetagenerationNotMatch: Option[String] = None,
)
final case class ListParams(
/** Returns results in a directory-like mode. The only supported value is '/'. If set, items will only contain folders that either exactly match the prefix, or are one level below the prefix.
*/
delimiter: Option[String] = None,
/** Filter results to folders whose names are lexicographically before endOffset. If startOffset is also set, the folders listed will have names between startOffset (inclusive) and endOffset (exclusive).
*/
endOffset: Option[String] = None,
/** Maximum number of items to return in a single page of responses.
*/
pageSize: Option[Int] = None,
/** A previously-returned page token representing part of the larger set of results to view.
*/
pageToken: Option[String] = None,
/** Filter results to folders whose paths begin with this prefix. If set, the value must either be an empty string or end with a '/'.
*/
prefix: Option[String] = None,
/** Filter results to folders whose names are lexicographically equal to or after startOffset. If endOffset is also set, the folders listed will have names between startOffset (inclusive) and endOffset (exclusive).
*/
startOffset: Option[String] = None,
)
}