Пример #1
0
    def get_storage_gateway(
        self,
        storage_gateway_id: UUIDLike,
        *,
        include: Union[None, str, Iterable[str]] = None,
        query_params: Optional[Dict[str, Any]] = None,
    ) -> UnpackingGCSResponse:
        """
        ``GET /storage_gateways/<storage_gateway_id>``

        :param storage_gateway_id: UUID for the Storage Gateway to be gotten
        :type storage_gateway_id: str or UUID
        :param include: Optional document types to include in the response. If
            'private_policies' is included, then include private storage gateway
            policies in the attached storage_gateways document. This requires an
            ``administrator`` role on the Endpoint.
        :type include: str or iterable of str, optional
        :param query_params: Additional passthrough query parameters
        :type query_params: dict, optional
        """
        if query_params is None:
            query_params = {}
        if include is not None:
            query_params["include"] = ",".join(utils.safe_strseq_iter(include))

        return UnpackingGCSResponse(
            self.get(
                f"/storage_gateways/{storage_gateway_id}",
                query_params=query_params,
            ),
            "storage_gateway",
        )
Пример #2
0
 def _convert_listarg(
     val: Union[Iterable[Union[IntLike, UUIDLike]], Union[IntLike,
                                                          UUIDLike]]
 ) -> str:
     if isinstance(val, collections.abc.Iterable):
         return ",".join(utils.safe_strseq_iter(val))
     return str(val)
