1<?php 2 3declare(strict_types=1); 4 5namespace OpenStack\ObjectStore\v1; 6 7use OpenStack\Common\Api\AbstractParams; 8use Psr\Http\Message\StreamInterface; 9 10class Params extends AbstractParams 11{ 12 public function endMarker(): array 13 { 14 return [ 15 'location' => self::QUERY, 16 'description' => <<<EOT 17Based on a string value, only containers with names that are less in value than the specified marker will be returned. 18"Less in value" refers to the sorting algorithm, which is based on the SQLite memcmp() collating function.' 19EOT 20 ]; 21 } 22 23 public function prefix(): array 24 { 25 return [ 26 'location' => self::QUERY, 27 'description' => <<<EOT 28Based on a string value, only containers with names that begin with this value will be returned. This is useful when 29you only want to return a set of containers that match a particular pattern. 30EOT 31 ]; 32 } 33 34 public function delimiter(): array 35 { 36 return [ 37 'location' => self::QUERY, 38 'description' => <<<EOT 39Delimiter value, which returns the object names that are nested in the container. 40EOT 41 ]; 42 } 43 44 public function newest(): array 45 { 46 return [ 47 'location' => self::HEADER, 48 'type' => self::BOOL_TYPE, 49 'sentAs' => 'X-Newest', 50 'description' => <<<EOT 51If set to True, Object Storage queries all replicas to return the most recent one. If you omit this header, Object 52Storage responds faster after it finds one valid replica. Because setting this header to True is more expensive for the 53back end, use it only when it is absolutely needed. 54EOT 55 ]; 56 } 57 58 public function tempUrlKey($type) 59 { 60 return [ 61 'location' => self::HEADER, 62 'sentAs' => sprintf('X-%s-Meta-Temp-URL-Key', ucfirst($type)), 63 'description' => 'The secret key value for temporary URLs.', 64 ]; 65 } 66 67 public function tempUrlKey2($type) 68 { 69 return [ 70 'location' => self::HEADER, 71 'sentAs' => sprintf('X-%s-Meta-Temp-URL-Key-2', ucfirst($type)), 72 'description' => <<<EOT 73A second secret key value for temporary URLs. The second key enables you to rotate keys by having an old and new key 74active at the same time. 75EOT 76 ]; 77 } 78 79 public function containerName(): array 80 { 81 return [ 82 'location' => self::URL, 83 'required' => true, 84 'description' => <<<EOT 85The unique name for the container. The container name must be from 1 to 256 characters long and can start with any 86character and contain any pattern. Character set must be UTF-8. The container name cannot contain a slash (/) character 87because this character delimits the container and object name. For example, /account/container/object. 88EOT 89 ]; 90 } 91 92 public function path(): array 93 { 94 return [ 95 'location' => 'query', 96 'description' => <<<EOT 97For a string value, returns the object names that are nested in the pseudo path. Equivalent to setting delimiter to / 98and prefix to the path with a / at the end. 99EOT 100 ]; 101 } 102 103 public function readAccess($type) 104 { 105 return [ 106 'location' => 'header', 107 'sentAs' => sprintf('X-%s-Read', ucfirst($type)), 108 'description' => <<<EOT 109Sets a container access control list (ACL) that grants read access. Container ACLs are available on any Object Storage 110cluster, and are enabled by container rather than by cluster. Specify the ACL value as follows: 111 112".r:*" to allow access for all referrers. 113 114".r:example.com,swift.example.com" to allow access to a comma-separated list of referrers. 115 116".rlistings" to allow container listing. 117 118"AUTH_username" allows access to a specified user who authenticates through a legacy or non-OpenStack-Identity-based 119authentication system. 120 121"LDAP_" allows access to all users who authenticate through an LDAP-based legacy or non-OpenStack-Identity-based 122authentication system. 123EOT 124 ]; 125 } 126 127 public function syncTo(): array 128 { 129 return [ 130 'location' => self::HEADER, 131 'sentAs' => 'X-Container-Sync-To', 132 'description' => <<<EOT 133Sets the destination for container synchronization. Used with the secret key indicated in the X-Container-Sync-Key 134header. If you want to stop a container from synchronizing, send a blank value for the X-Container-Sync-Key header. 135EOT 136 ]; 137 } 138 139 public function syncKey(): array 140 { 141 return [ 142 'location' => self::HEADER, 143 'sentAs' => 'X-Container-Sync-Key', 144 'description' => <<<EOT 145Sets the secret key for container synchronization. If you remove the secret key, synchronization is halted. 146EOT 147 ]; 148 } 149 150 public function writeAccess($type) 151 { 152 return [ 153 'location' => self::HEADER, 154 'sentAs' => sprintf('X-%s-Write', ucfirst($type)), 155 'description' => 'Like `readAccess` parameter, but for write access.', 156 ]; 157 } 158 159 public function metadata($type, $remove = false) 160 { 161 if (true == $remove) { 162 $type = 'Remove-'.ucfirst($type); 163 } 164 165 return [ 166 'location' => self::HEADER, 167 'type' => self::OBJECT_TYPE, 168 'prefix' => sprintf('X-%s-Meta-', ucfirst($type)), 169 'properties' => [ 170 'type' => self::STRING_TYPE, 171 ], 172 'description' => <<<EOT 173Human-readable key/value pairs that help describe and determine what type of resource it is. You can specify whichever 174key you like, but the values need to be in scalar form (since they will be translated to strings). 175EOT 176 ]; 177 } 178 179 public function versionsLocation(): array 180 { 181 return [ 182 'location' => self::HEADER, 183 'sentAs' => 'X-Versions-Location', 184 'description' => <<<EOT 185Enables versioning on this container. The value is the name of another container. You must UTF-8-encode and then 186URL-encode the name before you include it in the header. To disable versioning, set the header to an empty string. 187EOT 188 ]; 189 } 190 191 public function bytesQuota(): array 192 { 193 return [ 194 'location' => self::HEADER, 195 'sentAs' => 'X-Container-Meta-Quota-Bytes', 196 'description' => <<<EOT 197Sets maximum size of the container, in bytes. Typically these values are set by an administrator. Returns a 413 198response (request entity too large) when an object PUT operation exceeds this quota value. 199EOT 200 ]; 201 } 202 203 public function countQuota(): array 204 { 205 return [ 206 'location' => self::HEADER, 207 'sentAs' => 'X-Container-Meta-Quota-Count', 208 'description' => <<<EOT 209Sets maximum object count of the container. Typically these values are set by an administrator. Returns a 413 210response (request entity too large) when an object PUT operation exceeds this quota value. 211EOT 212 ]; 213 } 214 215 public function webDirType(): array 216 { 217 return [ 218 'location' => self::HEADER, 219 'sentAs' => 'X-Container-Meta-Web-Directory-Type', 220 'description' => <<<EOT 221Sets the content-type of directory marker objects. If the header is not set, default is application/directory. 222Directory marker objects are 0-byte objects that represent directories to create a simulated hierarchical structure. 223For example, if you set "X-Container-Meta-Web-Directory- Type: text/directory", Object Storage treats 0-byte objects 224with a content-type of text/directory as directories rather than objects. 225EOT 226 ]; 227 } 228 229 public function detectContentType(): array 230 { 231 return [ 232 'location' => self::HEADER, 233 'type' => self::BOOL_TYPE, 234 'sentAs' => 'X-Detect-Content-Type', 235 'description' => <<<EOT 236If set to true, Object Storage guesses the content type based on the file extension and ignores the value sent in the 237Content-Type header, if present. 238EOT 239 ]; 240 } 241 242 public function removeVersionsLocation(): array 243 { 244 return [ 245 'location' => self::HEADER, 246 'sentAs' => 'X-Remove-Versions-Location', 247 'description' => 'Set to any value to disable versioning.', 248 ]; 249 } 250 251 public function objectName(): array 252 { 253 return [ 254 'location' => self::URL, 255 'required' => true, 256 'description' => 'The unique name for the object', 257 ]; 258 } 259 260 public function range(): array 261 { 262 return [ 263 'location' => self::HEADER, 264 'description' => <<<EOT 265You can use the Range header to get portions of data by using one or more range specifications. To specify many ranges, 266separate the range specifications with a comma. The types of range specifications are: 267 268- Byte range specification. Use FIRST_BYTE_OFFSET to specify the start of the data range, and LAST_BYTE_OFFSET to 269specify the end. You can omit the LAST_BYTE_OFFSET and if you do, the value defaults to the offset of the last byte of 270data. 271 272- Suffix byte range specification . Use LENGTH bytes to specify the length of the data range. 273 274The following forms of the header specify the following ranges of data: 275 276Range: bytes=-5. The last five bytes. 277 278Range: bytes=10-15. The five bytes of data after a 10-byte offset. 279 280Range: bytes=10-15,-5. A multi-part response that contains the last five bytes and the five bytes of data after a 28110-byte offset. The Content-Type of the response is then multipart/byteranges. 282 283Range: bytes=4-6. Bytes 4 to 6 inclusive. 284 285Range: bytes=2-2. Byte 2, the third byte of the data. 286 287Range: bytes=6-. Byte 6 and after. 288 289Range: bytes=1-3,2-5. A multi-part response that contains bytes 1 to 3 inclusive, and bytes 2 to 5 inclusive. The 290Content-Type of the response is then multipart/byteranges. 291EOT 292 ]; 293 } 294 295 public function ifMatch(): array 296 { 297 return [ 298 'location' => self::HEADER, 299 'sentAs' => 'If-Match', 300 'description' => <<<EOT 301In a nutshell, this provides for conditional requests. The value provided should be a MD5 checksum, and it will be 302checked by the server receiving the request. If any existing entity held on the server has the same MD5 checksum (or 303ETag), or if "*" is provided as the value, the request will be performed. 304 305Conversely, if none of the entity tags match, or if "*" is given and no current entity exists, the server MUST NOT 306perform the requested method, and MUST return a 412 (Precondition Failed) response. 307 308See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14 for more information. 309EOT 310 ]; 311 } 312 313 public function ifNoneMatch(): array 314 { 315 return [ 316 'location' => self::HEADER, 317 'sentAs' => 'If-None-Match', 318 'description' => <<<EOT 319In a nutshell, this provides for conditional requests. The value provided should be a MD5 checksum, and it will be 320checked by the server receiving the request. If any existing entity held on the server has the same MD5 checksum (or 321ETag), or if "*" is provided as the value, the request MUST NOT perform the request, and MUST return a 412 322(Precondition Failed) response. 323 324Conversely, if none of the entity tags match, or if "*" is given and no current entity exists, the server may 325perform the requested method. 326 327See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14 for more information. 328EOT 329 ]; 330 } 331 332 public function ifModifiedSince(): array 333 { 334 return [ 335 'location' => self::HEADER, 336 'sentAs' => 'If-Modified-Since', 337 'description' => <<<EOT 338The value should be a valid HTTP-date. This value makes the request conditional. If the requested resource HAS NOT 339been modified or changed since the specified date, it will not be returned. Instead a 304 (Not Modified) response will 340be returned without any message body. If the resource HAS been modified since the specified date, it will be returned 341as usual. 342EOT 343 ]; 344 } 345 346 public function ifUnmodifiedSince(): array 347 { 348 return [ 349 'location' => self::HEADER, 350 'sentAs' => 'If-Unmodified-Since', 351 'description' => <<<EOT 352The value should be a valid HTTP-date. This value makes the request conditional. If the requested resource HAS 353been modified or changed since the specified date, it will not be returned. Instead a 412 (Precondition Failed) 354response will be returned without any message body. If the resource HAS NOT been modified since the specified date, it 355will be returned as usual. 356EOT 357 ]; 358 } 359 360 public function deleteAfter(): array 361 { 362 return [ 363 'location' => self::HEADER, 364 'sentAs' => 'X-Delete-After', 365 'description' => <<<EOT 366Specifies the number of seconds after which the object is removed. Internally, the Object Storage system stores this 367value in the X-Delete-At metadata item. 368EOT 369 ]; 370 } 371 372 public function deleteAt(): array 373 { 374 return [ 375 'location' => self::HEADER, 376 'sentAs' => 'X-Delete-At', 377 'description' => 'The certain date, in UNIX Epoch timestamp format, when the object will be removed.', 378 ]; 379 } 380 381 public function contentEncoding(): array 382 { 383 return [ 384 'location' => self::HEADER, 385 'sentAs' => 'Content-Encoding', 386 'description' => <<<EOT 387The Content-Encoding entity-header field is used as a modifier to the media-type. When present, its value indicates 388what additional content codings have been applied to the entity-body, and thus what decoding mechanisms must be applied 389in order to obtain the media-type referenced by the Content-Type header field 390EOT 391 ]; 392 } 393 394 public function contentDisposition(): array 395 { 396 return [ 397 'location' => self::HEADER, 398 'sentAs' => 'Content-Disposition', 399 'description' => <<<EOT 400The Content-Disposition response-header field has been proposed as a means for the origin server to suggest a default 401filename if the user requests that the content is saved to a file. 402EOT 403 ]; 404 } 405 406 public function copyFrom(): array 407 { 408 return [ 409 'location' => self::HEADER, 410 'sentAs' => 'X-Copy-From', 411 'description' => <<<EOT 412If set, this is the name of an object used to create the new object by copying the X-Copy-From object. The value is in 413form {container}/{object}. You must UTF-8-encode and then URL-encode the names of the container and object before you 414include them in the header. Using PUT with X-Copy-From has the same effect as using the COPY operation to copy an object. 415EOT 416 ]; 417 } 418 419 public function etag(): array 420 { 421 return [ 422 'location' => self::HEADER, 423 'sentAs' => 'ETag', 424 'description' => <<<EOT 425The MD5 checksum value of the request body. For example, the MD5 checksum value of the object content. You are strongly 426recommended to compute the MD5 checksum value of object content and include it in the request. This enables the Object 427Storage API to check the integrity of the upload. The value is not quoted. 428EOT 429 ]; 430 } 431 432 public function contentType(): array 433 { 434 return [ 435 'location' => self::HEADER, 436 'sentAs' => 'Content-Type', 437 'description' => 'The Content-Type entity-header field indicates the media type of the entity-body', 438 ]; 439 } 440 441 public function destination(): array 442 { 443 return [ 444 'location' => self::HEADER, 445 'sentAs' => 'Destination', 446 'description' => <<<EOT 447The container and object name of the destination object in the form of /container/object. You must UTF-8-encode and 448then URL-encode the names of the destination container and object before you include them in this header. 449EOT 450 ]; 451 } 452 453 public function freshMetadata(): array 454 { 455 return [ 456 'location' => self::HEADER, 457 'type' => self::BOOL_TYPE, 458 'description' => <<<EOT 459Enables object creation that omits existing user metadata. If set to True, the COPY request creates an object without 460existing user metadata. Default value is False. 461EOT 462 ]; 463 } 464 465 public function content(): array 466 { 467 return [ 468 'location' => self::RAW, 469 'type' => self::STRING_TYPE, 470 'description' => 'The content of the object in string form', 471 ]; 472 } 473 474 public function stream(): array 475 { 476 return [ 477 'location' => self::RAW, 478 'type' => StreamInterface::class, 479 'description' => 'The content of the object in string form', 480 ]; 481 } 482 483 public function format(): array 484 { 485 return [ 486 'location' => self::QUERY, 487 'type' => self::STRING_TYPE, 488 'description' => 'Defines the format of the collection. Will always default to `json`.', 489 ]; 490 } 491 492 public function objectManifest(): array 493 { 494 return [ 495 'location' => self::HEADER, 496 'sentAs' => 'X-Object-Manifest', 497 'type' => self::STRING_TYPE, 498 'description' => <<<EOT 499The value of this header is {container}/{prefix}, where {container} is the name of the container where the segment 500objects are stored, and {prefix} is a string that all segment objects have in common 501EOT 502 ]; 503 } 504} 505