Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p lambda-cloudformation-custom-resource/.js/target lambda-http4s/.jvm/target unidocs/target lambda-http4s/.js/target lambda/js/target scalafix/rules/target lambda/jvm/target sbt-lambda/target google-cloud-http4s/jvm/target lambda-cloudformation-custom-resource/.jvm/target google-cloud-http4s/js/target project/target
run: mkdir -p lambda-cloudformation-custom-resource/.js/target lambda-http4s/.jvm/target unidocs/target google-cloud/js/target lambda-http4s/.js/target lambda/js/target scalafix/rules/target lambda/jvm/target sbt-lambda/target google-cloud-http4s/jvm/target lambda-cloudformation-custom-resource/.jvm/target google-cloud-http4s/js/target google-cloud/jvm/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar lambda-cloudformation-custom-resource/.js/target lambda-http4s/.jvm/target unidocs/target lambda-http4s/.js/target lambda/js/target scalafix/rules/target lambda/jvm/target sbt-lambda/target google-cloud-http4s/jvm/target lambda-cloudformation-custom-resource/.jvm/target google-cloud-http4s/js/target project/target
run: tar cf targets.tar lambda-cloudformation-custom-resource/.js/target lambda-http4s/.jvm/target unidocs/target google-cloud/js/target lambda-http4s/.js/target lambda/js/target scalafix/rules/target lambda/jvm/target sbt-lambda/target google-cloud-http4s/jvm/target lambda-cloudformation-custom-resource/.jvm/target google-cloud-http4s/js/target google-cloud/jvm/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand Down
8 changes: 8 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ pull_request_rules:
add:
- examples
remove: []
- name: Label google-cloud PRs
conditions:
- files~=^google-cloud/
actions:
label:
add:
- google-cloud
remove: []
- name: Label google-cloud-http4s PRs
conditions:
- files~=^google-cloud-http4s/
Expand Down
30 changes: 30 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ lazy val root =
lambdaHttp4s,
lambdaCloudFormationCustomResource,
googleCloudHttp4s,
googleCloud,
examples,
unidocs
)
Expand Down Expand Up @@ -271,3 +272,32 @@ lazy val googleCloudHttp4s = crossProject(JSPlatform, JVMPlatform)
"co.fs2" %%% "fs2-io" % fs2Version
)
)

lazy val googleCloud = crossProject(JSPlatform, JVMPlatform)
.in(file("google-cloud"))
.settings(
name := "feral-google-cloud",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-effect" % catsEffectVersion,
"org.scodec" %%% "scodec-bits" % "1.2.0",
"io.circe" %%% "circe-core" % circeVersion,
"io.circe" %%% "circe-generic" % circeVersion,
"org.scalameta" %%% "munit-scalacheck" % munitVersion % Test,
"org.typelevel" %%% "munit-cats-effect" % munitCEVersion % Test,
"io.circe" %%% "circe-literal" % circeVersion % Test
),
tlVersionIntroduced := List("2.13", "3").map(_ -> "0.3.2").toMap
)
.settings(commonSettings)
.jsSettings(
libraryDependencies ++= Seq(
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0"
)
)
.jvmSettings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.google.cloud.functions" % "functions-framework-api" % "1.1.4" % Provided,
"co.fs2" %%% "fs2-io" % fs2Version
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2021 Typelevel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package feral.googlecloud
package events

import io.circe._
import scodec.bits.ByteVector

import java.time.Instant

sealed abstract class MessagePublishedData {
def message: PubsubMessage
def subscription: String
def deliveryAttempt: Option[Int]
}

object MessagePublishedData {

def apply(
message: PubsubMessage,
subscription: String,
deliveryAttempt: Option[Int] = None
): MessagePublishedData = {
new Impl(message, subscription, deliveryAttempt)
}

implicit val decoder: Decoder[MessagePublishedData] =
Decoder.forProduct3("message", "subscription", "deliveryAttempt")(
MessagePublishedData.apply
)

private final case class Impl(
message: PubsubMessage,
subscription: String,
deliveryAttempt: Option[Int]
) extends MessagePublishedData {
override def productPrefix = "MessagePublishedData"
}
}

sealed abstract class PubsubMessage {
def data: ByteVector
def attributes: Map[String, String]
def messageId: String
def publishTime: Instant
def orderingKey: Option[String]
}

