|
17 | 17 | from ..services.rgw_client import NoRgwDaemonsException, RgwClient, RgwMultisite |
18 | 18 | from ..tools import json_str_to_object, str_to_bool |
19 | 19 | from . import APIDoc, APIRouter, BaseController, CreatePermission, \ |
20 | | - CRUDCollectionMethod, CRUDEndpoint, Endpoint, EndpointDoc, ReadPermission, \ |
21 | | - RESTController, UIRouter, UpdatePermission, allow_empty_body |
| 20 | + CRUDCollectionMethod, CRUDEndpoint, DeletePermission, Endpoint, \ |
| 21 | + EndpointDoc, ReadPermission, RESTController, UIRouter, UpdatePermission, \ |
| 22 | + allow_empty_body |
22 | 23 | from ._crud import CRUDMeta, Form, FormField, FormTaskInfo, Icon, MethodType, \ |
23 | 24 | TableAction, Validator, VerticalContainer |
24 | 25 | from ._version import APIVersion |
@@ -114,15 +115,98 @@ def migrate(self, daemon_name=None, realm_name=None, zonegroup_name=None, zone_n |
114 | 115 |
|
115 | 116 | @APIRouter('rgw/multisite', Scope.RGW) |
116 | 117 | @APIDoc("RGW Multisite Management API", "RgwMultisite") |
117 | | -class RgwMultisiteSyncStatus(RESTController): |
118 | | - @RESTController.Collection(method='GET', path='/sync_status') |
| 118 | +class RgwMultisiteController(RESTController): |
| 119 | + @Endpoint(path='/sync_status') |
| 120 | + @EndpointDoc("Get the sync status") |
| 121 | + @ReadPermission |
119 | 122 | @allow_empty_body |
120 | 123 | # pylint: disable=W0102,W0613 |
121 | 124 | def get_sync_status(self): |
122 | 125 | multisite_instance = RgwMultisite() |
123 | 126 | result = multisite_instance.get_multisite_sync_status() |
124 | 127 | return result |
125 | 128 |
|
| 129 | + @Endpoint(path='/sync-policy') |
| 130 | + @EndpointDoc("Get the sync policy") |
| 131 | + @ReadPermission |
| 132 | + def get_sync_policy(self, bucket_name='', zonegroup_name=''): |
| 133 | + multisite_instance = RgwMultisite() |
| 134 | + return multisite_instance.get_sync_policy(bucket_name, zonegroup_name) |
| 135 | + |
| 136 | + @Endpoint(path='/sync-policy-group') |
| 137 | + @EndpointDoc("Get the sync policy group") |
| 138 | + @ReadPermission |
| 139 | + def get_sync_policy_group(self, group_id: str, bucket_name=''): |
| 140 | + multisite_instance = RgwMultisite() |
| 141 | + return multisite_instance.get_sync_policy_group(group_id, bucket_name) |
| 142 | + |
| 143 | + @Endpoint(method='POST', path='/sync-policy-group') |
| 144 | + @EndpointDoc("Create the sync policy group") |
| 145 | + @CreatePermission |
| 146 | + def create_sync_policy_group(self, group_id: str, status: str, bucket_name=''): |
| 147 | + multisite_instance = RgwMultisite() |
| 148 | + return multisite_instance.create_sync_policy_group(group_id, status, bucket_name) |
| 149 | + |
| 150 | + @Endpoint(method='PUT', path='/sync-policy-group') |
| 151 | + @EndpointDoc("Update the sync policy group") |
| 152 | + @UpdatePermission |
| 153 | + def update_sync_policy_group(self, group_id: str, status: str, bucket_name=''): |
| 154 | + multisite_instance = RgwMultisite() |
| 155 | + return multisite_instance.update_sync_policy_group(group_id, status, bucket_name) |
| 156 | + |
| 157 | + @Endpoint(method='DELETE', path='/sync-policy-group') |
| 158 | + @EndpointDoc("Remove the sync policy group") |
| 159 | + @DeletePermission |
| 160 | + def remove_sync_policy_group(self, group_id: str, bucket_name=''): |
| 161 | + multisite_instance = RgwMultisite() |
| 162 | + return multisite_instance.remove_sync_policy_group(group_id, bucket_name) |
| 163 | + |
| 164 | + @Endpoint(method='PUT', path='/sync-flow') |
| 165 | + @EndpointDoc("Create or update the sync flow") |
| 166 | + @CreatePermission |
| 167 | + def create_sync_flow(self, flow_id: str, flow_type: str, group_id: str, |
| 168 | + source_zone='', destination_zone='', zones: Optional[List[str]] = None, |
| 169 | + bucket_name=''): |
| 170 | + multisite_instance = RgwMultisite() |
| 171 | + return multisite_instance.create_sync_flow(group_id, flow_id, flow_type, zones, |
| 172 | + bucket_name, source_zone, destination_zone) |
| 173 | + |
| 174 | + @Endpoint(method='DELETE', path='/sync-flow') |
| 175 | + @EndpointDoc("Remove the sync flow") |
| 176 | + @DeletePermission |
| 177 | + def remove_sync_flow(self, flow_id: str, flow_type: str, group_id: str, |
| 178 | + source_zone='', destination_zone='', zones: Optional[List[str]] = None, |
| 179 | + bucket_name=''): |
| 180 | + multisite_instance = RgwMultisite() |
| 181 | + return multisite_instance.remove_sync_flow(group_id, flow_id, flow_type, source_zone, |
| 182 | + destination_zone, zones, bucket_name) |
| 183 | + |
| 184 | + @Endpoint(method='PUT', path='/sync-pipe') |
| 185 | + @EndpointDoc("Create or update the sync pipe") |
| 186 | + @CreatePermission |
| 187 | + def create_sync_pipe(self, group_id: str, pipe_id: str, |
| 188 | + source_zones: Optional[List[str]] = None, |
| 189 | + destination_zones: Optional[List[str]] = None, |
| 190 | + destination_buckets: Optional[List[str]] = None, |
| 191 | + bucket_name: str = ''): |
| 192 | + multisite_instance = RgwMultisite() |
| 193 | + return multisite_instance.create_sync_pipe(group_id, pipe_id, source_zones, |
| 194 | + destination_zones, destination_buckets, |
| 195 | + bucket_name) |
| 196 | + |
| 197 | + @Endpoint(method='DELETE', path='/sync-pipe') |
| 198 | + @EndpointDoc("Remove the sync pipe") |
| 199 | + @DeletePermission |
| 200 | + def remove_sync_pipe(self, group_id: str, pipe_id: str, |
| 201 | + source_zones: Optional[List[str]] = None, |
| 202 | + destination_zones: Optional[List[str]] = None, |
| 203 | + destination_buckets: Optional[List[str]] = None, |
| 204 | + bucket_name: str = ''): |
| 205 | + multisite_instance = RgwMultisite() |
| 206 | + return multisite_instance.remove_sync_pipe(group_id, pipe_id, source_zones, |
| 207 | + destination_zones, destination_buckets, |
| 208 | + bucket_name) |
| 209 | + |
126 | 210 |
|
127 | 211 | @APIRouter('/rgw/daemon', Scope.RGW) |
128 | 212 | @APIDoc("RGW Daemon Management API", "RgwDaemon") |
|
0 commit comments