Swiftpack.co - Package - vapor-community/google-cloud-kit


Swift NIO

This project aims to bring over as many Google Cloud Platform APIs as possible to server side swift projects built on top of Swift NIO.

Because the products and API's are so vast this will start slowly and over time add more API's as time goes on.


Before you begin note that this package only supports using Service accounts to authenticate to the various Google Cloud Platform APIs using OAuth2.

  1. Select or create a Cloud Platform project.

Go to the projects page

  1. Enable billing for your project.

[Enable billing](https://raw.github.com/vapor-community/google-cloud-kit/master/ https://support.google.com/cloud/answer/6293499#enable-billing)

  1. Enable the Google Cloud Storage API.

Enable the API

  1. Set up authentication with a service account so you can access the API from your local workstation.

To begin using GogleCloudKit in your project you'll need to setup the initial configuration.

In your Package.swift file, add the following

.package(url: "https://github.com/vapor-community/google-cloud-kit.git", from: "1.0.0-alpha.1")

Now setup the configuration.

 import GoogleCloudKit
 let credentialsConfig = GoogleCloudCredentialsConfiguration(project: "myprojectid-12345", credentialsFile: "/path/to/service-account.json")

Optionally, you can register an empty GoogleCloudCredentialsConfiguration() and configure the following environment variables:

export PROJECT_ID=myprojectid-12345
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account.json

Additionally, you can copy and paste the contents of your Service Account JSON file as the value for the GOOGLE_APPLICATION_CREDENTIALS environment variable:


Currently the following API's are implemented and you can follow the setup guides for each specific API to integrate with your project.


Stars: 20

Used By

Total: 0


RC 4 -

Updates to the release version of JWTKit

1.0.0 RC 3 -

Fixes and enhancements. Breaking changes ⚠️

GoogleCloudKit RC 2 -

This release includes a few fixes and enhancements

  • Fixes a stray ) in cloud storage #21
  • Fixes ~ not being read as the home directory #22
  • Clean up and convenience helpers for Datastore API #23 #25

GoogleCloudKit RC 1 -

This release adds basic support for the cloud DataStore API.

GoogleCloudKit 1.0.0 Alpha 11 -

This release removes the exact requirement for using async-http-client. We're generally trust worthy of the NIO developers to follow semversion.

GoogleCloudKit 1.0.0 Alpha 10 -

GoogleCloudKit 1.0.0 Alpha 9 -

This release updates the library to require swift 5.2. Added a hopped eventloop helper for GoogleCloudStorageClient.

GoogleCloudKit Alpha 8 -

This release adds the subscription field to the GoogleCloudAPIConfiguration protocol. This allows specific configuration for APIs to accept a subscription when creating JWT tokens if they need to do so.

GoogleCloudKit Alpha 7 -

This release updates the GoogleCloudCredentialsConfiguration to perform the work of reading the service account from disk rather than having GoogleCloudStorageClient do it.

This approach has the benefit of reducing overhead by not having to block and read from disk if a user initializes a GoogleCloudStorageClient in a computed property for example. Setting up the configuration to perform that work steers a user to do that operation once and in a manner where a system is still initializing and it's ok to take that overhead.

GoogleCloudKit Alpha 6 -

This version has breaking changes. It's now required when initializing a new APIClient GoogleCloudStorageClient for example, to provide an HTTPClient and an event loop you want to be notified on when a promise resolves.

let credentialsConfiguration = GoogleCloudCredentialsConfiguration()

let cloudStorageConfiguration: GoogleCloudStorageConfiguration = .default()
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let client = HTTPClient(eventLoopGroupProvider: .shared(elg),
                        configuration: .init(ignoreUncleanSSLShutdown: true))
let gcs = try GoogleCloudStorageClient(credentials: credentialsConfiguration, storageConfig: cloudStorageConfiguration, httpClient: client, eventLoop: elg.next())

GoogleCloudKit 1.0.0 Alpha 5 -

GoogleCloudKit Alpha 4.0.0 -

This release updates the JWT package to the latest implementation from JWTKit

GoogleCloudKit Alpha 3.0.1 -

Fixed a bug with shutting down the http client when no project id is set.

GoogleCloudKit Alpha 3 -

This release makes the library modular and sets up the package to be flexible in which APIs you use.

for example instead of just importing GoogleCloudKit and having to compile every API that's implemented, you can specifically import the API you're looking to use

import GoogleCloudKit // Compiles CloudStorage library, PubSub library, etc...
import Storage // Only compiles CloudStorage

GoogleCloudKit Alpha 2.1.1 -

Fixes an issue where we weren't shutting down the AsyncHTTPClient on deinit

GoogleCloudKit Alpha 2.1 -

Added a fix for an empty 404 response that may be returned by google.

GoogleCloudKit Alpha 2 -

Updated to use latest version of AsyncHTTPClient Made StorageClient initializer take an eventloop Fixed storage upload URL Updated README

GoogleCloudKit Alpha 1.2 -

GoogleCloudStorageClient's initializer is now public.

GoogleCloudKit Alpha 1.1 -

Finished the object API implementation

GoogleCloudKit 1.0.0 Alpha 1 -

Not completely finished just yet. Still have to implement a few more APIs in the Storage Object API. Only Cloud Storage is supported right now.