object PubsubMessage {

def apply(
data: ByteVector,
attributes: Map[String, String],
messageId: String,
publishTime: Instant,
orderingKey: Option[String]
): PubsubMessage = {
new Impl(data, attributes, messageId, publishTime, orderingKey)
}

import codecs.{decodeByteVector, decodeInstant}

implicit val decoder: Decoder[PubsubMessage] = Decoder.forProduct5(
"data",
"attributes",
"messageId",
"publishTime",
"orderingKey"
)(PubsubMessage.apply)

private final case class Impl(
data: ByteVector,
attributes: Map[String, String],
messageId: String,
publishTime: Instant,
orderingKey: Option[String]
) extends PubsubMessage { override def productPrefix = "PubsubMessage" }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/*
* Copyright 2021 Typelevel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package feral.googlecloud.events

import io.circe._
import io.circe.generic.semiauto.deriveDecoder

import java.time.Instant

import codecs.decodeDateTimetoInstant

sealed abstract class StorageObjectData {
def contentEncoding: String
def contentDisposition: String
def cacheControl: String
def contentLanguage: String
def metageneration: Int
def timeDeleted: Option[Instant]
def contentType: String
def size: Int
def timeCreated: Option[Instant]
def crc32c: String
def componentCount: Int
def md5Hash: String
def etag: String
def updated: Option[Instant]
def storageClass: String
def kmsKeyName: String
def timeStorageClassUpdated: Option[Instant]
def temporaryHold: Boolean
def retentionExpirationTime: Option[Instant]
def metadata: Map[String, String]
def eventBasedHold: Boolean
def name: String
def id: String
def bucket: String
def generation: Int
def customerEncryption: CustomerEncryption
def mediaLink: String
def selfLink: String
def kind: String
}

object StorageObjectData {

def apply(
contentEncoding: String,
contentDisposition: String,
cacheControl: String,
contentLanguage: String,
metageneration: Int,
timeDeleted: Option[Instant],
contentType: String,
size: Int,
timeCreated: Option[Instant],
crc32c: String,
componentCount: Int,
md5Hash: String,
etag: String,
updated: Option[Instant],
storageClass: String,
kmsKeyName: String,
timeStorageClassUpdated: Option[Instant],
temporaryHold: Boolean,
retentionExpirationTime: Option[Instant],
metadata: Map[String, String],
eventBasedHold: Boolean,
name: String,
id: String,
bucket: String,
generation: Int,
customerEncryption: CustomerEncryption,
mediaLink: String,
selfLink: String,
kind: String
): StorageObjectData = {
new Impl(
contentEncoding,
contentDisposition,
cacheControl,
contentLanguage,
metageneration,
timeDeleted,
contentType,
size,
timeCreated,
crc32c,
componentCount,
md5Hash,
etag,
updated,
storageClass,
kmsKeyName,
timeStorageClassUpdated,
temporaryHold,
retentionExpirationTime,
metadata,
eventBasedHold,
name,
id,
bucket,
generation,
customerEncryption,
mediaLink,
selfLink,
kind
)
}

implicit val decoder: Decoder[StorageObjectData] = deriveDecoder[Impl].map(identity)

private final case class Impl(
contentEncoding: String,
contentDisposition: String,
cacheControl: String,
contentLanguage: String,
metageneration: Int,
timeDeleted: Option[Instant],
contentType: String,
size: Int,
timeCreated: Option[Instant],
crc32c: String,
componentCount: Int,
md5Hash: String,
etag: String,
updated: Option[Instant],
storageClass: String,
kmsKeyName: String,
timeStorageClassUpdated: Option[Instant],
temporaryHold: Boolean,
retentionExpirationTime: Option[Instant],
metadata: Map[String, String],
eventBasedHold: Boolean,
name: String,
id: String,
bucket: String,
generation: Int,
customerEncryption: CustomerEncryption,
mediaLink: String,
selfLink: String,
kind: String
) extends StorageObjectData {
override def productPrefix = "StorageObjectData"
}
}

sealed abstract class CustomerEncryption {
def encryptionAlgorithm: String
def keySha256: String
}

object CustomerEncryption {

def apply(
encryptionAlgorithm: String,
keySha256: String
): CustomerEncryption = {
new Impl(encryptionAlgorithm, keySha256)
}

implicit val decoder: Decoder[CustomerEncryption] =
Decoder.forProduct2("encryptionAlgorithm", "keySha256")(
CustomerEncryption.apply
)

private final case class Impl(encryptionAlgorithm: String, keySha256: String)
extends CustomerEncryption {
override def productPrefix = "CustomerEncryption"
}
}
Loading
Loading