Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove servant and conduit #177

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Remove servant and conduit #177

wants to merge 9 commits into from

Conversation

brendanhay
Copy link
Owner

@brendanhay brendanhay commented Mar 19, 2022

Various updates/fixes to eventually be catalogued here.

  1. Per-service OAuth scopes are now generated as type aliases of the form:
-- | View and manage your data across Google Cloud Platform services
type CloudPlatform'FullControl = "https://www.googleapis.com/auth/cloud-platform"

-- | View your data across Google Cloud Platform services
type CloudPlatform'ReadOnly = "https://www.googleapis.com/auth/cloud-platform.read-only"

-- | Manage your data and permissions in Google Cloud Storage
type Devstorage'FullControl = "https://www.googleapis.com/auth/devstorage.full_control"

-- | View your data in Google Cloud Storage
type Devstorage'ReadOnly = "https://www.googleapis.com/auth/devstorage.read_only"

-- | Manage your data in Google Cloud Storage
type Devstorage'ReadWrite = "https://www.googleapis.com/auth/devstorage.read_write"
  1. A per-service parameters datatype matching the service definitions global parameters is synthesised by the generator - this will be supplied to some variant of send as a first-class value so you can, say, add the apiKey parameter to requests:
-- /See:/ 'newStorageParams' smart constructor.
data StorageParams = StorageParams
  { -- | Selector specifying which fields to include in a partial response.
    fields :: Core.Maybe Core.Text,
    -- | API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
    key :: Core.Maybe Core.Text,
    -- | OAuth 2.0 token for the current user.
    oauthToken :: Core.Maybe Core.Text,
    -- | Returns response with indentations and line breaks.
    prettyPrint :: Core.Bool,
    -- | An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
    quotaUser :: Core.Maybe Core.Text
  }
  deriving (Core.Eq, Core.Ord, Core.Show, Core.Generic)

newStorageParams :: StorageParams
newStorageParams =
  StorageParams
    { fields = Core.Nothing,
      key = Core.Nothing,
      oauthToken = Core.Nothing,
      prettyPrint = Core.False,
      quotaUser = Core.Nothing
    }
  1. Servant is being removed and GoogleRequest instances are generated which construct an http-client Request (or possiblly an intermediate request datatype):
instance Core.GoogleRequest StorageObjectsInsert where
  type GoogleResponse StorageObjectsInsert = Object
  type GoogleScopes StorageObjectsInsert = '[ CloudPlatform'FullControl, Devstorage'FullControl, Devstorage'ReadWrite]
  type GoogleParams StorageObjectsInsert = StorageParams
  googleRequest StorageParams {..} StorageObjectsInsert {..} =
      Core.defaultRequest
        { method = "POST",
          path = Core.toRequestPath [ "storage/v1/b/", Core.toPathBuilder bucket, "/o"],
          queryString =
            Core.toRequestQuery $
              Core.catMaybes
                [ ("contentEncoding",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> contentEncoding,
                  ("ifGenerationMatch",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> ifGenerationMatch,
                  ("ifGenerationNotMatch",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> ifGenerationNotMatch,
                  ("ifMetagenerationMatch",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> ifMetagenerationMatch,
                  ("ifMetagenerationNotMatch",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> ifMetagenerationNotMatch,
                  ("key",) Core.. Core.toQueryParamBuilder
                    Core.<$> key,
                  ("kmsKeyName",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> kmsKeyName,
                  ("name",) Core.. Core.toQueryParamBuilder
                    Core.<$> name,
                  ("oauth_token",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> oauthToken,
                  ("predefinedAcl",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> predefinedAcl,
                  ("projection",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> projection,
                  ("provisionalUserProject",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> provisionalUserProject,
                  ("userProject",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> userProject,
                  ("quotaUser",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> quotaUser,
                  Core.Just
                    ( "prettyPrint",
                      Core.toQueryParamBuilder prettyPrint
                    ),
                  ("fields",)
                    Core.. Core.toQueryParamBuilder
                    Core.<$> fields,
                  Core.Just ("alt", Core.AltJSON)
                ],
          requestBody = Core.toRequestBodyJSON payload
        }

@brendanhay
Copy link
Owner Author

I've posted some thoughts regarding the ergonomics of constructing records with smart constructors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant