packages feed

google-cloud-logging (empty) → 0.1.0.0

raw patch · 7 files changed

+173/−0 lines, 7 filesdep +aesondep +basedep +google-cloud-commonsetup-changed

Dependencies added: aeson, base, google-cloud-common, google-cloud-logging

Files

+ CHANGELOG.md view
@@ -0,0 +1,11 @@+# Changelog for `google-cloud-logging`++All notable changes to this project will be documented in this file.++The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),+and this project adheres to the+[Haskell Package Versioning Policy](https://pvp.haskell.org/).++## Unreleased++## 0.1.0.0 - YYYY-MM-DD
+ LICENSE view
@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2025 Tushar Adhatrao++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
+ README.md view
@@ -0,0 +1,5 @@+# google-cloud-logging++Haskell idiomatic client for [Google Cloud Platform](https://cloud.google.com/) Logging service.++Full docs are available at https://github.com/tusharad/google-cloud-haskell
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ google-cloud-logging.cabal view
@@ -0,0 +1,55 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.37.0.+--+-- see: https://github.com/sol/hpack++name:           google-cloud-logging+version:        0.1.0.0+synopsis:       GCP Client for Haskell+description:    GCP Logging client for Haskell+category:       Web+homepage:       https://github.com/tusharad/google-cloud-haskell#readme+bug-reports:    https://github.com/tusharad/google-cloud-haskell/issues+author:         tushar+maintainer:     tusharadhatrao@gmail.com+copyright:      2025 tushar+license:        MIT+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    README.md+    CHANGELOG.md++source-repository head+  type: git+  location: https://github.com/tusharad/google-cloud-haskell++library+  exposed-modules:+      Google.Cloud.Logging.Logs+  other-modules:+      Paths_google_cloud_logging+  hs-source-dirs:+      src+  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints+  build-depends:+      aeson <3+    , base >=4.7 && <5+    , google-cloud-common+  default-language: Haskell2010++test-suite google-cloud-logging-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Paths_google_cloud_logging+  hs-source-dirs:+      test+  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      aeson <3+    , base >=4.7 && <5+    , google-cloud-common+    , google-cloud-logging+  default-language: Haskell2010
+ src/Google/Cloud/Logging/Logs.hs view
@@ -0,0 +1,77 @@+{-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DuplicateRecordFields #-}++-- | A client module for interacting with Google Cloud Logging's log management API.+--+-- This module implements the v2 REST API for listing logs from GCP resources.+-- For API details, see: <https://cloud.google.com/logging/docs/reference/v2/rest/v2/logs/list GCP Logging API Documentation>++module Google.Cloud.Logging.Logs+  ( listLogs+  , Resource (..)+  , ListLogsResp (..)+  ) where++import Data.Aeson+import GHC.Generics+import Google.Cloud.Common.Core++-- | Represents GCP resources that can contain logs.+-- Constructors take the resource identifier as a String.+data Resource+  = Projects String       -- ^ A GCP Project resource with the given project ID+  | Organizations String  -- ^ A GCP Organization resource with the given organization ID+  | BillingAccount String -- ^ A GCP Billing Account resource with the given billing account ID+  | Folders String        -- ^ A GCP Folder resource with the given folder ID+  deriving (Eq, Show)++-- | Options for customizing the 'listLogs' request+data ListLogsOps = ListLogsOps+  { resourceNames :: [String]     -- ^ List of parent resource names to search (corresponds to 'resourceNames' query parameter)+  , pageSize :: Maybe Integer     -- ^ Maximum number of results to return (server may return fewer)+  , pageToken :: Maybe String     -- ^ Pagination token from previous 'ListLogsResp'+  }+  deriving (Eq, Show)++-- | Response from the Cloud Logging API containing log resources+data ListLogsResp = ListLogsResp+  { logNames :: [String]         -- ^ List of log resource names matching the request+  , nextPageToken :: Maybe String -- ^ Pagination token for next batch of results (if any)+  }+  deriving (Eq, Show, Generic, FromJSON)++-- | Internal helper to convert a Resource to a URL path component+toResource :: Resource -> [String]+toResource resource =+  case resource of+    Projects str -> ["projects", str]+    Organizations str -> ["organizations", str]+    BillingAccount str -> ["billingAccounts", str]+    Folders str -> ["folders", str]++-- | List log resource names from a GCP resource+--+-- Example:+--+-- > listLogs (Projects "my-project") Nothing+--+-- This makes a request to @v2/projects/my-project/logs@+--+-- Returns 'Either' with error message or 'ListLogsResp' containing:+-- * Matching log resource names+-- * Pagination token for subsequent requests+listLogs :: Resource           -- ^ Parent GCP resource to list logs from+         -> Maybe ListLogsOps  -- ^ Optional parameters for pagination and filtering+         -> IO (Either String ListLogsResp)+listLogs resource _ =+  doRequestJSON+    RequestOptions+      { reqMethod = GET+      , reqUrl = googleLoggingUrl+      , mbQueryParams = Nothing+      , mbReqBody = Nothing+      , mbReqHeaders = Nothing+      , mbReqPath =+          Just $ toPath $ toResource resource <> ["logs"]+      }
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"