| @@ 104-126 (lines=23) @@ | ||
| 101 | * |
|
| 102 | * @throws \RuntimeException if cannot create the container |
|
| 103 | */ |
|
| 104 | public function createContainer($containerName, CreateContainerOptions $options = null) |
|
| 105 | { |
|
| 106 | $this->init(); |
|
| 107 | ||
| 108 | if (null === $options) { |
|
| 109 | $options = $this->getCreateContainerOptions(); |
|
| 110 | } |
|
| 111 | ||
| 112 | try { |
|
| 113 | $this->blobProxy->createContainer($containerName, $options); |
|
| 114 | } catch (ServiceException $e) { |
|
| 115 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 116 | ||
| 117 | if ($errorCode !== self::ERROR_CONTAINER_ALREADY_EXISTS) { |
|
| 118 | throw new \RuntimeException(sprintf( |
|
| 119 | 'Failed to create the configured container "%s": %s (%s).', |
|
| 120 | $containerName, |
|
| 121 | $e->getErrorText(), |
|
| 122 | $errorCode |
|
| 123 | )); |
|
| 124 | } |
|
| 125 | } |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * Deletes a container. |
|
| @@ 136-154 (lines=19) @@ | ||
| 133 | * |
|
| 134 | * @throws \RuntimeException if cannot delete the container |
|
| 135 | */ |
|
| 136 | public function deleteContainer($containerName, DeleteContainerOptions $options = null) |
|
| 137 | { |
|
| 138 | $this->init(); |
|
| 139 | ||
| 140 | try { |
|
| 141 | $this->blobProxy->deleteContainer($containerName, $options); |
|
| 142 | } catch (ServiceException $e) { |
|
| 143 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
| 144 | ||
| 145 | if ($errorCode !== self::ERROR_CONTAINER_NOT_FOUND) { |
|
| 146 | throw new \RuntimeException(sprintf( |
|
| 147 | 'Failed to delete the configured container "%s": %s (%s).', |
|
| 148 | $containerName, |
|
| 149 | $e->getErrorText(), |
|
| 150 | $errorCode |
|
| 151 | ), $e->getCode()); |
|
| 152 | } |
|
| 153 | } |
|
| 154 | } |
|
| 155 | ||
| 156 | /** |
|
| 157 | * {@inheritdoc} |
|