scala.googleapis.storage.ManagedFoldersClient.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 ManagedFoldersClient[F[_]: Concurrent](client: Client[F]) extends AbstractClient[F](client) {
val baseUri = uri"https://storage.googleapis.com/storage/v1"
def testIamPermissions(
/** Name of the bucket containing the managed folder.
*/
bucket: String,
/** The managed folder name/path.
*/
managedFolder: String,
query: ManagedFoldersClient.TestIamPermissionsParams =
ManagedFoldersClient.TestIamPermissionsParams(),
): F[TestIamPermissionsResponse] = expectJson[TestIamPermissionsResponse](
request(
method = Method.GET,
uri = (baseUri / "b" / s"${bucket}" / "managedFolders" / s"${managedFolder}" / "iam" / "testPermissions")
.copy(query = Query("permissions" -> query.permissions, "userProject" -> query.userProject)),
)
)
def insert(
/** Name of the bucket containing the managed folder.
*/
bucket: String
)(input: ManagedFolder): F[ManagedFolder] = expectJson[ManagedFolder](
requestWithBody(method = Method.POST, uri = baseUri / "b" / s"${bucket}" / "managedFolders")(
input
)
)
def setIamPolicy(
/** Name of the bucket containing the managed folder.
*/
bucket: String,
/** The managed folder name/path.
*/
managedFolder: String,
query: ManagedFoldersClient.SetIamPolicyParams = ManagedFoldersClient.SetIamPolicyParams(),
)(input: Policy): F[Policy] = expectJson[Policy](
requestWithBody(
method = Method.PUT,
uri = (baseUri / "b" / s"${bucket}" / "managedFolders" / s"${managedFolder}" / "iam")
.copy(query = Query("userProject" -> query.userProject)),
)(input)
)
def getIamPolicy(
/** Name of the bucket containing the managed folder.
*/
bucket: String,
/** The managed folder name/path.
*/
managedFolder: String,
query: ManagedFoldersClient.GetIamPolicyParams = ManagedFoldersClient.GetIamPolicyParams(),
): F[Policy] = expectJson[Policy](
request(
method = Method.GET,
uri =
(baseUri / "b" / s"${bucket}" / "managedFolders" / s"${managedFolder}" / "iam").copy(query =
Query(
"optionsRequestedPolicyVersion" -> query.optionsRequestedPolicyVersion.map(s =>
QueryParamEncoder[Int].encode(s).value
),
"userProject" -> query.userProject,
)
),
)
)
def delete(
/** Name of the bucket containing the managed folder.
*/
bucket: String,
/** The managed folder name/path.
*/
managedFolder: String,
query: ManagedFoldersClient.DeleteParams = ManagedFoldersClient.DeleteParams(),
): F[Status] = client.status(
request(
method = Method.DELETE,
uri = (baseUri / "b" / s"${bucket}" / "managedFolders" / s"${managedFolder}").copy(query =
Query(
"allowNonEmpty" -> query.allowNonEmpty.map(s =>
QueryParamEncoder[Boolean].encode(s).value
),
"ifMetagenerationMatch" -> query.ifMetagenerationMatch,
"ifMetagenerationNotMatch" -> query.ifMetagenerationNotMatch,
)
),
)
)
def get(
/** Name of the bucket containing the managed folder.
*/
bucket: String,
/** The managed folder name/path.
*/
managedFolder: String,
query: ManagedFoldersClient.GetParams = ManagedFoldersClient.GetParams(),
): F[ManagedFolder] = expectJson[ManagedFolder](
request(
method = Method.GET,
uri = (baseUri / "b" / s"${bucket}" / "managedFolders" / s"${managedFolder}").copy(query =
Query(
"ifMetagenerationMatch" -> query.ifMetagenerationMatch,
"ifMetagenerationNotMatch" -> query.ifMetagenerationNotMatch,
)
),
)
)
def list(
/** Name of the bucket containing the managed folder.
*/
bucket: String,
query: ManagedFoldersClient.ListParams = ManagedFoldersClient.ListParams(),
): F[ManagedFolders] = expectJson[ManagedFolders](
request(
method = Method.GET,
uri = (baseUri / "b" / s"${bucket}" / "managedFolders").copy(query =
Query(
"pageSize" -> query.pageSize.map(s => QueryParamEncoder[Int].encode(s).value),
"pageToken" -> query.pageToken,
"prefix" -> query.prefix,
)
),
)
)
}
object ManagedFoldersClient {
final case class TestIamPermissionsParams(
/** Permissions to test.
*/
permissions: Option[String] = None,
/** The project to be billed for this request. Required for Requester Pays buckets.
*/
userProject: Option[String] = None,
)
final case class SetIamPolicyParams(
/** The project to be billed for this request. Required for Requester Pays buckets.
*/
userProject: Option[String] = None
)
final case class GetIamPolicyParams(
/** The IAM policy format version to be returned. If the optionsRequestedPolicyVersion is for an older version that doesn't support part of the requested IAM policy, the request fails.
*/
optionsRequestedPolicyVersion: Option[Int] = None,
/** The project to be billed for this request. Required for Requester Pays buckets.
*/
userProject: Option[String] = None,
)
final case class DeleteParams(
/** Allows the deletion of a managed folder even if it is not empty. A managed folder is empty if there are no objects or managed folders that it applies to. Callers must have storage.managedFolders.setIamPolicy permission.
*/
allowNonEmpty: Option[Boolean] = None,
/** If set, only deletes the managed folder if its metageneration matches this value.
*/
ifMetagenerationMatch: Option[String] = None,
/** If set, only deletes the managed folder if its metageneration does not match this value.
*/
ifMetagenerationNotMatch: Option[String] = None,
)
final case class GetParams(
/** Makes the return of the managed folder metadata conditional on whether the managed folder's current metageneration matches the given value.
*/
ifMetagenerationMatch: Option[String] = None,
/** Makes the return of the managed folder metadata conditional on whether the managed folder's current metageneration does not match the given value.
*/
ifMetagenerationNotMatch: Option[String] = None,
)
final case class ListParams(
/** 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,
/** The managed folder name/path prefix to filter the output list of results.
*/
prefix: Option[String] = None,
)
}