File: _proxy.py

package info (click to toggle)
python-openstacksdk 4.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,352 kB
  • sloc: python: 122,960; sh: 153; makefile: 23
file content (1249 lines) | stat: -rw-r--r-- 51,884 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import typing as ty

from openstack import exceptions
from openstack import proxy
from openstack import resource
from openstack.shared_file_system.v2 import (
    availability_zone as _availability_zone,
)
from openstack.shared_file_system.v2 import limit as _limit
from openstack.shared_file_system.v2 import quota_class_set as _quota_class_set
from openstack.shared_file_system.v2 import resource_locks as _resource_locks
from openstack.shared_file_system.v2 import share as _share
from openstack.shared_file_system.v2 import share_group as _share_group
from openstack.shared_file_system.v2 import (
    share_group_snapshot as _share_group_snapshot,
)
from openstack.shared_file_system.v2 import (
    share_access_rule as _share_access_rule,
)
from openstack.shared_file_system.v2 import (
    share_export_locations as _share_export_locations,
)
from openstack.shared_file_system.v2 import share_instance as _share_instance
from openstack.shared_file_system.v2 import share_network as _share_network
from openstack.shared_file_system.v2 import (
    share_network_subnet as _share_network_subnet,
)
from openstack.shared_file_system.v2 import share_snapshot as _share_snapshot
from openstack.shared_file_system.v2 import (
    share_snapshot_instance as _share_snapshot_instance,
)
from openstack.shared_file_system.v2 import storage_pool as _storage_pool
from openstack.shared_file_system.v2 import user_message as _user_message


