0.1.1 • Published 4 years ago

file-api-create-folder v0.1.1

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

AutoML File API - Create Folder

HTTP Triggered Google Cloud Function for creating Folder Entries in Firestore

Bitbucket Configuration

The bucket pipeline requires the following variables for BOTH Test and Production deployment environments.

Environments Variables

VariableUsage
SLS_STAGEServerless Stage, valid parameters are dev and prod.
GCP_PROJECTProject ID to deploy to.
GCP_REGIONRegion to deploy to.
GCP_KEY_FILEbase64 encoded contents of the GCP key file

Prerequisites

  • You will also need credentials for the cloud provider you will be deploying to.
  • Check out the documentation for the cloud provider you are interested in the official serverless documentation.

Google Cloud Platform:

  • Create a GCP project.
  • Create an IAM member with at least a minimum set of roles: Deployment Manager Editor, Storage Admin, Logging Admin, Cloud Functions Developer and other needed for your resources.
  • Create service account for your project.
  • Create, download and save private_key.json. You will use it as your credentials in the serverless.yml.
  • Enable the Cloud Functions API.
  • Enable the Cloud Deployment Manager V2 API.
  • Enable the Cloud Storage.
  • Enable the Stackdriver Logging

For base64 encoded contents required by GCP_KEY_FILE variable use command:

Linux

base64 -w 0 < GCP_key

Create Folder

To create a folder entry, use this snippet:

curl 'https://"$BASE_URL"/create_folder' \
  -X POST \
  -H "Content-Type: application/json" \
  -d @request.json

In request.json:

{
  "name": "New Folder"
}

The above command returns JSON structured like this:

{
  "message": "Folder Created",
  "payload": {
    "id": "ad603de7-ab99-46eb-95bd-d0e47b793678",
    "name": "New Folder",
    "created_at": "1579517552",
    "updated_at": "1579517552"
  }
}

This endpoint creates a folder entry in Firestore

HTTP Request

POST /create_folder

Request Body

ParameterTypeDescription
namestringRequired. The folder's display name.

Response Body

ParameterTypeDescription
messagestringMessage.
payloadFolderCreated folder entry.
errorstringError.

Status Code

CodeDescription
200Folder created.
400Bad request.

Folder Interface

Parameters

NameTypeDescription
idstringUnique id of the Folder.
namestringFolder Name
created_atTimestampCreated Date
updated_atTimestampLast Updated Date