File: Policies.md

package info (click to toggle)
owncloud 7.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 104,192 kB
  • sloc: php: 403,584; xml: 5,843; perl: 630; cs: 504; sh: 453; sql: 271; python: 221; makefile: 104
file content (68 lines) | stat: -rw-r--r-- 1,261 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#Policies

## Setup

To interact with the policies of a scaling group, you will need to setup the group object beforehand.

```php
$groupId = 'foobar';
$group   = $service->getGroup($groupId);
```

For more information about setting up the `$service` object, please see the userguide tutorial for [Autoscale groups]().

## Get all policies

```php
$policies = $group->getPolicies();

while ($policy = $policies->next()) {
    // do something
    echo "{$policy->name} {($policy->type)}" . PHP_EOL;
}
```

## Create a new scaling policy

Creating policies is achieved through passing an array to the `create` method.

```php
$policy = new \stdClass;
$policy->name = "NEW NAME";
$policy->change = 1;
$policy->cooldown = 150;
$policy->type = "webhook";

$group->getPolicy()->create(array($policy));

// or even:

$group->getPolicy()->create(array(
    (object) array(
        'name' => 'NEW NAME',
        'change' => 1,
        'cooldown' => 150,
        'type' => 'webhook'
    ),
    // etc.
));
```

## Get, update and delete a scaling policy

```php
$policyId = 'foobar';
$policy = $group->getPolicy($policyId);

$policy->update(array(
    'name' => 'More relevant name'
));

$policy->delete();
```

## Execute a scaling policy

```php
$policy->execute();
```