GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#50)
by Ha
02:25
created

Service::createServer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare (strict_types=1);
2
3
namespace OpenStack\Compute\v2;
4
5
use OpenCloud\Common\Service\AbstractService;
6
use OpenStack\Compute\v2\Models\Flavor;
7
use OpenStack\Compute\v2\Models\Image;
8
use OpenStack\Compute\v2\Models\Keypair;
9
use OpenStack\Compute\v2\Models\Server;
10
11
/**
12
 * Compute v2 service for OpenStack.
13
 *
14
 * @property \OpenStack\Compute\v2\Api $api
15
 */
16
class Service extends AbstractService
17
{
18
    /**
19
     * Create a new server resource. This operation will provision a new virtual machine on a host chosen by your
20
     * service API.
21
     *
22
     * @param array $options {@see \OpenStack\Compute\v2\Api::postServer}
23
     *
24
     * @return \OpenStack\Compute\v2\Models\Server
25 1
     */
26
    public function createServer(array $options): Server
27 1
    {
28
        return $this->model(Server::class)->create($options);
0 ignored issues
show
Bug introduced by
The method create() does not seem to exist on object<OpenCloud\Common\...urce\ResourceInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
    }
30
31
    /**
32
     * List servers.
33
     *
34
     * @param bool     $detailed Determines whether detailed information will be returned. If FALSE is specified, only
35
     *                           the ID, name and links attributes are returned, saving bandwidth.
36
     * @param array    $options  {@see \OpenStack\Compute\v2\Api::getServers}
37
     * @param callable $mapFn    A callable function that will be invoked on every iteration of the list.
38
     *
39
     * @return \Generator
40 1
     */
41
    public function listServers(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator
42 1
    {
43 1
        $def = ($detailed === true) ? $this->api->getServersDetail() : $this->api->getServers();
44
        return $this->model(Server::class)->enumerate($def, $options, $mapFn);
45
    }
46
47
    /**
48
     * Retrieve a server object without calling the remote API. Any values provided in the array will populate the
49
     * empty object, allowing you greater control without the expense of network transactions. To call the remote API
50
     * and have the response populate the object, call {@see Server::retrieve}. For example:
51
     *
52
     * <code>$server = $service->getServer(['id' => '{serverId}']);</code>
53
     *
54
     * @param array $options An array of attributes that will be set on the {@see Server} object. The array keys need to
55
     *                       correspond to the class public properties.
56
     *
57
     * @return \OpenStack\Compute\v2\Models\Server
58 1
     */
59
    public function getServer(array $options = []): Server
60 1
    {
61 1
        $server = $this->model(Server::class);
62 1
        $server->populateFromArray($options);
63
        return $server;
64
    }
65
66
    /**
67
     * List flavors.
68
     *
69
     * @param array    $options {@see \OpenStack\Compute\v2\Api::getFlavors}
70
     * @param callable $mapFn   A callable function that will be invoked on every iteration of the list.
71
     *
72
     * @return \Generator
73 1
     */
74
    public function listFlavors(array $options = [], callable $mapFn = null): \Generator
75 1
    {
76
        return $this->model(Flavor::class)->enumerate($this->api->getFlavors(), $options, $mapFn);
77
    }
78
79
    /**
80
     * Retrieve a flavor object without calling the remote API. Any values provided in the array will populate the
81
     * empty object, allowing you greater control without the expense of network transactions. To call the remote API
82
     * and have the response populate the object, call {@see Flavor::retrieve}.
83
     *
84
     * @param array $options An array of attributes that will be set on the {@see Flavor} object. The array keys need to
85
     *                       correspond to the class public properties.
86
     *
87
     * @return \OpenStack\Compute\v2\Models\Flavor
88 1
     */
89
    public function getFlavor(array $options = []): Flavor
90 1
    {
91 1
        $flavor = $this->model(Flavor::class);
92 1
        $flavor->populateFromArray($options);
93
        return $flavor;
94
    }
95
96
    public function createFlavor(array $options = []): Flavor
97
    {
98
        return $this->model(Flavor::class)->create($options);
0 ignored issues
show
Bug introduced by
The method create() does not seem to exist on object<OpenCloud\Common\...urce\ResourceInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
99
    }
100
101
    /**
102
     * List images.
103 1
     *
104
     * @param array    $options {@see \OpenStack\Compute\v2\Api::getImages}
105 1
     * @param callable $mapFn   A callable function that will be invoked on every iteration of the list.
106
     *
107
     * @return \Generator
108
     */
109
    public function listImages(array $options = [], callable $mapFn = null): \Generator
110
    {
111
        return $this->model(Image::class)->enumerate($this->api->getImages(), $options, $mapFn);
112
    }
113
114
    /**
115
     * Retrieve an image object without calling the remote API. Any values provided in the array will populate the
116
     * empty object, allowing you greater control without the expense of network transactions. To call the remote API
117
     * and have the response populate the object, call {@see Image::retrieve}.
118 1
     *
119
     * @param array $options An array of attributes that will be set on the {@see Image} object. The array keys need to
120 1
     *                       correspond to the class public properties.
121 1
     *
122 1
     * @return \OpenStack\Compute\v2\Models\Image
123
     */
124
    public function getImage(array $options = []): Image
125
    {
126
        $image = $this->model(Image::class);
127
        $image->populateFromArray($options);
128
        return $image;
129
    }
130
131
    /**
132
     * List key pairs.
133
     *
134
     * @param array    $options {@see \OpenStack\Compute\v2\Api::getKeyPairs}
135
     * @param callable $mapFn   A callable function that will be invoked on every iteration of the list.
136
     *
137
     * @return \Generator
138
     */
139
    public function listKeypairs(array $options = [], callable $mapFn = null): \Generator
140
    {
141
        return $this->model(Keypair::class)->enumerate($this->api->getKeypairs(), $options, $mapFn);
142
    }
143
144
    public function createKeypair(array $options): Keypair
145
    {
146
        return $this->model(Keypair::class)->create($options);
0 ignored issues
show
Bug introduced by
The method create() does not seem to exist on object<OpenCloud\Common\...urce\ResourceInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
147
    }
148
149
    public function getKeypair(array $options = []): Keypair
150
    {
151
        $keypair = $this->model(Keypair::class);
152
        $keypair->populateFromArray($options);
153
        return $keypair;
154
    }
155
}
156