Skip to content

Commit d4b9a8f

Browse files
authored
[11.12] Add support for filter in Projects::variable (#767)
* fix: add filter option to project variable method This commit implements the option to add a filter[environment_scope] to a variable request, when multiple variables with the same name exist, but have different environment scopes. See documentation for more information https://docs.gitlab.com/ee/api/project_level_variables.html#get-a-single-variable * fix: fix indenting and remove extra resolver
1 parent a8b21d7 commit d4b9a8f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Api/Projects.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,12 +1214,17 @@ public function variables($project_id, array $parameters = [])
12141214
/**
12151215
* @param int|string $project_id
12161216
* @param string $key
1217+
* @param array $parameters
12171218
*
12181219
* @return mixed
12191220
*/
1220-
public function variable($project_id, string $key)
1221+
public function variable($project_id, string $key, array $parameters = [])
12211222
{
1222-
return $this->get($this->getProjectPath($project_id, 'variables/'.self::encodePath($key)));
1223+
$resolver = $this->createOptionsResolver();
1224+
$resolver->setDefined('filter')
1225+
->setAllowedTypes('filter', 'array');
1226+
1227+
return $this->get($this->getProjectPath($project_id, 'variables/'.self::encodePath($key)), $resolver->resolve($parameters));
12231228
}
12241229

12251230
/**

0 commit comments

Comments
 (0)