{"id":22733915,"url":"https://github.com/permutive-engineering/common-types-gcp","last_synced_at":"2025-03-30T02:11:45.997Z","repository":{"id":244494945,"uuid":"759142387","full_name":"permutive-engineering/common-types-gcp","owner":"permutive-engineering","description":"GPC common types that can be used on any Scala services or libraries","archived":false,"fork":false,"pushed_at":"2024-12-01T05:03:52.000Z","size":61,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-05T04:32:48.679Z","etag":null,"topics":["gcp","google-cloud","google-cloud-platform","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/permutive-engineering.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-17T19:02:50.000Z","updated_at":"2024-09-18T14:45:40.000Z","dependencies_parsed_at":"2024-07-15T06:24:38.022Z","dependency_job_id":"dae5d3ae-b02c-4650-bf61-63c0a9bf16ec","html_url":"https://github.com/permutive-engineering/common-types-gcp","commit_stats":null,"previous_names":["permutive-engineering/common-types-gcp"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutive-engineering%2Fcommon-types-gcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutive-engineering%2Fcommon-types-gcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutive-engineering%2Fcommon-types-gcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutive-engineering%2Fcommon-types-gcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/permutive-engineering","download_url":"https://codeload.github.com/permutive-engineering/common-types-gcp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246266244,"owners_count":20749754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gcp","google-cloud","google-cloud-platform","scala"],"created_at":"2024-12-10T20:16:58.335Z","updated_at":"2025-03-30T02:11:45.981Z","avatar_url":"https://github.com/permutive-engineering.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `common-types-gcp`\n\nGPC common types that can be used on any Scala services or libraries.\n\nThe list of common types are:\n\n- [`DatasetName`](modules/common-types-gcp/src/main/scala/com/permutive/common/types/gcp/DatasetName.scala)\n- [`DatasetMultiRegion`](modules/common-types-gcp/src/main/scala/com/permutive/common/types/gcp/DatasetMultiRegion.scala)\n- [`ProjectId`](modules/common-types-gcp/src/main/scala/com/permutive/common/types/gcp/ProjectId.scala)\n\n---\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Integrations](#integrations)\n  - [`common-types-gcp-circe`](#common-types-gcp-circe)\n    - [Installation](#installation)\n    - [Usage](#usage)\n  - [`common-types-gcp-http4s`](#common-types-gcp-http4s)\n    - [Installation](#installation)\n    - [Usage](#usage)\n  - [`common-types-gcp-pureconfig`](#common-types-gcp-pureconfig)\n    - [Installation](#installation)\n    - [Usage](#usage)\n  - [`common-types-gcp-tapir`](#common-types-gcp-tapir)\n    - [Installation](#installation)\n    - [Usage](#usage)\n  - [`common-types-gcp-scalacheck`](#common-types-gcp-scalacheck)\n    - [Installation](#installation)\n    - [Usage](#usage)\n- [Contributors to this project](#contributors-to-this-project)\n\n## Installation\n\nAdd the following dependency to your project:\n\n```sbt\n\"com.permutive\" %% \"common-types-gcp\" % \"1.1.0\"\n```\n\n## Usage\n\nEvery type includes implicit instances for cats' `Eq`, `Show`, `Order`, `Hash`.\n\nIn addition, types like `ProjectId` also contain smart constructors:\n\n**Obtaining the current `ProjectId` from Google's metadata service:**\n\n```scala\nimport cats.Eval\n\nval projectId: Eval[ProjectId] = ProjectId.unsafeFromGCP()\n```\n\n\u003e 👆🏼 This method will only return a valid project ID if run inside a workload.\n\n**Creating a random value:**\n\n```scala\nval projectId: ProjectId = ProjectId.random()\n```\n\n\u003e 👆🏼 It will raise a warning if used outside `Test` or `IntegrationTest` configurations\n\n**Creating a value from a string (returning `Either`):**\n\n\n```scala\nval projectId: Either[String, ProjectId]=\n  ProjectId.fromString(\"test-project\")\n```\n\n**Effectful alternative:**\n\n\n```scala\nval projectId: IO[ProjectId]=\n  ProjectId.fromStringF[IO](\"test-project\")\n```\n\n**Creating a value from a literal string:**\n\n\n```scala\nval projectId: ProjectId = ProjectId(\"test-project\")\n```\n\n\u003e 👆🏼 It will fail at compile time if not a project ID or not using a literal.\n\n## Integrations\n\n### `common-types-gcp-circe`\n\n#### Installation\n\nAdd the following dependency to your project:\n\n```sbt\n\"com.permutive\" %% \"common-types-gcp-circe\" % \"1.1.0\"\n```\n\n#### Usage\n\nJust add the following import:\n\n```scala\nimport com.permutive.common.types.gcp.circe._\n```\n\nIt will bring `Encoder`, `Decoder`, `KeyEncoder` \u0026 `KeyDecoder` instances for the\navailable types into scope.\n\n### `common-types-gcp-http4s`\n\n#### Installation\n\nAdd the following dependency to your project:\n\n```sbt\n\"com.permutive\" %% \"common-types-gcp-http4s\" % \"1.1.0\"\n```\n\n#### Usage\n\nJust add the following import:\n\n```scala\nimport com.permutive.common.types.gcp.http4s._\n```\n\nIt will bring `SegmentEncoder`, `QueryParamEncoder` \u0026 `QueryParamDecoder`\ninstances for the available types into scope.\n\n### `common-types-gcp-pureconfig`\n\n#### Installation\n\nAdd the following dependency to your project:\n\n```sbt\n\"com.permutive\" %% \"common-types-gcp-pureconfig\" % \"1.1.0\"\n```\n\n#### Usage\n\nJust add the following import:\n\n```scala\nimport com.permutive.common.types.gcp.pureconfig._\n```\n\nIt will bring `ConfigReader` \u0026 `ConfigWriter` instances for the available types\ninto scope.\n\nFor the case of `ProjectId` you can use the special value `gcp` on your\n`application.conf` when running inside a workload and it will retrieve the\ncurrent `ProjectId` from Google's metadata service.\n\n### `common-types-gcp-tapir`\n\n#### Installation\n\nAdd the following dependency to your project:\n\n```sbt\n\"com.permutive\" %% \"common-types-gcp-tapir\" % \"1.1.0\"\n```\n\n#### Usage\n\nJust add the following import:\n\n```scala\nimport com.permutive.common.types.gcp.tapir._\n```\n\nIt will bring `Codec`/`Schema` instances for the available types, as well as adding a new extension method (`example`) to common types' companion objects that can be used to add an example value to tapir endpoints:\n\n```scala\nimport com.permutive.common.types.gcp.ProjectId\nimport com.permutive.common.types.gcp.tapir._\n\nimport sttp.tapir._\n\nendpoint.get\n  .in(\"projects\")\n  .in(path[ProjectId](\"project_id\").example(ProjectId.example))\n// res12: Endpoint[Unit, typelevel.LowPriorityTupleConcat0.\u003crefinement\u003e.this.type.Out, Unit, Unit, Any] = Endpoint(\n//   securityInput = Empty(\n//     codec = sttp.tapir.Codec$$anon$4@7cc62914,\n//     info = Info(\n//       description = None,\n//       examples = List(),\n//       deprecated = false,\n//       attributes = AttributeMap(storage = Map())\n//     )\n//   ),\n//   input = Pair(\n//     left = Pair(\n//       left = Pair(\n//         left = Empty(\n//           codec = sttp.tapir.Codec$$anon$4@7cc62914,\n//           info = Info(\n//             description = None,\n//             examples = List(),\n//             deprecated = false,\n//             attributes = AttributeMap(storage = Map())\n//           )\n//         ),\n//         right = FixedMethod(\n//           m = Method(method = \"GET\"),\n//           codec = sttp.tapir.Codec$$anon$4@24e399bf,\n//           info = Info(\n//             description = None,\n//             examples = List(),\n//             deprecated = false,\n//             attributes = AttributeMap(storage = Map())\n//           )\n//         ),\n//         combine = sttp.tapir.internal.package$$$Lambda$14987/0x00007f4b5697e6e0@6836a99b,\n//         split = sttp.tapir.internal.package$$$Lambda$14988/0x00007f4b5697ec88@45bf623a\n//       ),\n//       right = FixedPath(\n//         s = \"projects\",\n//         codec = sttp.tapir.Codec$$anon$4@4a282bc6,\n//         info = Info(\n//           description = None,\n//           examples = List(),\n//           deprecated = false,\n//           attributes = AttributeMap(storage = Map())\n//         )\n//       ),\n//       combine = sttp.tapir.internal.package$$$Lambda$14989/0x00007f4b5697f7c8@72be7d5d,\n// ...\n```\n\n### `common-types-gcp-scalacheck`\n\n#### Installation\n\nAdd the following dependency to your project:\n\n```sbt\n\"com.permutive\" %% \"common-types-gcp-scalacheck\" % \"1.1.0\"\n```\n\n#### Usage\n\nJust add the following import:\n\n```scala\nimport com.permutive.common.types.gcp.scalacheck._\n```\n\nIt will bring `Arbitrary` instances for the available types into scope.\n\n## Contributors to this project\n\n| \u003ca href=\"https://github.com/alejandrohdezma\"\u003e\u003cimg alt=\"alejandrohdezma\" src=\"https://avatars.githubusercontent.com/u/9027541?v=4\u0026s=120\" width=\"120px\" /\u003e\u003c/a\u003e |\n| :--: |\n| \u003ca href=\"https://github.com/alejandrohdezma\"\u003e\u003csub\u003e\u003cb\u003ealejandrohdezma\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermutive-engineering%2Fcommon-types-gcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpermutive-engineering%2Fcommon-types-gcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermutive-engineering%2Fcommon-types-gcp/lists"}