Packaging

From DreamFactory
Jump to: navigation, search

Tutorial

Packaging in DreamFactory allows for easily exporting various system resources from one instance and importing them to another.

API Endpoint

Export a Package Manifest only

GET https://your-url/api/v2/system/package

Export a Package

POST https://your-url/api/v2/system/package 

<source lang="JavaScript"> {

   "service":{
           "system":{
               "role":[1,2,3]
           }
   }

} </source>

Import a Package

POST https://your-url/api/v2/system/package?import_url=<package url>

-- OR --

Using multipart/form-data POST

curl --form [email protected] http://your-url/api/v2/system/package

Example - Export a Package Manifest

GET http://foo.com/api/v2/system/package

Example - Export a Package Manifest for system services only

GET http://foo.com/api/v2/system/package?system_only=true

Example - Export a Package with various resources

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> {

“service": {
   	"system": {
     		"role": [“role1”,“role2”],
     		"service": [

“DB", “mailgun", “script", “s3", “mysql", “math-py" ],

     		"app": [“add_angular2",“my-test-app"],
     		"user": [“[email protected]",“[email protected]"],
     		"admin": ["[email protected]"],
     		"custom": ["adminPreferences"],
     		"cors": [6,7],
     		"email_template": [“test_email_template","test_template"],
     		"event": [
       			"mydb._table.contact.{id}.patch.pre_process",
       			"user.register.post.post_process"
     		],
     		"lookup": ["host","user"]
   	},
   	"DB": {
     		"_schema": [“contact_group","contact_info"]
   	},
   	"mydb": {
     		"_schema": [“contact","todo"]
   	},
   	"mysql": {
     		"_schema": [“contact","todo"]
   	},
   	"files": [
     		"applications/",
     		"projects/",
     		"testfiles.zip"
   	],
   	"s3": [
     		"my_images/",
     		"work/"
   	]
 }

} </source>

Example - Exporting Package resources using id

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “service”:{ “system”:{ “role”:[1,2,3] // Exporting roles with id 1,2,3 } } } </source>

Example - Exporting Package resources using filter

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “service”:{ “system”:{ “service”:{ “filter”:”name like ’test_%’” } } } } </source>

Example - Exporting Package resources with related data

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “service”:{ “system”:{ “role”:{ “ids”:[1,2,3], // Exporting roles with id 1,2,3 “related”:[ “app_by_role_id”, “role_service_access_by_role_id” ] } } } } </source>

Example - Exporting Package resources with related data using filter

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “service”:{ “system”:{ … “role”:{ “filter”:”name like ’test_%’”, “related”:[ “app_by_role_id”, “role_service_access_by_role_id” ] } } } } </source>

Example - Exporting storage resources in Package

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “service”:{ “files”:[ // Name of your storage service “css/”, // Storage folders to export “assets/“, “images/buttons/“, “app.js”, // Storage files to export “index.html” ] } } </source>


Example - Exporting schemas from database service

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “service”:{ “db”:{ // Name of your database service “_schema”:[ // Export _schema resource “table1”, // Name of your tables “table2”, “table3” ] } } } </source>

Example - Storing exported package using a storage service

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “storage”:{ “name”:”s3”, // Name of the storage service “folder”:”my-exports”, // Folder to store your package in }, “service”:{ “system”:{ “role”:[1,2,3] // Exporting roles with id 1,2,3 … } } } </source>

Example - Storing exported package using a storage service and a custom filename

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “storage”:{ “name”:”s3”, // Name of the storage service “folder”:”my-exports”, // Folder to store your package in “filename”:”my-package.zip” // Name of your package file }, “service”:{ “system”:{ “role”:[1,2,3] // Exporting roles with id 1,2,3 } } } </source>

Example - Exporting a Package securely

POST http://foo.com/api/v2/system/package

<source lang="JavaScript"> { “secured”:true, // Set this true for secure package “password”:”secret”, // Must provide a password for secure package “service”:{ “system”:{ “service”:[“db”,”s3”] // Service configs are encrypted } } } </source>


Example - Importing a Package using multipart/form-data

curl --form [email protected] http://foo.com/api/v2/system/package

Example - Importing a secured Package using multipart/form-data

curl --form [email protected] password=secret http://foo.com/api/v2/system/package

Example - Importing a Package using URL import

POST http://foo.com/api/v2/system/package?import_url=http://foobar.com/packages/my-package.zip

Example - Importing a secured Package using URL import

POST http://foo.com/api/v2/system/package?import_url=http://foobar.com/packages/my-package.zip?password=secured

Example - Importing a Package from command line

php artisan dreamfactory:import-pkg /path/to/package/folder_or_file_or_url

Example - Importing a secured Package from command line

php artisan dreamfactory:import-pkg /path/to/package/folder_or_file_or_url --password=secret