Packaging

From DreamFactory
Jump to: navigation, search
m (Toddappleton moved page DreamFactory/Tutorials/Deployment/Packaging to DreamFactory/Tutorials/Packaging without leaving a redirect)
Line 1: Line 1:
=== Tutorial ===
+
Packaging in DreamFactory allows for easily exporting various system resources from one instance and importing them to another.  This can include apps, users, roles, database schema, file storage, services, and more. This functionality is available via the API or from the Packages tab in the admin console.
 
+
Packaging in DreamFactory allows for easily exporting various system resources from one instance and importing them to another.  
+
  
 
=== API Endpoint ===
 
=== API Endpoint ===

Revision as of 19:45, 22 June 2016

Packaging in DreamFactory allows for easily exporting various system resources from one instance and importing them to another. This can include apps, users, roles, database schema, file storage, services, and more. This functionality is available via the API or from the Packages tab in the admin console.

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 
{
    "service":{
            "system":{
                "role":[1,2,3]
            }
    }
}

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
{
 “service": {
    	"system": {
      		"role": [“role1”,“role2”],
      		"service": [
			“DB",
			“mailgun",
			“script",
			“s3",
			“mysql",
			“math-py"
		],
      		"app": [“add_angular2",“my-test-app"],
      		"user": [“[email protected]",“john@foo.com"],
      		"admin": ["john@dreamfactory.com"],
      		"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/"
    	]
  }
}

Example - Exporting Package resources using id

POST http://foo.com/api/v2/system/package
{
	“service”:{
		“system”:{
			“role”:[1,2,3]	// Exporting roles with id 1,2,3
		}
	}
}

Example - Exporting Package resources using filter

POST http://foo.com/api/v2/system/package
{
	“service”:{
		“system”:{
			“service”:{
				“filter”:”name like ’test_%’”
			}
		}
	}
}

Example - Exporting Package resources with related data

POST http://foo.com/api/v2/system/package
{
	“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”
				]
			}	
		}
	}
}

Example - Exporting Package resources with related data using filter

POST http://foo.com/api/v2/system/package
{
	“service”:{
		“system”:{
			…
			“role”:{
				“filter”:”name like ’test_%’”,
				“related”:[
					“app_by_role_id”,
					“role_service_access_by_role_id”
				]
			}
		}
	}
}

Example - Exporting storage resources in Package

POST http://foo.com/api/v2/system/package
{
	“service”:{
		“files”:[				// Name of your storage service
			“css/,			    // Storage folders to export
			“assets/,
			“images/buttons/,
			“app.js,			// Storage files to export
			“index.html]
	}
}


Example - Exporting schemas from database service

POST http://foo.com/api/v2/system/package
{
	“service”:{
		“db”:{				    // Name of your database service
			“_schema”:[		    // Export _schema resource
				“table1”,		// Name of your tables
				“table2”,
				“table3”
			]
		}
	}
}

Example - Storing exported package using a storage service

POST http://foo.com/api/v2/system/package
{
	“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}
	}
}

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

POST http://foo.com/api/v2/system/package
{
	“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
		}
	}
}

Example - Exporting a Package securely

POST http://foo.com/api/v2/system/package
{
	“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
		}
	}
}


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