File indexing completed on 2024-05-12 05:22:23

0001 /*
0002     SPDX-FileCopyrightText: 2019 David Barchiesi <david@barchie.si>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kgapidrive_export.h"
0010 #include "object.h"
0011 #include "types.h"
0012 
0013 #include <QString>
0014 
0015 #include <QDateTime>
0016 
0017 namespace KGAPI2
0018 {
0019 
0020 namespace Drive
0021 {
0022 
0023 /**
0024  * @brief Teamdrive contains a representation of a Team Drive.
0025  *
0026  * Getters and setters' documentation is based on Google Drive's API v2 reference
0027  * @see <a href="https://developers.google.com/drive/v2/reference/teamdrives">Teamdrives</a>
0028  *
0029  * @since x.0
0030  * @author David Barchiesi <david@barchie.si>
0031  */
0032 class KGAPIDRIVE_EXPORT Teamdrive : public KGAPI2::Object
0033 {
0034 public:
0035     /**
0036      * @brief DriveTeamdrive::Restrictions holds the structure used for
0037      * restrictions property.
0038      */
0039     class Restrictions
0040     {
0041     public:
0042         struct Fields {
0043             static const QString AdminManagedRestrictions;
0044             static const QString CopyRequiresWriterPermission;
0045             static const QString DomainUsersOnly;
0046             static const QString TeamMembersOnly;
0047         };
0048 
0049         Restrictions();
0050         Restrictions(const Restrictions &other);
0051         ~Restrictions();
0052         bool operator==(const Restrictions &other) const;
0053         bool operator!=(const Restrictions &other) const
0054         {
0055             return !operator==(other);
0056         }
0057 
0058         /**
0059          * @brief Returns whether administrative privileges on this Team Drive
0060          * are required to modify restrictions.
0061          */
0062         bool adminManagedRestrictions() const;
0063 
0064         /**
0065          * @brief Sets whether administrative privileges on this Team Drive
0066          * are required to modify restrictions.
0067          *
0068          * @param adminManagedRestrictions
0069          */
0070         void setAdminManagedRestrictions(bool adminManagedRestrictions) const;
0071 
0072         /**
0073          * @brief Returns whether the options to copy, print, or download files
0074          * inside this Team Drive, should be disabled for readers and commenters.
0075          * When this restriction is set to true, it will override the similarly
0076          * named field to true for any file inside this Team Drive.
0077          */
0078         [[nodiscard]] bool copyRequiresWriterPermission() const;
0079 
0080         /**
0081          * @brief Sets whether the options to copy, print, or download files
0082          * inside this Team Drive, should be disabled for readers and commenters.
0083          * When this restriction is set to true, it will override the similarly
0084          * named field to true for any file inside this Team Drive.
0085          *
0086          * @param copyRequiresWriterPermission
0087          */
0088         void setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const;
0089 
0090         /**
0091          * @brief Returns whether access to this Team Drive and items inside this
0092          * Team Drive is restricted to users of the domain to which this Team
0093          * Drive belongs. This restriction may be overridden by other sharing
0094          * policies controlled outside of this Team Drive.
0095          */
0096         [[nodiscard]] bool domainUsersOnly() const;
0097 
0098         /**
0099          * @brief Sets whether access to this Team Drive and items inside this
0100          * Team Drive is restricted to users of the domain to which this Team
0101          * Drive belongs. This restriction may be overridden by other sharing
0102          * policies controlled outside of this Team Drive.
0103          *
0104          * @param domainUsersOnly
0105          */
0106         void setDomainUsersOnly(bool domainUsersOnly) const;
0107 
0108         /**
0109          * @brief Returns whether access to items inside this Team Drive is
0110          * restricted to members of this Team Drive.
0111          */
0112         [[nodiscard]] bool teamMembersOnly() const;
0113 
0114         /**
0115          * @brief Sets whether access to items inside this Team Drive is
0116          * restricted to members of this Team Drive.
0117          *
0118          * @param teamMembersOnly
0119          */
0120         void setTeamMembersOnly(bool teamMembersOnly) const;
0121 
0122     private:
0123         class Private;
0124         QScopedPointer<Private> const d;
0125         friend class Private;
0126         friend class Teamdrive;
0127     };
0128 
0129     using RestrictionsPtr = QSharedPointer<Restrictions>;
0130 
0131     /**
0132      * @brief DriveTeamdrive::Capabilities holds the structure used for capabilities property.
0133      */
0134     class Capabilities
0135     {
0136     public:
0137         struct Fields {
0138             static const QString CanAddChildren;
0139             static const QString CanChangeCopyRequiresWriterPermissionRestriction;
0140             static const QString CanChangeDomainUsersOnlyRestriction;
0141             static const QString CanChangeTeamDriveBackground;
0142             static const QString CanChangeTeamMembersOnlyRestriction;
0143             static const QString CanComment;
0144             static const QString CanCopy;
0145             static const QString CanDeleteChildren;
0146             static const QString CanDeleteTeamDrive;
0147             static const QString CanDownload;
0148             static const QString CanEdit;
0149             static const QString CanListChildren;
0150             static const QString CanManageMembers;
0151             static const QString CanReadRevisions;
0152             static const QString CanRename;
0153             static const QString CanRenameTeamDrive;
0154             static const QString CanShare;
0155             static const QString CanTrashChildren;
0156         };
0157 
0158         Capabilities();
0159         Capabilities(const Capabilities &other);
0160         ~Capabilities();
0161         bool operator==(const Capabilities &other) const;
0162         bool operator!=(const Capabilities &other) const
0163         {
0164             return !operator==(other);
0165         }
0166 
0167         /**
0168          * @brief Returns whether the current user can add children to folders
0169          * in this Team Drive.
0170          */
0171         [[nodiscard]] bool canAddChildren() const;
0172 
0173         /**
0174          * @brief Returns whether the current user can change the
0175          * copyRequiresWriterPermission restriction of this Team Drive.
0176          */
0177         [[nodiscard]] bool canChangeCopyRequiresWriterPermissionRestriction() const;
0178 
0179         /**
0180          * @brief Returns whether the current user can change the domainUsersOnly
0181          * restriction of this Team Drive.
0182          */
0183         [[nodiscard]] bool canChangeDomainUsersOnlyRestriction() const;
0184 
0185         /**
0186          * @brief Returns whether the current user can change the background of
0187          * this Team Drive.
0188          */
0189         [[nodiscard]] bool canChangeTeamDriveBackground() const;
0190 
0191         /**
0192          * @brief Returns whether the current user can change the teamMembersOnly
0193          * restriction of this Team Drive.
0194          */
0195         [[nodiscard]] bool canChangeTeamMembersOnlyRestriction() const;
0196 
0197         /**
0198          * @brief Returns Whether the current user can comment on files in
0199          * this Team Drive.
0200          */
0201         [[nodiscard]] bool canComment() const;
0202 
0203         /**
0204          * @brief Returns Whether the current user can copy files in this Team Drive.
0205          */
0206         [[nodiscard]] bool canCopy() const;
0207 
0208         /**
0209          * @brief Returns Whether the current user can delete children from
0210          * folders in this Team Drive.
0211          */
0212         [[nodiscard]] bool canDeleteChildren() const;
0213 
0214         /**
0215          * @brief Returns Whether the current user can delete this Team Drive.
0216          *
0217          * Attempting to delete the Team Drive may still fail if there are
0218          * untrashed items inside the Team Drive.
0219          */
0220         [[nodiscard]] bool canDeleteTeamDrive() const;
0221 
0222         /**
0223          * @brief Returns Whether the current user can download files in this
0224          * Team Drive.
0225          */
0226         [[nodiscard]] bool canDownload() const;
0227 
0228         /**
0229          * @brief Returns Whether the current user can edit files in this
0230          * Team Drive
0231          */
0232         [[nodiscard]] bool canEdit() const;
0233 
0234         /**
0235          * @brief Returns Whether the current user can list the children of
0236          * folders in this Team Drive.
0237          */
0238         [[nodiscard]] bool canListChildren() const;
0239 
0240         /**
0241          * @brief Returns Whether the current user can add members to this Team Drive
0242          * or remove them or change their role.
0243          */
0244         [[nodiscard]] bool canManageMembers() const;
0245 
0246         /**
0247          * @brief Returns Whether the current user can read the revisions
0248          * resource of files in this Team Drive.
0249          */
0250         [[nodiscard]] bool canReadRevisions() const;
0251 
0252         /**
0253          * @brief Returns Whether the current user can rename files or folders
0254          * in this Team Drive.
0255          */
0256         [[nodiscard]] bool canRename() const;
0257 
0258         /**
0259          * @brief Returns Whether the current user can rename this Team Drive.
0260          */
0261         [[nodiscard]] bool canRenameTeamDrive() const;
0262 
0263         /**
0264          * @brief Returns Whether the current user can share files or folders
0265          * in this Team Drive.
0266          */
0267         [[nodiscard]] bool canShare() const;
0268 
0269         /**
0270          * @brief Returns Whether the current user can trash children from
0271          * folders in this Team Drive.
0272          */
0273         [[nodiscard]] bool canTrashChildren() const;
0274 
0275     private:
0276         class Private;
0277         QScopedPointer<Private> const d;
0278         friend class Private;
0279         friend class Teamdrive;
0280     };
0281 
0282     using CapabilitiesPtr = QSharedPointer<Capabilities>;
0283 
0284     /**
0285      * @brief DriveTeamdrive::BackgroundImageFile holds the structure used
0286      * for backgroundImageFile property.
0287      */
0288     class BackgroundImageFile
0289     {
0290     public:
0291         struct Fields {
0292             static const QString Id;
0293             static const QString XCoordinate;
0294             static const QString YCoordinate;
0295             static const QString Width;
0296         };
0297 
0298         BackgroundImageFile();
0299         BackgroundImageFile(const BackgroundImageFile &other);
0300         ~BackgroundImageFile();
0301         bool operator==(const BackgroundImageFile &other) const;
0302         bool operator!=(const BackgroundImageFile &other) const
0303         {
0304             return !operator==(other);
0305         }
0306 
0307         /**
0308          * @brief Returns the id of the background image file.
0309          */
0310         [[nodiscard]] QString id() const;
0311 
0312         /**
0313          * @brief Sets the id of the background image file.
0314          *
0315          * @param id
0316          */
0317         void setId(const QString &id) const;
0318 
0319         /**
0320          * @brief Returns the x coordinate for this background image file.
0321          */
0322         [[nodiscard]] float xCoordinate() const;
0323 
0324         /**
0325          * @brief Sets the x coordinate for this background image file.
0326          *
0327          * @param xCoordinate
0328          */
0329         void setXCoordinate(float xCoordinate) const;
0330 
0331         /**
0332          * @brief Returns the y coordinate for this background image file.
0333          */
0334         [[nodiscard]] float yCoordinate() const;
0335 
0336         /**
0337          * @brief Sets the y coordinate for this background image file.
0338          *
0339          * @param yCoordinate
0340          */
0341         void setYCoordinate(float yCoordinate) const;
0342 
0343         /**
0344          * @brief Returns the width for this background image file.
0345          */
0346         [[nodiscard]] float width() const;
0347 
0348         /**
0349          * @brief Sets the width for this background image file.
0350          *
0351          * @param width
0352          */
0353         void setWidth(float width) const;
0354 
0355     private:
0356         class Private;
0357         QScopedPointer<Private> const d;
0358         friend class Private;
0359         friend class Teamdrive;
0360     };
0361 
0362     using BackgroundImageFilePtr = QSharedPointer<BackgroundImageFile>;
0363 
0364     struct Fields {
0365         static const QString Kind;
0366         static const QString Items;
0367         static const QString KindDrive;
0368         static const QString PageToken;
0369         static const QString NextPageToken;
0370         static const QString Id;
0371         static const QString Name;
0372         static const QString ThemeId;
0373         static const QString ColorRgb;
0374         static const QString BackgroundImageFile;
0375         static const QString BackgroundImageLink;
0376         static const QString Capabilities;
0377         static const QString CreatedDate;
0378         static const QString Restrictions;
0379     };
0380 
0381     Teamdrive();
0382     Teamdrive(const Teamdrive &other);
0383     ~Teamdrive() override;
0384     bool operator==(const Teamdrive &other) const;
0385     bool operator!=(const Teamdrive &other) const
0386     {
0387         return !operator==(other);
0388     }
0389 
0390     /**
0391      * @brief Returns the id of the teamdrive.
0392      */
0393     [[nodiscard]] QString id() const;
0394 
0395     /**
0396      * @brief Sets the id of the teamdrive.
0397      *
0398      * @param id
0399      */
0400     void setId(const QString &id) const;
0401 
0402     /**
0403      * @brief Returns the name of the teamdrive.
0404      */
0405     [[nodiscard]] QString name() const;
0406 
0407     /**
0408      * @brief Sets the name of the teamdrive.
0409      *
0410      * @param name
0411      */
0412     void setName(const QString &name) const;
0413 
0414     /**
0415      * @brief Returns the themeId of the teamdrive.
0416      */
0417     [[nodiscard]] QString themeId() const;
0418 
0419     /**
0420      * @brief Sets the themeId of the teamdrive.
0421      *
0422      * @param themeId
0423      */
0424     void setThemeId(const QString &themeId) const;
0425 
0426     /**
0427      * @brief Returns the colorRgb of the teamdrive.
0428      */
0429     [[nodiscard]] QString colorRgb() const;
0430 
0431     /**
0432      * @brief Sets the colorRgb of the teamdrive.
0433      *
0434      * @param colorRgb
0435      */
0436     void setColorRgb(const QString &colorRgb) const;
0437 
0438     /**
0439      * @brief Returns the image file and cropping parameters from which a background image for this Team Drive is set.
0440      */
0441     BackgroundImageFilePtr backgroundImageFile() const;
0442 
0443     /**
0444      * @brief Sets the backgroundImageFile of the teamdrive.
0445      *
0446      * @param backgroundImageFile
0447      */
0448     void setBackgroundImageFile(const BackgroundImageFilePtr &backgroundImageFile) const;
0449 
0450     /**
0451      * @brief Returns the backgroundImageLink of the teamdrive.
0452      */
0453     [[nodiscard]] QString backgroundImageLink() const;
0454 
0455     /**
0456      * @brief Returns the capabilities the current user has on this Team Drive.
0457      */
0458     CapabilitiesPtr capabilities() const;
0459 
0460     /**
0461      * @brief Returns the time at which the Team Drive was created.
0462      */
0463     [[nodiscard]] QDateTime createdDate() const;
0464 
0465     /**
0466      * @brief Returns the set of restrictions that apply to this Team Drive or
0467      * items inside this Team Drive.
0468      */
0469     RestrictionsPtr restrictions() const;
0470 
0471     /**
0472      * @brief Sets the restrictions of the teamdrive.
0473      *
0474      * @param restrictions
0475      */
0476     void setRestrictions(const RestrictionsPtr &restrictions) const;
0477 
0478     static TeamdrivePtr fromJSON(const QByteArray &jsonData);
0479     static TeamdrivesList fromJSONFeed(const QByteArray &jsonData, FeedData &feedData);
0480     static QByteArray toJSON(const TeamdrivePtr &teamdrive);
0481 
0482 private:
0483     class Private;
0484     QScopedPointer<Private> const d;
0485     friend class Private;
0486 };
0487 
0488 } /* namespace Drive */
0489 
0490 } /* namespace KGAPI2 */