Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds some changes that can be made now for v2.1. #115

Merged
merged 1 commit into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,49 @@ acquiacli team:invite d2693c6e-58e7-47e5-8867-e2db88c71b8c '[email protected]

````

### Additional parameters
The `--limit`, `--sort`, and `--filter` parameters can be added to every single command used with the Acquia Cli tool for providing more relevant information to users who are working on sites.

*Limiting*

To limit the number of returned entries, use `--limit=x` with a command.
```
# Reduce the number of notifications passed back to 10.
acquiacli notification:list myacquiasite --limit=10
```

*Sorting*

A comma-delimited string with fields can be used for sorting. The order of the fields is significant. A leading - in the field indicates the field should be sorted in a descending order. Not all fields are sortable.
```
# Sort all applications first by organization name (alphabetically) and then by label (reverse-alphabetically).
acquiacli application:list --sort='organization_name,-label'
```

*Filtering*

The filters query string parameter restricts the data returned from your request. Filtered queries restrict the rows that do (or do not) get included in the result by testing each row in the result against the filters. Not all fields are filterable.

There are eight filter operators that can be used and they must be URL encoded in order to be included. The operators are:

* Equals: =
* Does not equal: !=
* Greater than: >
* Less than: <
* Greater than or equal to: >=
* Less than or equal to: <=
* Contains substring: =@
* Does not contain substring: !@

Filters can be combined using OR and AND boolean logic. The OR operator is defined using a comma (,) and the AND operator is defined using a semi-colon (;).

```
# Show all tasks with a label starting with Database after 1st April 2019 and before 1st Jan 2020.
acquiacli notification:list myacquiasite --filter='label=@Database*;created_at>2019-04-01;created_at<2020-01-01'
# Show all tasks with a label starting with Database OR a label exactly matching 'Code switched'
acquiacli notification:list myacquiasite --filter='label=@Database*,label=Code switched'
```

### See it in action
[![asciicast](https://asciinema.org/a/178427.png)](https://asciinema.org/a/178427)

Expand Down
6 changes: 1 addition & 5 deletions src/Commands/CodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@ class CodeCommand extends AcquiaCommand
* Gets all code branches and tags associated with an application.
*
* @param string $uuid
* @param string $match A string to filter out specific code branches with.
*
* @command code:list
* @aliases c:l
*/
public function code(Client $client, Code $codeAdapter, $uuid, $match = null)
public function code(Client $client, Code $codeAdapter, $uuid)
{
if (null !== $match) {
$client->addQuery('filter', "name=@*${match}*");
}
$branches = $codeAdapter->getAll($uuid);
$client->clearQuery();

Expand Down
19 changes: 2 additions & 17 deletions src/Commands/NotificationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class NotificationsCommand extends AcquiaCommand
* Gets all notifications associated with a site.
*
* @param string $uuid
* @param int $limit The maximum number of items to return.
* @param string $filter
* @param string $sort Sortable by: 'name', 'title', 'created', 'completed', 'started'.
* A leading "~" in the field indicates the field should be sorted in a descending order.
*
* @command notification:list
* @option details Whether to show more details in the notication list (slower).
Expand All @@ -38,20 +34,9 @@ public function notificationList(
Organizations $organizationsAdapter,
Notifications $notificationsAdapter,
$uuid,
$limit = 50,
$filter = null,
$sort = '~created_at',
$options = ['details']
) {

// Allows for limits and sort criteria.
$sort = str_replace('~', '-', $sort);
$client->addQuery('limit', $limit);
$client->addQuery('sort', $sort);
if (null !== $filter) {
$client->addQuery('filter', "name=${filter}");
}

$notifications = $notificationsAdapter->getAll($uuid);
$client->clearQuery();

Expand Down Expand Up @@ -86,10 +71,10 @@ public function notificationList(

$application = $applicationsAdapter->get($uuid);
$orgUuid = $application->organization->uuid;

$admins = $organizationsAdapter->getAdmins($orgUuid);
$members = $organizationsAdapter->getMembers($orgUuid);

$users = $admins->getArrayCopy() + $members->getArrayCopy();
$uuids = array_reduce($users, function ($result, $member) {
$result[$member->uuid] = $member->mail;
Expand Down
4 changes: 0 additions & 4 deletions tests/Commands/CodeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public function codeProvider()
['code:list', 'devcloud:devcloud2'],
$codeList . PHP_EOL
],
[
['code:list', 'devcloud:devcloud2', 'master'],
$codeList . PHP_EOL
],
[
['code:switch', 'devcloud:devcloud2', 'prod', 'master'],
$codeSwitch . PHP_EOL
Expand Down