@@ -68,32 +68,50 @@ final class ProjectCache
68
68
*/
69
69
private $ modes ;
70
70
71
+ /**
72
+ * Defines the scope of the cache. You can use this namespace to share a cache across multiple projects. For more
73
+ * information, see Cache sharing between projects [^1] in the *CodeBuild User Guide*.
74
+ *
75
+ * [^1]: https://docs.aws.amazon.com/codebuild/latest/userguide/caching-s3.html#caching-s3-sharing
76
+ *
77
+ * @var string|null
78
+ */
79
+ private $ cacheNamespace ;
80
+
71
81
/**
72
82
* @param array{
73
83
* type: CacheType::*,
74
84
* location?: null|string,
75
85
* modes?: null|array<CacheMode::*>,
86
+ * cacheNamespace?: null|string,
76
87
* } $input
77
88
*/
78
89
public function __construct (array $ input )
79
90
{
80
91
$ this ->type = $ input ['type ' ] ?? $ this ->throwException (new InvalidArgument ('Missing required field "type". ' ));
81
92
$ this ->location = $ input ['location ' ] ?? null ;
82
93
$ this ->modes = $ input ['modes ' ] ?? null ;
94
+ $ this ->cacheNamespace = $ input ['cacheNamespace ' ] ?? null ;
83
95
}
84
96
85
97
/**
86
98
* @param array{
87
99
* type: CacheType::*,
88
100
* location?: null|string,
89
101
* modes?: null|array<CacheMode::*>,
102
+ * cacheNamespace?: null|string,
90
103
* }|ProjectCache $input
91
104
*/
92
105
public static function create ($ input ): self
93
106
{
94
107
return $ input instanceof self ? $ input : new self ($ input );
95
108
}
96
109
110
+ public function getCacheNamespace (): ?string
111
+ {
112
+ return $ this ->cacheNamespace ;
113
+ }
114
+
97
115
public function getLocation (): ?string
98
116
{
99
117
return $ this ->location ;
@@ -140,6 +158,9 @@ public function requestBody(): array
140
158
$ payload ['modes ' ][$ index ] = $ listValue ;
141
159
}
142
160
}
161
+ if (null !== $ v = $ this ->cacheNamespace ) {
162
+ $ payload ['cacheNamespace ' ] = $ v ;
163
+ }
143
164
144
165
return $ payload ;
145
166
}
0 commit comments