RLMSyncPermissionOffer.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import <Foundation/Foundation.h>
  19. #import <Realm/RLMObject.h>
  20. #import <Realm/RLMProperty.h>
  21. #import <Realm/RLMSyncUtil.h>
  22. NS_ASSUME_NONNULL_BEGIN
  23. /**
  24. This model is used for offering permission changes to other users.
  25. It should be used in conjunction with an `RLMSyncUser`'s Management Realm.
  26. See https://realm.io/docs/realm-object-server/#permissions for general
  27. documentation.
  28. */
  29. @interface RLMSyncPermissionOffer : RLMObject
  30. /// The globally unique ID string of this permission offer object.
  31. @property (readonly) NSString *id;
  32. /// The date this object was initially created.
  33. @property (readonly) NSDate *createdAt;
  34. /// The date this object was last modified.
  35. @property (readonly) NSDate *updatedAt;
  36. /// The status code of the object that was processed by Realm Object Server.
  37. @property (nullable, readonly) NSNumber<RLMInt> *statusCode;
  38. /// An error or informational message, typically written to by the Realm Object Server.
  39. @property (nullable, readonly) NSString *statusMessage;
  40. /// Sync management object status.
  41. @property (readonly) RLMSyncManagementObjectStatus status;
  42. /// A token which uniquely identifies this offer. Generated by the server.
  43. @property (nullable, readonly) NSString *token;
  44. /// The remote URL to the realm.
  45. @property (readonly) NSString *realmUrl;
  46. /// Whether this offer allows the receiver to read from the Realm.
  47. @property (readonly) BOOL mayRead;
  48. /// Whether this offer allows the receiver to write to the Realm.
  49. @property (readonly) BOOL mayWrite;
  50. /// Whether this offer allows the receiver to manage the access rights for others.
  51. @property (readonly) BOOL mayManage;
  52. /// When this token will expire and become invalid.
  53. @property (nullable, readonly) NSDate *expiresAt;
  54. /**
  55. Construct a permission offer object used to offer permission changes to other users.
  56. @param realmURL The URL to the Realm on which to apply these permission changes
  57. to, once the offer is accepted.
  58. @param expiresAt When this token will expire and become invalid.
  59. Pass `nil` if this offer should not expire.
  60. @param mayRead Grant or revoke read access.
  61. @param mayWrite Grant or revoked read-write access.
  62. @param mayManage Grant or revoke administrative access.
  63. */
  64. + (instancetype)permissionOfferWithRealmURL:(NSString *)realmURL
  65. expiresAt:(nullable NSDate *)expiresAt
  66. read:(BOOL)mayRead
  67. write:(BOOL)mayWrite
  68. manage:(BOOL)mayManage;
  69. @end
  70. NS_ASSUME_NONNULL_END