-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFunc.php
More file actions
175 lines (155 loc) · 4.1 KB
/
Func.php
File metadata and controls
175 lines (155 loc) · 4.1 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
namespace Utopia\Migration\Resources\Functions;
use Utopia\Migration\Resource;
use Utopia\Migration\Transfer;
class Func extends Resource
{
/**
* @param string $id
* @param string $name
* @param string $runtime
* @param array<string> $execute
* @param bool $enabled
* @param array<string> $events
* @param string $schedule
* @param int $timeout
* @param string $activeDeployment
* @param string $entrypoint
* @param string $commands
* @param bool $logging
* @param array<string> $scopes
* @param string $specification
*/
public function __construct(
string $id,
private readonly string $name,
private readonly string $runtime,
private readonly array $execute = [],
private readonly bool $enabled = true,
private readonly array $events = [],
private readonly string $schedule = '',
private readonly int $timeout = 0,
private readonly string $activeDeployment = '',
private readonly string $entrypoint = '',
private readonly string $commands = '',
private readonly bool $logging = true,
private readonly array $scopes = [],
private readonly string $specification = ''
) {
$this->id = $id;
}
/**
* @param array<string, mixed> $array
* @return self
*/
public static function fromArray(array $array): self
{
return new self(
$array['id'],
$array['name'],
$array['runtime'],
$array['execute'] ?? [],
$array['enabled'] ?? true,
$array['events'] ?? [],
$array['schedule'] ?? '',
$array['timeout'] ?? 0,
$array['activeDeployment'] ?? '',
$array['entrypoint'] ?? '',
$array['commands'] ?? '',
$array['logging'] ?? true,
$array['scopes'] ?? [],
$array['specification'] ?? ''
);
}
/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'name' => $this->name,
'execute' => $this->execute,
'enabled' => $this->enabled,
'runtime' => $this->runtime,
'events' => $this->events,
'schedule' => $this->schedule,
'timeout' => $this->timeout,
'activeDeployment' => $this->activeDeployment,
'entrypoint' => $this->entrypoint,
'commands' => $this->commands,
'logging' => $this->logging,
'scopes' => $this->scopes,
'specification' => $this->specification,
];
}
public static function getName(): string
{
return Resource::TYPE_FUNCTION;
}
public function getGroup(): string
{
return Transfer::GROUP_FUNCTIONS;
}
public function getFunctionName(): string
{
return $this->name;
}
/**
* @return array<string>
*/
public function getExecute(): array
{
return $this->execute;
}
public function getEnabled(): bool
{
return $this->enabled;
}
public function getRuntime(): string
{
return $this->runtime;
}
/**
* @return array<string>
*/
public function getEvents(): array
{
return $this->events;
}
public function getSchedule(): string
{
return $this->schedule;
}
public function getTimeout(): int
{
return $this->timeout;
}
public function getActiveDeployment(): string
{
return $this->activeDeployment;
}
public function getEntrypoint(): string
{
return $this->entrypoint;
}
public function getCommands(): string
{
return $this->commands;
}
public function getLogging(): bool
{
return $this->logging;
}
/**
* @return array<string>
*/
public function getScopes(): array
{
return $this->scopes;
}
public function getSpecification(): string
{
return $this->specification;
}
}