Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #94 from swichers/develop
Browse files Browse the repository at this point in the history
Add improved ClientFactory and examples to release
  • Loading branch information
swichers committed Dec 30, 2020
2 parents 2bee369 + e9cd2e5 commit 1c48310
Show file tree
Hide file tree
Showing 58 changed files with 1,312 additions and 744 deletions.
15 changes: 15 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Environment variables can be set from a .env file placed in the location you
# run client scripts from. One can also be placed in the ACSF gfs mount for
# each environment.
#
# The AH_* variables should be removed when running on Acquia environments.
#
# The username of the user the API key belongs to.
ACSF_API_USERNAME=api.user
# The API key to access the API with.
# https://docs.acquia.com/site-factory/extend/api/#obtaining-your-api-key
ACSF_API_KEY=abc123
# The ACSF site group.
AH_SITE_GROUP=example
# The ACSF environment.
AH_SITE_ENVIRONMENT=01dev
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
.idea/*
/vendor/
.phpcs-cache
.phpunit.result.cache

# macOS

# General
.DS_Store
.AppleDouble
.LSOverride
.env

# Icon must end with two \r
Icon
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install:

script:
- php vendor/bin/phpcs
- php vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml
- XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml

after_script:
- php vendor/bin/codacycoverage clover ./build/logs/clover.xml
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,40 @@
[![Codacy Quality](https://api.codacy.com/project/badge/Grade/f8600bde4f684cf98b8255c814d753c3)](https://www.codacy.com/manual/swichers/acsf-client)
[![Codacy Coverage](https://api.codacy.com/project/badge/Coverage/f8600bde4f684cf98b8255c814d753c3)](https://www.codacy.com/manual/swichers/acsf-client)

Acquia Cloud Site Factory is a hosting platform provided by Acquia. As part of that platform an API is provided for developers to use. The goal of this library is to wrap that API in such a way that it becomes trivial to leverage it in PHP applications.
Acquia Cloud Site Factory is a hosting platform provided by Acquia. The goal of this library is to wrap the ACSF API in such a way that it becomes trivial to leverage it in PHP applications. This library is a significant boon when it comes to streamlining interactions with ACSF. Usage of this library will, among other things, facilitate a much quicker and less error prone deployment process.

**Caution:** Test coverage in this library is around validation of calls to the API, and is not testing interaction with the actual ACSF API. Not all wrapped endpoints have been validated as properly implemented, and live calls to the API may have unexpected results. Review all scripts and calls for proper behavior before executing against a live environment.

## Why use this project?

You may already be familiar with projects such as [ACSF Tools](https://github.com/acquia/acsf-tools) or the [Acquia CLI](https://github.com/acquia/cli) and be wondering what this project has to offer over those.

| Feature | ACSF Client | ACSF Tools | Acquia CLI |
| ------------------------------------- | :---------: | :--------: | :--------: |
| PHP library ||||
| Supports Site Factory ||||
| Supports Acquia Cloud ||||
| Complete implementation of ACSF API ||||
| Complete implementation of Cloud API ||||
| Can bundle with codebase ||||
| Can be standalone ||||
| Designed for scripting ||||
| Designed for specific tasks ||||

The primary use case for this project is creating custom PHP scripts for automating your development and management workflows within ACSF. Anything that you can do within the ACSF UI should be accomplishable through this library.

![Backporting sites to dev demonstration](https://user-images.githubusercontent.com/5890607/66103462-b6579d00-e56a-11e9-88c3-bc10936afb94.gif)

**Caution:** Test coverage in this library is around validation of calls to the API, and is not testing interaction with the actual ACSF API. Not all wrapped endpoints have been validated as properly implemented, and live calls to the API may have unexpected results. Review all scripts and calls for proper behavior before executing against a live environment.
Common tasks that you can use this library to automate:

* Regular complete backups with custom names
* Regular backup pruning for backups meeting certain criteria
* Bbackports/staging to lower environments along with code deploys
* Production deployments, including backups, backports, and deployments
* Recreating domains on lower environments after backports
* Starting a deployment from your CI system

The [examples](examples/) folder contains several scripts that show some common tasks. They can serve as a starting point to build much more complex workflows custom tailored to your project.

## Installation

Expand All @@ -29,14 +58,14 @@ composer require swichers/acsf-client

## Usage

Example scripts are available in the [examples](examples/) folder.
Many starter scripts are available in the [examples](examples/) folder.

```php
<?php declare(strict_types=1);

require 'vendor/autoload.php';

use swichers\Acsf\Client\ServiceLoader;
use swichers\Acsf\Client\ClientFactory;

$base_config = [
'username' => 'example.user',
Expand All @@ -45,8 +74,10 @@ Example scripts are available in the [examples](examples/) folder.
'environment' => 'live',
];

$client = ServiceLoader::buildFromConfig(['acsf.client.connection' => $base_config])
->get('acsf.client');
// There are multiple ways to create a client, including from
// environment variables (recommended). View the ClientFactory
// class for details.
$client = ClientFactory::createFromArray($base_config);

// Check the service status.
print_r($client->getAction('Status')->ping());
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
"symfony/dependency-injection": "^4.3",
"symfony/finder": "^4.3",
"symfony/http-client": "^4.3",
"symfony/yaml": "^4.3"
"symfony/yaml": "^4.3",
"symfony/dotenv": "^4.4"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0 || ^0.6.0",
"drupal/coder": "^8.3",
"phpunit/phpunit": "^8.5 || ^6.5"
"phpunit/phpunit": "^8.5 || ^6.5",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1"
},
"config": {
"platform": {
Expand Down
Loading

0 comments on commit 1c48310

Please sign in to comment.