-
-
Notifications
You must be signed in to change notification settings - Fork 456
/
Copy pathRegistry.php
136 lines (124 loc) · 4.24 KB
/
Registry.php
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
<?php
declare(strict_types=1);
/*
* This file is part of the Gitlab API library.
*
* (c) Matt Humphrey <matth@windsor-telecom.co.uk>
* (c) Graham Campbell <hello@gjcampbell.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Gitlab\Api;
use Symfony\Component\OptionsResolver\Options;
class Registry extends AbstractApi
{
/**
* @see https://docs.gitlab.com/ee/api/container_registry.html#get-details-of-a-single-repository
*
* @param int|string $repository_id The ID of the registry repository accessible by the authenticated user
* @param array $parameters {
*
* @var bool $tags
* @var bool $tags_count
* @var bool $size
* }
*
* @return mixed
*/
public function repositories($repository_id, array $parameters = [])
{
$resolver = $this->createOptionsResolver();
$booleanNormalizer = function (Options $resolver, $value): string {
return $value ? 'true' : 'false';
};
$resolver->setDefined('tags')
->setAllowedTypes('tags', 'bool')
->setNormalizer('tags', $booleanNormalizer);
$resolver->setDefined('tags_count')
->setAllowedTypes('tags_count', 'bool')
->setNormalizer('tags_count', $booleanNormalizer);
$resolver->setDefined('size')
->setAllowedTypes('size', 'bool')
->setNormalizer('size', $booleanNormalizer);
return $this->get('registry/repositories/'.self::encodePath($repository_id), $resolver->resolve($parameters));
}
/**
* @see https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repository-tags
*
* @param int|string $project_id
*
* @return mixed
*/
public function repositoryTags($project_id, int $repository_id)
{
return $this->get(
$this->getProjectPath($project_id, 'registry/repositories/'.self::encodePath($repository_id).'/tags')
);
}
/**
* @see https://docs.gitlab.com/ee/api/container_registry.html#get-details-of-a-registry-repository-tag
*
* @param int|string $project_id
*
* @return mixed
*/
public function repositoryTag($project_id, int $repository_id, string $tag_name)
{
return $this->get(
$this->getProjectPath(
$project_id,
'registry/repositories/'.self::encodePath($repository_id).'/tags/'.self::encodePath($tag_name)
)
);
}
/**
* @see https://docs.gitlab.com/ee/api/container_registry.html#delete-a-registry-repository-tag
*
* @param int|string $project_id
*
* @return mixed
*/
public function removeRepositoryTag($project_id, int $repository_id, string $tag_name)
{
return $this->delete(
$this->getProjectPath(
$project_id,
'registry/repositories/'.self::encodePath($repository_id).'/tags/'.self::encodePath($tag_name)
)
);
}
/**
* @see https://docs.gitlab.com/ee/api/container_registry.html#delete-registry-repository-tags-in-bulk
*
* @param int|string $project_id
* @param array $parameters {
*
* @var string $name_regex_delete
* @var string $name_regex_keep
* @var int $keep_n
* @var string $older_than
* }
*
* @return mixed
*/
public function removeRepositoryTags($project_id, int $repository_id, array $parameters = [])
{
$resolver = $this->createOptionsResolver();
$resolver->setRequired('name_regex_delete')
->setAllowedTypes('name_regex_delete', 'string');
$resolver->setDefined('name_regex_keep')
->setAllowedTypes('name_regex_keep', 'string');
$resolver->setDefined('keep_n')
->setAllowedTypes('keep_n', 'int');
$resolver->setDefined('older_than')
->setAllowedTypes('older_than', 'string');
return $this->delete(
$this->getProjectPath(
$project_id,
'registry/repositories/'.self::encodePath($repository_id).'/tags'
),
$resolver->resolve($parameters)
);
}
}