class Proxy(proxy.Proxy):
    _resource_registry = {
        "availability_zone": _availability_zone.AvailabilityZone,
        "share_snapshot": _share_snapshot.ShareSnapshot,
        "storage_pool": _storage_pool.StoragePool,
        "user_message": _user_message.UserMessage,
        "limit": _limit.Limit,
        "share": _share.Share,
        "share_network": _share_network.ShareNetwork,
        "share_network_subnet": _share_network_subnet.ShareNetworkSubnet,
        "share_snapshot_instance": _share_snapshot_instance.ShareSnapshotInstance,  # noqa: E501
        "share_instance": _share_instance.ShareInstance,
        "share_export_locations": _share_export_locations.ShareExportLocation,
        "share_access_rule": _share_access_rule.ShareAccessRule,
        "share_group": _share_group.ShareGroup,
        "share_group_snapshot": _share_group_snapshot.ShareGroupSnapshot,
        "resource_locks": _resource_locks.ResourceLock,
        "quota_class_set": _quota_class_set.QuotaClassSet,
    }

    def availability_zones(self):
        """Retrieve shared file system availability zones

        :returns: A generator of availability zone resources
        :rtype:
            :class:`~openstack.shared_file_system.v2.availability_zone.AvailabilityZone`
        """
        return self._list(_availability_zone.AvailabilityZone)

    def shares(self, details=True, **query):
        """Lists all shares with details

        :param kwargs query: Optional query parameters to be sent to limit
            the shares being returned.  Available parameters include:

            * status: Filters by a share status
            * share_server_id: The UUID of the share server.
            * metadata: One or more metadata key and value pairs as a url
              encoded dictionary of strings.
            * extra_specs: The extra specifications as a set of one or more
              key-value pairs.
            * share_type_id: The UUID of a share type to query resources by.
            * name: The user defined name of the resource to filter resources
              by.
            * snapshot_id: The UUID of the share’s base snapshot to filter
              the request based on.
            * host: The host name of the resource to query with.
            * share_network_id: The UUID of the share network to filter
              resources by.
            * project_id: The ID of the project that owns the resource.
            * is_public: A boolean query parameter that, when set to true,
              allows retrieving public resources that belong to
              all projects.
            * share_group_id: The UUID of a share group to filter resource.
            * export_location_id: The export location UUID that can be used
              to filter shares or share instances.
            * export_location_path: The export location path that can be used
              to filter shares or share instances.
            * name~: The name pattern that can be used to filter shares, share
              snapshots, share networks or share groups.
            * description~: The description pattern that can be used to filter
              shares, share snapshots, share networks or share groups.
            * with_count: Whether to show count in API response or not,
              default is False.
            * limit: The maximum number of shares to return.
            * offset: The offset to define start point of share or share group
              listing.
            * sort_key: The key to sort a list of shares.
            * sort_dir: The direction to sort a list of shares. A valid value
              is asc, or desc.

        :returns: Details of shares resources
        :rtype: :class:`~openstack.shared_file_system.v2.share.Share`
        """
        base_path = '/shares/detail' if details else None
        return self._list(_share.Share, base_path=base_path, **query)

    def find_share(self, name_or_id, ignore_missing=True, **query):
        """Find a single share

        :param name_or_id: The name or ID of a share.
        :param bool ignore_missing: When set to ``False``
            :class:`~openstack.exceptions.NotFoundException` will be
            raised when the resource does not exist.
            When set to ``True``, None will be returned when
            attempting to find a nonexistent resource.
        :param dict query: Any additional parameters to be passed into
            underlying methods. such as query filters.

        :returns: One :class:`~openstack.shared_file_system.v2.share.Share`
                  or None
        """

        return self._find(
            _share.Share, name_or_id, ignore_missing=ignore_missing, **query
        )

    def get_share(self, share_id):
        """Lists details of a single share

        :param share: The ID of the share to get
        :returns: Details of the identified share
        :rtype: :class:`~openstack.shared_file_system.v2.share.Share`
        """
        return self._get(_share.Share, share_id)

    def delete_share(self, share, ignore_missing=True):
        """Deletes a single share

        :param share: The ID of the share to delete
        :returns: Result of the ``delete``
        :rtype: ``None``
        """
        self._delete(_share.Share, share, ignore_missing=ignore_missing)

    def update_share(self, share_id, **attrs):
        """Updates details of a single share.

        :param share: The ID of the share to update
        :param dict attrs: The attributes to update on the share
        :returns: the updated share
        :rtype: :class:`~openstack.shared_file_system.v2.share.Share`
        """
        return self._update(_share.Share, share_id, **attrs)

    def create_share(self, **attrs):
        """Creates a share from attributes

        :returns: Details of the new share
        :param dict attrs: Attributes which will be used to create
            a :class:`~openstack.shared_file_system.v2.shares.Shares`,
            comprised of the properties on the Shares class. 'size' and 'share'
            are required to create a share.
        :rtype: :class:`~openstack.shared_file_system.v2.share.Share`
        """
        return self._create(_share.Share, **attrs)

    def revert_share_to_snapshot(self, share_id, snapshot_id):
        """Reverts a share to the specified snapshot, which must be
            the most recent one known to manila.

        :param share_id: The ID of the share to revert
        :param snapshot_id: The ID of the snapshot to revert to
        :returns: Result of the ``revert``
        :rtype: ``None``
        """
        res = self._get(_share.Share, share_id)
        res.revert_to_snapshot(self, snapshot_id)

    def manage_share(self, protocol, export_path, service_host, **params):
        """Manage a share.

        :param str protocol: The shared file systems protocol of this share.
        :param str export_path: The export path formatted according to the
            protocol.
        :param str service_host: The manage-share service host.
        :param kwargs params: Optional parameters to be sent. Available
            parameters include:
            * name: The user defined name of the resource.
            * share_type: The name or ID of the share type to be used to create
            the resource.
            * driver_options: A set of one or more key and value pairs, as a
            dictionary of strings, that describe driver options.
            * is_public: The level of visibility for the share.
            * description: The user defiend description of the resource.
            * share_server_id: The UUID of the share server.

        :returns: The share that was managed.
        """

        share = _share.Share()
        return share.manage(
            self, protocol, export_path, service_host, **params
        )

    def unmanage_share(self, share_id):
        """Unmanage the share with the given share ID.

        :param share_id: The ID of the share to unmanage.
        :returns: ``None``
        """

        share_to_unmanage = self._get(_share.Share, share_id)
        share_to_unmanage.unmanage(self)

    def resize_share(
        self, share_id, new_size, no_shrink=False, no_extend=False, force=False
    ):
        """Resizes a share, extending/shrinking the share as needed.

        :param share_id: The ID of the share to resize
        :param new_size: The new size of the share in GiBs. If new_size is
            the same as the current size, then nothing is done.
        :param bool no_shrink: If set to True, the given share is not shrunk,
            even if shrinking the share is required to get the share to the
            given size. This could be useful for extending shares to a minimum
            size, while not shrinking shares to the given size. This defaults
            to False.
        :param bool no_extend: If set to True, the given share is not
            extended, even if extending the share is required to get the share
            to the given size. This could be useful for shrinking shares to a
            maximum size, while not extending smaller shares to that maximum
            size. This defaults to False.
        :param bool force: Whether or not force should be used,
            in the case where the share should be extended.
        :returns: ``None``
        """

        res = self._get(_share.Share, share_id)

        if new_size > res.size and no_extend is not True:
            res.extend_share(self, new_size, force)
        elif new_size < res.size and no_shrink is not True:
            res.shrink_share(self, new_size)

    def share_groups(self, **query):
        """Lists all share groups.

        :param kwargs query: Optional query parameters to be sent to limit
            the share groups being returned.  Available parameters include:

            * status: Filters by a share group status.
            * name: The user defined name of the resource to filter resources
                by.
            * description: The user defined description text that can be used
                to filter resources.
            * project_id: The project ID of the user or service.
            * share_server_id: The UUID of the share server.
            * snapshot_id: The UUID of the share’s base snapshot to filter
                the request based on.
            * host: The host name for the back end.
            * share_network_id: The UUID of the share network to filter
                resources by.
            * share_group_type_id: The share group type ID to filter
                share groups.
            * share_group_snapshot_id: The source share group snapshot ID to
                list the share group.
            * share_types: A list of one or more share type IDs. Allows
                filtering share groups.
            * limit: The maximum number of share groups members to return.
            * offset: The offset to define start point of share or share
                group listing.
            * sort_key: The key to sort a list of shares.
            * sort_dir: The direction to sort a list of shares
            * name~: The name pattern that can be used to filter shares,
                share snapshots, share networks or share groups.
            * description~: The description pattern that can be used to
                filter shares, share snapshots, share networks or share groups.

        :returns: A generator of manila share group resources
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_group.ShareGroup`
        """
        return self._list(_share_group.ShareGroup, **query)

    def get_share_group(self, share_group_id):
        """Lists details for a share group.

        :param share: The ID of the share group to get
        :returns: Details of the identified share group
        :rtype: :class:`~openstack.shared_file_system.v2.
                                    share_group.ShareGroup`
        """
        return self._get(_share_group.ShareGroup, share_group_id)

    def find_share_group(self, name_or_id, ignore_missing=True):
        """Finds a single share group

        :param name_or_id: The name or ID of a share group.
        :param bool ignore_missing: When set to ``False``
            :class:`~openstack.exceptions.NotFoundException` will be
            raised when the resource does not exist.
            When set to ``True``, None will be returned when
            attempting to find a nonexistent resource.
        :returns: One :class:`~openstack.shared_file_system.v2.
                                        share_group.ShareGroup`
                                        or None
        """
        return self._find(
            _share_group.ShareGroup, name_or_id, ignore_missing=ignore_missing
        )

    def create_share_group(self, **attrs):
        """Creates a share group from attributes

        :returns: Details of the new share group
        :rtype: :class:`~openstack.shared_file_system.v2.
                                    share_group.ShareGroup`
        """
        return self._create(_share_group.ShareGroup, **attrs)

    def update_share_group(self, share_group_id, **kwargs):
        """Updates details of a single share group

        :param share: The ID of the share group
        :returns: Updated details of the identified share group
        :rtype: :class:`~openstack.shared_file_system.v2.
                                    share_group.ShareGroup`
        """
        return self._update(_share_group.ShareGroup, share_group_id, **kwargs)

    def delete_share_group(self, share_group_id, ignore_missing=True):
        """Deletes a single share group

        :param share: The ID of the share group
        :returns: Result of the "delete" on share group
        :rtype: :class:`~openstack.shared_file_system.v2.
                                    share_group.ShareGroup`
        """
        return self._delete(
            _share_group.ShareGroup,
            share_group_id,
            ignore_missing=ignore_missing,
        )

    def storage_pools(self, details=True, **query):
        """Lists all back-end storage pools with details

        :param kwargs query: Optional query parameters to be sent to limit
            the storage pools being returned.  Available parameters include:

            * pool_name: The pool name for the back end.
            * host_name: The host name for the back end.
            * backend_name: The name of the back end.
            * capabilities: The capabilities for the storage back end.
            * share_type: The share type name or UUID.
        :returns: A generator of manila storage pool resources
        :rtype:
            :class:`~openstack.shared_file_system.v2.storage_pool.StoragePool`
        """
        base_path = '/scheduler-stats/pools/detail' if details else None
        return self._list(
            _storage_pool.StoragePool, base_path=base_path, **query
        )

    def user_messages(self, **query):
        """List shared file system user messages

        :param kwargs query: Optional query parameters to be sent to limit
            the messages being returned.  Available parameters include:

            * action_id: The ID of the action during which the message
              was created.
            * detail_id: The ID of the message detail.
            * limit: The maximum number of shares to return.
            * message_level: The message level.
            * offset: The offset to define start point of share or share
              group listing.
            * sort_key: The key to sort a list of messages.
            * sort_dir: The direction to sort a list of shares.
            * project_id: The ID of the project for which the message
              was created.
            * request_id: The ID of the request during which the message
              was created.
            * resource_id: The UUID of the resource for which the message
              was created.
            * resource_type: The type of the resource for which the message
              was created.

        :returns: A generator of user message resources
        :rtype:
            :class:`~openstack.shared_file_system.v2.user_message.UserMessage`
        """
        return self._list(_user_message.UserMessage, **query)

    def get_user_message(self, message_id):
        """List details of a single user message

        :param message_id: The ID of the user message
        :returns: Details of the identified user message
        :rtype:
            :class:`~openstack.shared_file_system.v2.user_message.UserMessage`
        """
        return self._get(_user_message.UserMessage, message_id)

    def delete_user_message(self, message_id, ignore_missing=True):
        """Deletes a single user message

        :param message_id: The ID of the user message
        :returns: Result of the "delete" on the user message
        :rtype:
            :class:`~openstack.shared_file_system.v2.user_message.UserMessage`
        """
        return self._delete(
            _user_message.UserMessage,
            message_id,
            ignore_missing=ignore_missing,
        )

    def limits(self, **query):
        """Lists all share limits.

        :param kwargs query: Optional query parameters to be sent to limit
            the share limits being returned.

        :returns: A generator of manila share limits resources
        :rtype: :class:`~openstack.shared_file_system.v2.limit.Limit`
        """
        return self._list(_limit.Limit, **query)

    def share_snapshots(self, details=True, **query):
        """Lists all share snapshots with details.

        :param kwargs query: Optional query parameters to be sent to limit
            the snapshots being returned.  Available parameters include:

            * project_id: The ID of the user or service making the API request.

        :returns: A generator of manila share snapshot resources
        :rtype:
            :class:`~openstack.shared_file_system.v2.share_snapshot.ShareSnapshot`
        """
        base_path = '/snapshots/detail' if details else None
        return self._list(
            _share_snapshot.ShareSnapshot, base_path=base_path, **query
        )

    def get_share_snapshot(self, snapshot_id):
        """Lists details of a single share snapshot

        :param snapshot_id: The ID of the snapshot to get
        :returns: Details of the identified share snapshot
        :rtype:
            :class:`~openstack.shared_file_system.v2.share_snapshot.ShareSnapshot`
        """
        return self._get(_share_snapshot.ShareSnapshot, snapshot_id)

    def create_share_snapshot(self, **attrs):
        """Creates a share snapshot from attributes

        :returns: Details of the new share snapshot
        :rtype:
            :class:`~openstack.shared_file_system.v2.share_snapshot.ShareSnapshot`
        """
        return self._create(_share_snapshot.ShareSnapshot, **attrs)

    def update_share_snapshot(self, snapshot_id, **attrs):
        """Updates details of a single share.

        :param snapshot_id: The ID of the snapshot to update
        :pram dict attrs: The attributes to update on the snapshot
        :returns: the updated share snapshot
        :rtype:
            :class:`~openstack.shared_file_system.v2.share_snapshot.ShareSnapshot`
        """
        return self._update(
            _share_snapshot.ShareSnapshot, snapshot_id, **attrs
        )

    def delete_share_snapshot(self, snapshot_id, ignore_missing=True):
        """Deletes a single share snapshot

        :param snapshot_id: The ID of the snapshot to delete
        :returns: Result of the ``delete``
        :rtype: ``None``
        """
        self._delete(
            _share_snapshot.ShareSnapshot,
            snapshot_id,
            ignore_missing=ignore_missing,
        )

    # ========= Network Subnets ==========
    def share_network_subnets(self, share_network_id):
        """Lists all share network subnets with details.

        :param share_network_id: The id of the share network for which
            Share Network Subnets should be listed.
        :returns: A generator of manila share network subnets
        :rtype:
            :class:`~openstack.shared_file_system.v2.share_network_subnet.ShareNetworkSubnet`
        """
        return self._list(
            _share_network_subnet.ShareNetworkSubnet,
            share_network_id=share_network_id,
        )

    def get_share_network_subnet(
        self,
        share_network_id,
        share_network_subnet_id,
    ):
        """Lists details of a single share network subnet.

        :param share_network_id: The id of the share network associated
            with the Share Network Subnet.
        :param share_network_subnet_id: The id of the Share Network Subnet
            to retrieve.
        :returns: Details of the identified share network subnet
        :rtype:
            :class:`~openstack.shared_file_system.v2.share_network_subnet.ShareNetworkSubnet`
        """

        return self._get(
            _share_network_subnet.ShareNetworkSubnet,
            share_network_subnet_id,
            share_network_id=share_network_id,
        )

    def create_share_network_subnet(self, share_network_id, **attrs):
        """Creates a share network subnet from attributes

        :param share_network_id: The id of the share network wthin which the
            the Share Network Subnet should be created.
        :param dict attrs: Attributes which will be used to create
            a share network subnet.
        :returns: Details of the new share network subnet.
        :rtype:
            :class:`~openstack.shared_file_system.v2.share_network_subnet.ShareNetworkSubnet`
        """
        return self._create(
            _share_network_subnet.ShareNetworkSubnet,
            **attrs,
            share_network_id=share_network_id,
        )

    def delete_share_network_subnet(
        self, share_network_id, share_network_subnet, ignore_missing=True
    ):
        """Deletes a share network subnet.

        :param share_network_id: The id of the Share Network associated with
            the Share Network Subnet.
        :param share_network_subnet: The id of the Share Network Subnet
            which should be deleted.
        :returns: Result of the ``delete``
        :rtype: None
        """

        self._delete(
            _share_network_subnet.ShareNetworkSubnet,
            share_network_subnet,
            share_network_id=share_network_id,
            ignore_missing=ignore_missing,
        )

    def share_snapshot_instances(self, details=True, **query):
        """Lists all share snapshot instances with details.

        :param bool details: Whether to fetch detailed resource
            descriptions. Defaults to True.
        :param kwargs query: Optional query parameters to be sent to limit
            the share snapshot instance being returned.
            Available parameters include:

            * snapshot_id: The UUID of the share’s base snapshot to filter
                the request based on.
            * project_id: The project ID of the user or service making the
                request.

        :returns: A generator of share snapshot instance resources
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_snapshot_instance.ShareSnapshotInstance`
        """
        base_path = '/snapshot-instances/detail' if details else None
        return self._list(
            _share_snapshot_instance.ShareSnapshotInstance,
            base_path=base_path,
            **query,
        )

    def get_share_snapshot_instance(self, snapshot_instance_id):
        """Lists details of a single share snapshot instance

        :param snapshot_instance_id: The ID of the snapshot instance to get
        :returns: Details of the identified snapshot instance
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_snapshot_instance.ShareSnapshotInstance`
        """
        return self._get(
            _share_snapshot_instance.ShareSnapshotInstance,
            snapshot_instance_id,
        )

    def share_networks(self, details=True, **query):
        """Lists all share networks with details.

        :param dict query: Optional query parameters to be sent to limit the
            resources being returned. Available parameters include:

            * name~: The user defined name of the resource to filter resources
              by.
            * project_id: The ID of the user or service making the request.
            * description~: The description pattern that can be used to filter
              shares, share snapshots, share networks or share groups.
            * all_projects: (Admin only). Defines whether to list the requested
              resources for all projects.

        :returns: Details of shares networks
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_network.ShareNetwork`
        """
        base_path = '/share-networks/detail' if details else None
        return self._list(
            _share_network.ShareNetwork, base_path=base_path, **query
        )

    def get_share_network(self, share_network_id):
        """Lists details of a single share network

        :param share_network: The ID of the share network to get
        :returns: Details of the identified share network
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_network.ShareNetwork`
        """
        return self._get(_share_network.ShareNetwork, share_network_id)

    def delete_share_network(self, share_network_id, ignore_missing=True):
        """Deletes a single share network

        :param share_network_id: The ID of the share network to delete
        :rtype: ``None``
        """
        self._delete(
            _share_network.ShareNetwork,
            share_network_id,
            ignore_missing=ignore_missing,
        )

    def update_share_network(self, share_network_id, **attrs):
        """Updates details of a single share network.

        :param share_network_id: The ID of the share network to update
        :pram dict attrs: The attributes to update on the share network
        :returns: the updated share network
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_network.ShareNetwork`
        """
        return self._update(
            _share_network.ShareNetwork, share_network_id, **attrs
        )

    def create_share_network(self, **attrs):
        """Creates a share network from attributes

        :returns: Details of the new share network
        :param dict attrs: Attributes which will be used to create
            a :class:`~openstack.shared_file_system.v2.
            share_network.ShareNetwork`,comprised of the properties
            on the ShareNetwork class.
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_network.ShareNetwork`
        """
        return self._create(_share_network.ShareNetwork, **attrs)

    def share_instances(self, **query):
        """Lists all share instances.

        :param kwargs query: Optional query parameters to be sent to limit
            the share instances being returned. Available parameters include:

        * export_location_id: The export location UUID that can be used
          to filter share instances.
        * export_location_path: The export location path that can be used
          to filter share instances.

        :returns: Details of share instances resources
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_instance.ShareInstance`
        """
        return self._list(_share_instance.ShareInstance, **query)

    def get_share_instance(self, share_instance_id):
        """Shows details for a single share instance

        :param share_instance_id: The UUID of the share instance to get

        :returns: Details of the identified share instance
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_instance.ShareInstance`
        """
        return self._get(_share_instance.ShareInstance, share_instance_id)

    def reset_share_instance_status(self, share_instance_id, status):
        """Explicitly updates the state of a share instance.

        :param share_instance_id: The UUID of the share instance to reset.
        :param status: The share or share instance status to be set.

        :returns: ``None``
        """
        res = self._get_resource(
            _share_instance.ShareInstance, share_instance_id
        )
        res.reset_status(self, status)

    def delete_share_instance(self, share_instance_id):
        """Force-deletes a share instance

        :param share_instance: The ID of the share instance to delete

        :returns: ``None``
        """
        res = self._get_resource(
            _share_instance.ShareInstance, share_instance_id
        )
        res.force_delete(self)

    def export_locations(self, share_id):
        """List all export locations with details

        :param share_id: The ID of the share to list export locations from
        :returns: List of export locations
        :rtype: List of :class:`~openstack.shared_filesystem_storage.v2.
            share_export_locations.ShareExportLocations`
        """
        return self._list(
            _share_export_locations.ShareExportLocation, share_id=share_id
        )

    def get_export_location(self, export_location, share_id):
        """List details of export location

        :param export_location: The export location resource to get
        :param share_id: The ID of the share to get export locations from
        :returns: Details of identified export location
        :rtype: :class:`~openstack.shared_filesystem_storage.v2.
            share_export_locations.ShareExportLocations`
        """

        export_location_id = resource.Resource._get_id(export_location)
        return self._get(
            _share_export_locations.ShareExportLocation,
            export_location_id,
            share_id=share_id,
        )

    def access_rules(self, share, **query):
        """Lists the access rules on a share.

        :returns: A generator of the share access rules.
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_access_rules.ShareAccessRules`
        """
        share = self._get_resource(_share.Share, share)
        return self._list(
            _share_access_rule.ShareAccessRule, share_id=share.id, **query
        )

    def get_access_rule(self, access_id):
        """List details of an access rule.

        :param access_id: The id of the access rule to get
        :returns: Details of the identified access rule.
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_access_rules.ShareAccessRules`
        """
        return self._get(_share_access_rule.ShareAccessRule, access_id)

    def create_access_rule(self, share_id, **attrs):
        """Creates an access rule from attributes

        :returns: Details of the new access rule
        :param share_id: The ID of the share
        :param dict attrs: Attributes which will be used to create
            a :class:`~openstack.shared_file_system.v2.
            share_access_rules.ShareAccessRules`, comprised of the
            properties on the ShareAccessRules class.
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_access_rules.ShareAccessRules`
        """
        base_path = f"/shares/{share_id}/action"
        return self._create(
            _share_access_rule.ShareAccessRule, base_path=base_path, **attrs
        )

    def delete_access_rule(
        self, access_id, share_id, ignore_missing=True, *, unrestrict=False
    ):
        """Deletes an access rule

        :param access_id: The id of the access rule to get
        :param share_id: The ID of the share
        :param unrestrict: If Manila must attempt removing locks while deleting

        :rtype: ``requests.models.Response`` HTTP response from internal
            requests client
        """
        res = self._get_resource(
            _share_access_rule.ShareAccessRule, access_id, share_id=share_id
        )
        try:
            return res.delete(
                self,
                unrestrict=unrestrict,
            )
        except exceptions.NotFoundException:
            if ignore_missing:
                return None
            raise

    def share_group_snapshots(self, details=True, **query):
        """Lists all share group snapshots.

        :param kwargs query: Optional query parameters to be sent
            to limit the share group snapshots being returned.
            Available parameters include:

            * project_id: The ID of the project that owns the resource.
            * name: The user defined name of the resource to filter resources.
            * description: The user defined description text that can be used
              to filter resources.
            * status: Filters by a share status
            * share_group_id: The UUID of a share group to filter resource.
            * limit: The maximum number of share group snapshot members
              to return.
            * offset: The offset to define start point of share or
              share group listing.
            * sort_key: The key to sort a list of shares.
            * sort_dir: The direction to sort a list of shares. A valid
              value is asc, or desc.

        :returns: Details of share group snapshots resources
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_group_snapshot.ShareGroupSnapshot`
        """
        base_path = '/share-group-snapshots/detail' if details else None
        return self._list(
            _share_group_snapshot.ShareGroupSnapshot,
            base_path=base_path,
            **query,
        )

    def share_group_snapshot_members(self, group_snapshot_id):
        """Lists all share group snapshots members.

        :param group_snapshot_id: The ID of the group snapshot to get
        :returns: List of the share group snapshot members, which are
            share snapshots.
        :rtype: dict containing attributes of the share snapshot members.
        """
        res = self._get(
            _share_group_snapshot.ShareGroupSnapshot,
            group_snapshot_id,
        )
        response = res.get_members(self)
        return response

    def get_share_group_snapshot(self, group_snapshot_id):
        """Show share group snapshot details

        :param group_snapshot_id: The ID of the group snapshot to get
        :returns: Details of the group snapshot
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_group_snapshot.ShareGroupSnapshot`
        """
        return self._get(
            _share_group_snapshot.ShareGroupSnapshot, group_snapshot_id
        )

    def create_share_group_snapshot(self, share_group_id, **attrs):
        """Creates a point-in-time snapshot copy of a share group.

        :returns: Details of the new snapshot
        :param dict attrs: Attributes which will be used to create
            a :class:`~openstack.shared_file_system.v2.
            share_group_snapshots.ShareGroupSnapshots`,
        :param 'share_group_id': ID of the share group to have the snapshot
            taken.
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_group_snapshot.ShareGroupSnapshot`
        """
        return self._create(
            _share_group_snapshot.ShareGroupSnapshot,
            share_group_id=share_group_id,
            **attrs,
        )

    def reset_share_group_snapshot_status(self, group_snapshot_id, status):
        """Reset share group snapshot state.

        :param group_snapshot_id: The ID of the share group snapshot to reset
        :param status: The state of the share group snapshot to be set, A
            valid value is "creating", "error", "available", "deleting",
            "error_deleting".
        :rtype: ``None``
        """
        res = self._get(
            _share_group_snapshot.ShareGroupSnapshot, group_snapshot_id
        )
        res.reset_status(self, status)

    def update_share_group_snapshot(self, group_snapshot_id, **attrs):
        """Updates a share group snapshot.

        :param group_snapshot_id: The ID of the share group snapshot to update
        :param dict attrs: The attributes to update on the share group snapshot
        :returns: the updated share group snapshot
        :rtype: :class:`~openstack.shared_file_system.v2.
            share_group_snapshot.ShareGroupSnapshot`
        """
        return self._update(
            _share_group_snapshot.ShareGroupSnapshot,
            group_snapshot_id,
            **attrs,
        )

    def delete_share_group_snapshot(
        self, group_snapshot_id, ignore_missing=True
    ):
        """Deletes a share group snapshot.

        :param group_snapshot_id: The ID of the share group snapshot to delete
        :rtype: ``None``
        """
        self._delete(
            _share_group_snapshot.ShareGroupSnapshot,
            group_snapshot_id,
            ignore_missing=ignore_missing,
        )

    # ========= Share Metadata ==========
    def get_share_metadata(self, share_id):
        """Lists all metadata for a share.

        :param share_id: The ID of the share

        :returns: A :class:`~openstack.shared_file_system.v2.share.Share`
            with the share's metadata.
        :rtype:
            :class:`~openstack.shared_file_system.v2.share.Share`
        """
        share = self._get_resource(_share.Share, share_id)
        return share.fetch_metadata(self)

    def get_share_metadata_item(self, share_id, key):
        """Retrieves a specific metadata item from a share by its key.

        :param share_id: The ID of the share
        :param key: The key of the share metadata

        :returns: A :class:`~openstack.shared_file_system.v2.share.Share`
            with the share's metadata.
        :rtype:
            :class:`~openstack.shared_file_system.v2.share.Share`
        """
        share = self._get_resource(_share.Share, share_id)
        return share.get_metadata_item(self, key)

    def create_share_metadata(self, share_id, **metadata):
        """Creates share metadata as key-value pairs.

        :param share_id: The ID of the share
        :param metadata: The metadata to be created

        :returns: A :class:`~openstack.shared_file_system.v2.share.Share`
            with the share's metadata.
        :rtype:
            :class:`~openstack.shared_file_system.v2.share.Share`
        """
        share = self._get_resource(_share.Share, share_id)
        return share.set_metadata(self, metadata=metadata)

    def update_share_metadata(self, share_id, metadata, replace=False):
        """Updates metadata of given share.

        :param share_id: The ID of the share
        :param metadata: The metadata to be created
        :param replace: Boolean for whether the preexisting metadata
            should be replaced

        :returns: A :class:`~openstack.shared_file_system.v2.share.Share`
            with the share's updated metadata.
        :rtype:
            :class:`~openstack.shared_file_system.v2.share.Share`
        """
        share = self._get_resource(_share.Share, share_id)
        return share.set_metadata(self, metadata=metadata, replace=replace)

    def delete_share_metadata(self, share_id, keys, ignore_missing=True):
        """Deletes a single metadata item on a share, idetified by its key.

        :param share_id: The ID of the share
        :param keys: The list of share metadata keys to be deleted
        :param ignore_missing: Boolean indicating if missing keys should be ignored.

        :returns: None
        :rtype: None
        """
        share = self._get_resource(_share.Share, share_id)
        keys_failed_to_delete = []
        for key in keys:
            try:
                share.delete_metadata_item(self, key)
            except exceptions.NotFoundException:
                if not ignore_missing:
                    self._connection.log.info("Key %s not found.", key)
                    keys_failed_to_delete.append(key)
            except exceptions.ForbiddenException:
                self._connection.log.info("Key %s cannot be deleted.", key)
                keys_failed_to_delete.append(key)
            except exceptions.SDKException:
                self._connection.log.info("Failed to delete key %s.", key)
                keys_failed_to_delete.append(key)
        if keys_failed_to_delete:
            raise exceptions.SDKException(
                f"Some keys failed to be deleted {keys_failed_to_delete}"
            )

    def resource_locks(self, **query):
        """Lists all resource locks.

        :param kwargs query: Optional query parameters to be sent to limit
            the resource locks being returned.  Available parameters include:

            * project_id: The project ID of the user that the lock is
                created for.
            * user_id: The ID of a user to filter resource locks by.
            * all_projects: list locks from all projects (Admin Only)
            * resource_id: The ID of the resource that the locks pertain to
                filter resource locks by.
            * resource_action: The action prevented by the filtered resource
                locks.
            * resource_type: The type of the resource that the locks pertain
                to filter resource locks by.
            * lock_context: The lock creator’s context to filter locks by.
            * lock_reason: The lock reason that can be used to filter resource
                locks. (Inexact search is also available with lock_reason~)
            * created_since: Search for the list of resources that were created
                after the specified date. The date is in ‘yyyy-mm-dd’ format.
            * created_before: Search for the list of resources that were
                created prior to the specified date. The date is in
                ‘yyyy-mm-dd’ format.
            * limit: The maximum number of resource locks to return.
            * offset: The offset to define start point of resource lock
                listing.
            * sort_key: The key to sort a list of shares.
            * sort_dir: The direction to sort a list of shares
            * with_count: Whether to show count in API response or not,
                default is False. This query parameter is useful with
                pagination.

        :returns: A generator of manila resource locks
        :rtype: :class:`~openstack.shared_file_system.v2.
            resource_locks.ResourceLock`
        """

        if query.get('resource_type'):
            # The _create method has a parameter named resource_type, which
            # refers to the type of resource to be created, so we need to avoid
            # a conflict of parameters we are sending to the method.
            query['__conflicting_attrs'] = {
                'resource_type': query.get('resource_type')
            }
            query.pop('resource_type')
        return self._list(_resource_locks.ResourceLock, **query)

    def get_resource_lock(self, resource_lock):
        """Show details of a resource lock.

        :param resource_lock: The ID of a resource lock or a
            :class:`~openstack.shared_file_system.v2.
            resource_locks.ResourceLock` instance.
        :returns: Details of the identified resource lock.
        :rtype: :class:`~openstack.shared_file_system.v2.
            resource_locks.ResourceLock`
        """
        return self._get(_resource_locks.ResourceLock, resource_lock)

    def update_resource_lock(self, resource_lock, **attrs):
        """Updates details of a single resource lock.

        :param resource_lock: The ID of a resource lock or a
            :class:`~openstack.shared_file_system.v2.
            resource_locks.ResourceLock` instance.
        :param dict attrs: The attributes to update on the resource lock
        :returns: the updated resource lock
        :rtype: :class:`~openstack.shared_file_system.v2.
            resource_locks.ResourceLock`
        """
        return self._update(
            _resource_locks.ResourceLock, resource_lock, **attrs
        )

    def delete_resource_lock(self, resource_lock, ignore_missing=True):
        """Deletes a single resource lock

        :param resource_lock: The ID of a resource lock or a
            :class:`~openstack.shared_file_system.v2.
            resource_locks.ResourceLock` instance.
        :returns: Result of the ``delete``
        :rtype: ``None``
        """
        return self._delete(
            _resource_locks.ResourceLock,
            resource_lock,
            ignore_missing=ignore_missing,
        )

    def create_resource_lock(self, **attrs):
        """Locks a resource.

        :param dict attrs: Attributes which will be used to create
            a :class:`~openstack.shared_file_system.v2.
            resource_locks.ResourceLock`, comprised of the properties
            on the ResourceLock class. Available parameters include:

            * ``resource_id``: ID of the resource to be locked.
            * ``resource_type``: type of the resource (share, access_rule).
            * ``resource_action``: action to be locked (delete, show).
            * ``lock_reason``: reason why you're locking the resource
                (Optional).
        :returns: Details of the lock
        :rtype: :class:`~openstack.shared_file_system.v2.
            resource_locks.ResourceLock`
        """

        if attrs.get('resource_type'):
            # The _create method has a parameter named resource_type, which
            # refers to the type of resource to be created, so we need to avoid
            # a conflict of parameters we are sending to the method.
            attrs['__conflicting_attrs'] = {
                'resource_type': attrs.get('resource_type')
            }
            attrs.pop('resource_type')
        return self._create(_resource_locks.ResourceLock, **attrs)

    def get_quota_class_set(self, quota_class_name):
        """Get quota class set.

        :param quota_class_name: The name of the quota class
        :returns: A :class:`~openstack.shared_file_system.v2
            .quota_class_set.QuotaClassSet`
        """
        return self._get(_quota_class_set.QuotaClassSet, quota_class_name)

    def update_quota_class_set(self, quota_class_name, **attrs):
        """Update quota class set.

        :param quota_class_name: The name of the quota class
        :param attrs: The attributes to update on the quota class set
        :returns: the updated quota class set
        :rtype: :class:`~openstack.shared_file_system.v2
            .quota_class_set.QuotaClassSet`
        """

        return self._update(
            _quota_class_set.QuotaClassSet, quota_class_name, **attrs
        )

    # ========== Utilities ==========

    def wait_for_status(
        self,
        res: resource.ResourceT,
        status: str,
        failures: ty.Optional[list[str]] = None,
        interval: ty.Union[int, float, None] = 2,
        wait: ty.Optional[int] = None,
        attribute: str = 'status',
        callback: ty.Optional[ty.Callable[[int], None]] = None,
    ) -> resource.ResourceT:
        """Wait for the resource to be in a particular status.

        :param session: The session to use for making this request.
        :param resource: The resource to wait on to reach the status. The
            resource must have a status attribute specified via ``attribute``.
        :param status: Desired status of the resource.
        :param failures: Statuses that would indicate the transition
            failed such as 'ERROR'. Defaults to ['ERROR'].
        :param interval: Number of seconds to wait between checks.
        :param wait: Maximum number of seconds to wait for transition.
            Set to ``None`` to wait forever.
        :param attribute: Name of the resource attribute that contains the
            status.
        :param callback: A callback function. This will be called with a single
            value, progress. This is API specific but is generally a percentage
            value from 0-100.

        :return: The updated resource.
        :raises: :class:`~openstack.exceptions.ResourceTimeout` if the
            transition to status failed to occur in ``wait`` seconds.
        :raises: :class:`~openstack.exceptions.ResourceFailure` if the resource
            transitioned to one of the states in ``failures``.
        :raises: :class:`~AttributeError` if the resource does not have a
            ``status`` attribute
        """
        return resource.wait_for_status(
            self, res, status, failures, interval, wait, attribute, callback
        )

    def wait_for_delete(
        self,
        res: resource.ResourceT,
        interval: int = 2,
        wait: int = 120,
        callback: ty.Optional[ty.Callable[[int], None]] = None,
    ) -> resource.ResourceT:
        """Wait for a resource to be deleted.

        :param res: The resource to wait on to be deleted.
        :param interval: Number of seconds to wait before to consecutive
            checks.
        :param wait: Maximum number of seconds to wait before the change.
        :param callback: A callback function. This will be called with a single
            value, progress, which is a percentage value from 0-100.

        :returns: The resource is returned on success.
        :raises: :class:`~openstack.exceptions.ResourceTimeout` if transition
            to delete failed to occur in the specified seconds.
        """
        return resource.wait_for_delete(self, res, interval, wait, callback)