Пример #3
0
 def decline_invites(
         self,
         identity_ids: Iterable[UUIDLike]) -> "BatchMembershipActions":
     """
     Decline an invitation for a given set of identities.
     """
     self.setdefault("decline", []).extend(
         {"identity_id": identity_id}
         for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #4
0
 def request_join(
         self,
         identity_ids: Iterable[UUIDLike]) -> "BatchMembershipActions":
     """
     Request to join a group.
     """
     self.setdefault("request_join", []).extend(
         {"identity_id": identity_id}
         for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #5
0
 def approve_pending(
         self,
         identity_ids: Iterable[UUIDLike]) -> "BatchMembershipActions":
     """
     Approve a list of identities with pending join requests.
     """
     self.setdefault("approve", []).extend(
         {"identity_id": identity_id}
         for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #6
0
 def reject_join_requests(
         self,
         identity_ids: Iterable[UUIDLike]) -> "BatchMembershipActions":
     """
     Reject a members that have requested to join the group.
     """
     self.setdefault("reject", []).extend(
         {"identity_id": identity_id}
         for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #7
0
 def leave(self,
           identity_ids: Iterable[UUIDLike]) -> "BatchMembershipActions":
     """
     Leave a group that one of the identities in the authenticated user's
     identity set is a member of.
     """
     self.setdefault("leave", []).extend(
         {"identity_id": identity_id}
         for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #8
0
 def join(self,
          identity_ids: Iterable[UUIDLike]) -> "BatchMembershipActions":
     """
     Join a group with the given identities.  The identities must be in the
     authenticated users identity set.
     """
     self.setdefault("join", []).extend(
         {"identity_id": identity_id}
         for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #9
0
 def accept_invites(
         self,
         identity_ids: Iterable[UUIDLike]) -> "BatchMembershipActions":
     """
     Accept invites for identities.  The identities must belong to
     the identity set of authenticated user.
     """
     self.setdefault("accept", []).extend(
         {"identity_id": identity_id}
         for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #10
0
 def remove_members(
         self,
         identity_ids: Iterable[UUIDLike]) -> "BatchMembershipActions":
     """
     Remove members from a group.  This must be done as an admin or manager
     of the group.
     """
     self.setdefault("remove", []).extend(
         {"identity_id": identity_id}
         for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #11
0
 def __init__(
     self,
     resource_server: str,
     *,
     known_scopes: Union[List[str], str, None] = None,
     known_url_scopes: Union[List[str], str, None] = None,
 ) -> None:
     self.resource_server = resource_server
     self._known_scopes = (list(utils.safe_strseq_iter(known_scopes))
                           if known_scopes is not None else [])
     self._known_url_scopes = (list(
         utils.safe_strseq_iter(known_url_scopes))
                               if known_url_scopes is not None else [])
     self._known_scope_names: List[str] = []
     if self._known_scopes:
         for scope_name in self._known_scopes:
             self._known_scope_names.append(scope_name)
             setattr(self, scope_name, self.urn_scope_string(scope_name))
     if self._known_url_scopes:
         for scope_name in self._known_url_scopes:
             self._known_scope_names.append(scope_name)
             setattr(self, scope_name, self.url_scope_string(scope_name))
Пример #12
0
 def invite_members(
         self,
         identity_ids: Iterable[UUIDLike],
         *,
         role: GroupRole = GroupRole.member) -> "BatchMembershipActions":
     """
     Invite a list of identities to a group with the given role.
     """
     self.setdefault("invite", []).extend({
         "identity_id": identity_id,
         "role": role.value
     } for identity_id in utils.safe_strseq_iter(identity_ids))
     return self
Пример #13
0
    def get_collection_list(
        self,
        *,
        mapped_collection_id: Optional[UUIDLike] = None,
        filter: Union[  # pylint: disable=redefined-builtin
            str, Iterable[str], None] = None,
        include: Union[str, Iterable[str], None] = None,
        query_params: Optional[Dict[str, Any]] = None,
    ) -> IterableGCSResponse:
        """
        ``GET /collections``

        :param mapped_collection_id: Filter collections which were created using this
            mapped collection ID.
        :type mapped_collection_id: str or UUID
        :param filter: Filter the returned set to any combination of the following:
            ``mapped_collections``, ``guest_collections``, ``managed_by_me``,
            ``created_by_me``.
        :type filter: str or iterable of str, optional
        :param include: Names of additional documents to include in the response
        :type include: str or iterable of str, optional
        :param query_params: Additional passthrough query parameters
        :type query_params: dict, optional

        List the Collections on an Endpoint
        """
        if query_params is None:
            query_params = {}
        if include is not None:
            query_params["include"] = ",".join(utils.safe_strseq_iter(include))
        if mapped_collection_id is not None:
            query_params["mapped_collection_id"] = mapped_collection_id
        if filter is not None:
            if isinstance(filter, str):
                filter = [filter]
            query_params["filter"] = ",".join(filter)
        return IterableGCSResponse(
            self.get("collections", query_params=query_params))
Пример #14
0
    def get_storage_gateway_list(
        self,
        *,
        include: Union[None, str, Iterable[str]] = None,
        query_params: Optional[Dict[str, Any]] = None,
    ) -> IterableGCSResponse:
        """
        ``GET /storage_gateways``

        :param include: Optional document types to include in the response. If
            'private_policies' is included, then include private storage gateway
            policies in the attached storage_gateways document. This requires an
            ``administrator`` role on the Endpoint.
        :type include: str or iterable of str, optional
        :param query_params: Additional passthrough query parameters
        :type query_params: dict, optional
        """
        if query_params is None:
            query_params = {}
        if include is not None:
            query_params["include"] = ",".join(utils.safe_strseq_iter(include))
        return IterableGCSResponse(
            self.get("/storage_gateways", query_params=query_params))
Пример #15
0
    def get_group(
        self,
        group_id: UUIDLike,
        *,
        include: Union[None, str, Iterable[str]] = None,
        query_params: Optional[Dict[str, Any]] = None,
    ) -> response.GlobusHTTPResponse:
        """
        Get details about a specific group

        :param group_id: the ID of the group
        :type group_id: str or UUID
        :param include: list of additional fields to include (allowed fields are
            ``memberships``, ``my_memberships``, ``policies``, ``allowed_actions``, and
            ``child_ids``)
        :type include: str or iterable of str, optional
        :param query_params: additional passthrough query parameters
        :type query_params: dict, optional
        """
        if query_params is None:
            query_params = {}
        if include is not None:
            query_params["include"] = ",".join(utils.safe_strseq_iter(include))
        return self.get(f"/groups/{group_id}", query_params=query_params)