{"__v":8,"_id":"56a0bda13697d80d002ac60c","category":{"__v":3,"_id":"56a0bd9f3697d80d002ac5e9","pages":["56a0bda13697d80d002ac5ff","56a0bda13697d80d002ac600","56a0bda13697d80d002ac601","56a0bda13697d80d002ac602","56a0bda13697d80d002ac603","56a0bda13697d80d002ac604","56a0bda13697d80d002ac605","56a0bda13697d80d002ac606","56a0bda13697d80d002ac607","56a0bda13697d80d002ac608","56a0bda13697d80d002ac609","56a0bda13697d80d002ac60a","56a0bda13697d80d002ac60b","56a0bda13697d80d002ac60c","56a0bda13697d80d002ac60d","56a0bda13697d80d002ac60e","56a0bda13697d80d002ac60f","56a0bda13697d80d002ac610","56a0bda13697d80d002ac611","56a0bda13697d80d002ac612","56a0bda13697d80d002ac613","56a0bda13697d80d002ac614","56a5d7f7d222d20d00500d91","56a8c90fc48ee00d0092e1d1"],"project":"54774d9af3736008009e9e0e","version":"56a0bd9e3697d80d002ac5e7","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-05T14:34:09.364Z","from_sync":false,"order":17,"slug":"developer-manual","title":"Advanced Topics"},"parentDoc":null,"project":"54774d9af3736008009e9e0e","user":"54774c47f3736008009e9e0c","version":{"__v":20,"_id":"56a0bd9e3697d80d002ac5e7","project":"54774d9af3736008009e9e0e","createdAt":"2016-01-21T11:14:38.131Z","releaseDate":"2016-01-21T11:14:38.131Z","categories":["56a0bd9f3697d80d002ac5e8","56a0bd9f3697d80d002ac5e9","56a0bd9f3697d80d002ac5ea","56a0bd9f3697d80d002ac5eb","56b098a43a5b810d00745e3f","56b098da8f7a4f0d0029dd10","56d5a8ecf612b80b00fb69cd","570989853ab43c0e0072b2d6","571006aa10300c0e007f6133","5735a52431a73b1700887ca0","5744b0529e045c0e00b7a7a2","5744b1d0b56d431700d8a4fb","5744b1fb55d65a0e00b436e1","5744b218f9c7411700ce560e","5744b220f9c7411700ce560f","5744b2259e045c0e00b7a7a7","5744b22cf8b79f0e00de6a2d","5744b23155d65a0e00b436e4","5744b242c758290e00fbc235","5744b2569e045c0e00b7a7a8","5756a3f2bb92962900dafe3d","57ee23e81e42900e0014a42f","581c822c98676e0f00d240ef"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Sockets","version_clean":"1.1.0","version":"1.1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-29T14:43:01.972Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"Chapter sections:\n1. [Groups overview](#groups-overview)\n2. [Creating a Group](#creating-a-group)\n3. [Adding Users to a Group](#adding-users-to-a-group)\n4. [Creating objects with Group permissions](#creating-objects-with-group-permissions)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Groups overview\"\n}\n[/block]\nGroups on Syncano are tightly coupled with permissions. They can be used to construct different levels of access to resources stored on the platform. After you create a group, you can add users to this group. Later on, during Data Object creation, you can decide which group of users will have access to it. We will discuss this in details in the sections below.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Limits\",\n  \"body\": \"Maximum number of Groups user can belong to is `32`\"\n}\n[/block]\nThis is how a Group object looks like when stored on Syncano:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"id\\\": 1, \\n    \\\"label\\\": \\\"group_label\\\",\\n    \\\"description\\\": \\\"group description\\\"\\n    \\\"links\\\": {\\n        \\\"self\\\": \\\"/v1.1/instances/INSTANCE/groups/1/\\\", \\n        \\\"users\\\": \\\"/v1.1/instances/INSTANCE/groups/1/users/\\\"\\n    }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nIt has two properties:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Property\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`id`\",\n    \"0-1\": \"Group identifier.\",\n    \"1-0\": \"`label`\",\n    \"1-1\": \"Group label.\",\n    \"2-0\": \"`description`\",\n    \"2-1\": \"Group description.\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\nList of currently existing Groups can be found in the left column of `Users & Groups` view in the [Dashboard](https://dashboard.syncano.io).\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/R5f5bVphTKyfvlEzif3a_Groups_01.png\",\n        \"Groups_01.png\",\n        \"1679\",\n        \"771\",\n        \"#254473\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nSo the Group object is pretty simple. Let's learn how to create Groups.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Creating a Group\"\n}\n[/block]\nThis is how you can create Groups on Syncano. The only parameter you'll have to pass here is a group label (name):\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/5UKBiVHTQ8aGXJKpVNcO_Add_group_01.png\",\n        \"Add_group_01.png\",\n        \"1679\",\n        \"736\",\n        \"#244371\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/LNuhyKnsR6eUt3qjREx7_Add_group_02.png\",\n        \"Add_group_02.png\",\n        \"1679\",\n        \"763\",\n        \"#244474\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X POST \\\\\\n-H \\\"Content-type: application/json\\\" \\\\\\n-H \\\"X-API-KEY: ACCOUNT_KEY\\\" \\\\\\n-d '{\\\"label\\\":\\\"my_group_label\\\"}' \\\\\\n\\\"https://api.syncano.io/v1.1/instances/instance/groups/\\\"\",\n      \"language\": \"curl\"\n    },\n    {\n      \"code\": \"from syncano.models import Group\\nimport syncano\\n\\nsyncano.connect(api_key=\\\"ACCOUNT_KEY\\\")\\n\\nGroup.please.create(\\n    instance_name=\\\"INSTANCE_NAME\\\",\\n    label=\\\"my new group\\\"\\n)\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"var Syncano = require(\\\"syncano\\\");  // CommonJS\\nvar connection = Syncano({accountKey: \\\"ACCOUNT_KEY\\\"});\\nvar Group = connection.Group;\\n\\nvar options = {\\n  label: \\\"GROUP_LABEL\\\", \\n  description: \\\"GROUP_DESCRIPTION\\\",\\n  instanceName: \\\"INSTANCE_NAME\\\"\\n};\\n\\nGroup.please().create(options).then(callback);\",\n      \"language\": \"javascript\"\n    },\n    {\n      \"code\": \"// Coming soon!\",\n      \"language\": \"javascript\",\n      \"name\": \"Node.js\"\n    },\n    {\n      \"code\": \"Group newGroup = new Group(\\\"group_label\\\");\\nResponse<Group> response = syncano.createGroup(newGroup).send();\",\n      \"language\": \"java\",\n      \"name\": \"Android\"\n    },\n    {\n      \"code\": \"// Not supported in iOS Library - please use Dashboard instead\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"// Not supported in iOS Library - please use Dashboard instead\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    },\n    {\n      \"code\": \"# Coming soon!\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Adding Users to a Group\"\n}\n[/block]\nNow, when we have a group created, we can start adding the users there. \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"This example assumes that there are existing users on your Instance. If you'd like to know how to add users to your application, go [here](user-management).\"\n}\n[/block]\nClick 'more' icon on chosen user.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/yX0FX1OxQamhvaeJHakd_Add_group_to_user_01.png\",\n        \"Add_group_to_user_01.png\",\n        \"1679\",\n        \"771\",\n        \"#254472\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nClick 'Edit a User' option.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/1DoQm37eQZ2lQhGgI8h2_Add_group_to_user_02.png\",\n        \"Add_group_to_user_02.png\",\n        \"1679\",\n        \"771\",\n        \"#254473\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nOn the `Edit` pop-up, select a Group from the drop-down menu.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Wy7M4okRiiY45BUJUk9Q_Add_group_to_user_03.png\",\n        \"Add_group_to_user_03.png\",\n        \"1679\",\n        \"768\",\n        \"#6c84a4\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nSelected Group will show up in the `Edit` window. Click `Confirm` to save changes.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/HXvh8rISwmKIMCXAvZ7z_Add_group_to_user_04.png\",\n        \"Add_group_to_user_04.png\",\n        \"1679\",\n        \"771\",\n        \"#2a3e5b\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nYou will also see Groups user belongs to, on the users list.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/l9qdjxVTkCaziaLdyqMy_Add_group_to_user_05.png\",\n        \"Add_group_to_user_05.png\",\n        \"1622\",\n        \"842\",\n        \"#254573\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nCall to add a group to a user can look like this:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X POST \\\\\\n-H \\\"Content-type: application/json\\\" \\\\\\n-H \\\"X-API-KEY: ACCOUNT_KEY\\\" \\\\\\n-d '{\\\"user\\\": user_id}' \\\\\\n\\\"https://api.syncano.io/v1.1/instances/instance/groups/group_id/users/\\\"\",\n      \"language\": \"curl\"\n    },\n    {\n      \"code\": \"from syncano.models import User\\nimport syncano\\n\\nsyncano.connect(api_key=\\\"API_KEY_WITH_ALLOW_USER_CREATE_FLAG\\\") \\n\\nGordon = User.please.create(\\n    instance_name=\\\"INSTANCE_NAME\\\",\\n    username=\\\"Gordon Freeman\\\",\\n    password=\\\"Black Mesa\\\"\\n)\\n\\ngroup = Group.objects.get(id=1)\\nGordon.add_to_group(group_id=group.id)\\n\\n# or:\\n\\ngroup.add_user(user_id=Gordon.id)\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"// Planned for v.1.1.0\",\n      \"language\": \"javascript\"\n    },\n    {\n      \"code\": \"// Coming soon!\",\n      \"language\": \"javascript\",\n      \"name\": \"Node.js\"\n    },\n    {\n      \"code\": \"Response<GroupMembership> response = syncano.addUserToGroup(group.getId(), user.getId()).send();\",\n      \"language\": \"java\",\n      \"name\": \"Android\"\n    },\n    {\n      \"code\": \"// Not supported in iOS Library - please use Dashboard instead\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"// Not supported in iOS Library - please use Dashboard instead\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    },\n    {\n      \"code\": \"# Coming soon!\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Creating objects with Group permissions\"\n}\n[/block]\nWhen creating objects, there's an option to set Group permissions:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/neNmeXtLRoihGa8Cfpt7_Add_object_with_group_permissions_01.png\",\n        \"Add_object_with_group_permissions_01.png\",\n        \"1679\",\n        \"872\",\n        \"#264472\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/HEB9BsnbQOiNazcPF1ZI_Add_object_with_group_permissions_v1.png\",\n        \"Add_object_with_group_permissions_v1.png\",\n        \"1678\",\n        \"772\",\n        \"#546c94\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X POST \\\\\\n-H \\\"Content-type: application/json\\\" \\\\\\n-H \\\"X-API-KEY: API_KEY\\\" \\\\\\n-d '{\\\"group\\\": 1, \\\"group_permissions\\\": \\\"full\\\"}' \\\\\\n\\\"https://api.syncano.io/v1.1/instances/instance/classes/class/objects/\\\"\",\n      \"language\": \"curl\"\n    },\n    {\n      \"code\": \"from syncano.models import Object\\nimport syncano\\n\\nsyncano.connect(api_key=\\\"API_KEY\\\")\\n\\nObject.please.create(\\n    instance_name=\\\"INSTANCE_NAME\\\",\\n    class_name=\\\"CLASS_NAME\\\",\\n    group=1,\\n    group_permissions=\\\"full\\\"\\n)\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"var Syncano = require(\\\"syncano\\\");  // CommonJS\\nvar connection = Syncano({accountKey: \\\"ACCOUNT_KEY\\\"});\\nvar DataObject = connection.DataObject;\\n\\nvar book = {\\n  title: 'Book Title',\\n  group: 1, \\n  group_permissions: \\\"full\\\",\\n  instanceName: \\\"INSTANCE_NAME\\\",\\n  className: \\\"CLASS_NAME\\\"\\n};\\n\\nDataObject.please().create(book).then(callback);\",\n      \"language\": \"javascript\"\n    },\n    {\n      \"code\": \"Book book = new Book();\\nbook.title = \\\"Title\\\";\\nbook.setGroup(group.getId());\\nbook.setGroupPermisions(DataObjectPermissions.FULL);\\n\\nResponse<Book> response = book.save();\",\n      \"language\": \"java\",\n      \"name\": \"Android\"\n    },\n    {\n      \"code\": \"// Coming soon!\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"// Coming soon!\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    },\n    {\n      \"code\": \"# Coming soon!\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\nNow, users from the group with an id = `1` will have full access to this Data Object.\n\nThese are the possible permissions that users can have:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Roll\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`full`\",\n    \"1-0\": \"`write`\",\n    \"2-0\": \"`read`\",\n    \"1-1\": \"Read/write access to the object.\",\n    \"2-1\": \"Permission to access the object in read-only mode.\",\n    \"0-1\": \"Read/write/delete access to the object.\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\nThe example above showed how to create a Data Object with group permissions but these permissions can be set on various resources. Here's a list of objects that have 'group_permissions` property:\n* Data Class\n* Data Object\n* User\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"For more details about the available methods for groups, visit the [Groups API reference](http://docs.syncano.com/v0.1.1/docs/groups-list).\",\n  \"title\": \"Learn More\"\n}\n[/block]","excerpt":"In this chapter you'll learn how to:\n* Create groups\n* Add users to a group\n* Add objects with group permissions\n* Learn groups usage with examples","slug":"groups","type":"basic","title":"Groups"}

Groups

In this chapter you'll learn how to: * Create groups * Add users to a group * Add objects with group permissions * Learn groups usage with examples

Chapter sections: 1. [Groups overview](#groups-overview) 2. [Creating a Group](#creating-a-group) 3. [Adding Users to a Group](#adding-users-to-a-group) 4. [Creating objects with Group permissions](#creating-objects-with-group-permissions) [block:api-header] { "type": "basic", "title": "Groups overview" } [/block] Groups on Syncano are tightly coupled with permissions. They can be used to construct different levels of access to resources stored on the platform. After you create a group, you can add users to this group. Later on, during Data Object creation, you can decide which group of users will have access to it. We will discuss this in details in the sections below. [block:callout] { "type": "info", "title": "Limits", "body": "Maximum number of Groups user can belong to is `32`" } [/block] This is how a Group object looks like when stored on Syncano: [block:code] { "codes": [ { "code": "{\n \"id\": 1, \n \"label\": \"group_label\",\n \"description\": \"group description\"\n \"links\": {\n \"self\": \"/v1.1/instances/INSTANCE/groups/1/\", \n \"users\": \"/v1.1/instances/INSTANCE/groups/1/users/\"\n }\n}", "language": "json" } ] } [/block] It has two properties: [block:parameters] { "data": { "h-0": "Property", "h-1": "Description", "0-0": "`id`", "0-1": "Group identifier.", "1-0": "`label`", "1-1": "Group label.", "2-0": "`description`", "2-1": "Group description." }, "cols": 2, "rows": 3 } [/block] List of currently existing Groups can be found in the left column of `Users & Groups` view in the [Dashboard](https://dashboard.syncano.io). [block:image] { "images": [ { "image": [ "https://files.readme.io/R5f5bVphTKyfvlEzif3a_Groups_01.png", "Groups_01.png", "1679", "771", "#254473", "" ] } ] } [/block] So the Group object is pretty simple. Let's learn how to create Groups. [block:api-header] { "type": "basic", "title": "Creating a Group" } [/block] This is how you can create Groups on Syncano. The only parameter you'll have to pass here is a group label (name): [block:image] { "images": [ { "image": [ "https://files.readme.io/5UKBiVHTQ8aGXJKpVNcO_Add_group_01.png", "Add_group_01.png", "1679", "736", "#244371", "" ] } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/LNuhyKnsR6eUt3qjREx7_Add_group_02.png", "Add_group_02.png", "1679", "763", "#244474", "" ] } ] } [/block] [block:code] { "codes": [ { "code": "curl -X POST \\\n-H \"Content-type: application/json\" \\\n-H \"X-API-KEY: ACCOUNT_KEY\" \\\n-d '{\"label\":\"my_group_label\"}' \\\n\"https://api.syncano.io/v1.1/instances/instance/groups/\"", "language": "curl" }, { "code": "from syncano.models import Group\nimport syncano\n\nsyncano.connect(api_key=\"ACCOUNT_KEY\")\n\nGroup.please.create(\n instance_name=\"INSTANCE_NAME\",\n label=\"my new group\"\n)", "language": "python" }, { "code": "var Syncano = require(\"syncano\"); // CommonJS\nvar connection = Syncano({accountKey: \"ACCOUNT_KEY\"});\nvar Group = connection.Group;\n\nvar options = {\n label: \"GROUP_LABEL\", \n description: \"GROUP_DESCRIPTION\",\n instanceName: \"INSTANCE_NAME\"\n};\n\nGroup.please().create(options).then(callback);", "language": "javascript" }, { "code": "// Coming soon!", "language": "javascript", "name": "Node.js" }, { "code": "Group newGroup = new Group(\"group_label\");\nResponse<Group> response = syncano.createGroup(newGroup).send();", "language": "java", "name": "Android" }, { "code": "// Not supported in iOS Library - please use Dashboard instead", "language": "objectivec" }, { "code": "// Not supported in iOS Library - please use Dashboard instead", "language": "objectivec", "name": "Swift" }, { "code": "# Coming soon!", "language": "ruby" } ] } [/block] [block:api-header] { "type": "basic", "title": "Adding Users to a Group" } [/block] Now, when we have a group created, we can start adding the users there. [block:callout] { "type": "info", "body": "This example assumes that there are existing users on your Instance. If you'd like to know how to add users to your application, go [here](user-management)." } [/block] Click 'more' icon on chosen user. [block:image] { "images": [ { "image": [ "https://files.readme.io/yX0FX1OxQamhvaeJHakd_Add_group_to_user_01.png", "Add_group_to_user_01.png", "1679", "771", "#254472", "" ] } ] } [/block] Click 'Edit a User' option. [block:image] { "images": [ { "image": [ "https://files.readme.io/1DoQm37eQZ2lQhGgI8h2_Add_group_to_user_02.png", "Add_group_to_user_02.png", "1679", "771", "#254473", "" ] } ] } [/block] On the `Edit` pop-up, select a Group from the drop-down menu. [block:image] { "images": [ { "image": [ "https://files.readme.io/Wy7M4okRiiY45BUJUk9Q_Add_group_to_user_03.png", "Add_group_to_user_03.png", "1679", "768", "#6c84a4", "" ] } ] } [/block] Selected Group will show up in the `Edit` window. Click `Confirm` to save changes. [block:image] { "images": [ { "image": [ "https://files.readme.io/HXvh8rISwmKIMCXAvZ7z_Add_group_to_user_04.png", "Add_group_to_user_04.png", "1679", "771", "#2a3e5b", "" ] } ] } [/block] You will also see Groups user belongs to, on the users list. [block:image] { "images": [ { "image": [ "https://files.readme.io/l9qdjxVTkCaziaLdyqMy_Add_group_to_user_05.png", "Add_group_to_user_05.png", "1622", "842", "#254573", "" ] } ] } [/block] Call to add a group to a user can look like this: [block:code] { "codes": [ { "code": "curl -X POST \\\n-H \"Content-type: application/json\" \\\n-H \"X-API-KEY: ACCOUNT_KEY\" \\\n-d '{\"user\": user_id}' \\\n\"https://api.syncano.io/v1.1/instances/instance/groups/group_id/users/\"", "language": "curl" }, { "code": "from syncano.models import User\nimport syncano\n\nsyncano.connect(api_key=\"API_KEY_WITH_ALLOW_USER_CREATE_FLAG\") \n\nGordon = User.please.create(\n instance_name=\"INSTANCE_NAME\",\n username=\"Gordon Freeman\",\n password=\"Black Mesa\"\n)\n\ngroup = Group.objects.get(id=1)\nGordon.add_to_group(group_id=group.id)\n\n# or:\n\ngroup.add_user(user_id=Gordon.id)", "language": "python" }, { "code": "// Planned for v.1.1.0", "language": "javascript" }, { "code": "// Coming soon!", "language": "javascript", "name": "Node.js" }, { "code": "Response<GroupMembership> response = syncano.addUserToGroup(group.getId(), user.getId()).send();", "language": "java", "name": "Android" }, { "code": "// Not supported in iOS Library - please use Dashboard instead", "language": "objectivec" }, { "code": "// Not supported in iOS Library - please use Dashboard instead", "language": "objectivec", "name": "Swift" }, { "code": "# Coming soon!", "language": "ruby" } ] } [/block] [block:api-header] { "type": "basic", "title": "Creating objects with Group permissions" } [/block] When creating objects, there's an option to set Group permissions: [block:image] { "images": [ { "image": [ "https://files.readme.io/neNmeXtLRoihGa8Cfpt7_Add_object_with_group_permissions_01.png", "Add_object_with_group_permissions_01.png", "1679", "872", "#264472", "" ] } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/HEB9BsnbQOiNazcPF1ZI_Add_object_with_group_permissions_v1.png", "Add_object_with_group_permissions_v1.png", "1678", "772", "#546c94", "" ] } ] } [/block] [block:code] { "codes": [ { "code": "curl -X POST \\\n-H \"Content-type: application/json\" \\\n-H \"X-API-KEY: API_KEY\" \\\n-d '{\"group\": 1, \"group_permissions\": \"full\"}' \\\n\"https://api.syncano.io/v1.1/instances/instance/classes/class/objects/\"", "language": "curl" }, { "code": "from syncano.models import Object\nimport syncano\n\nsyncano.connect(api_key=\"API_KEY\")\n\nObject.please.create(\n instance_name=\"INSTANCE_NAME\",\n class_name=\"CLASS_NAME\",\n group=1,\n group_permissions=\"full\"\n)", "language": "python" }, { "code": "var Syncano = require(\"syncano\"); // CommonJS\nvar connection = Syncano({accountKey: \"ACCOUNT_KEY\"});\nvar DataObject = connection.DataObject;\n\nvar book = {\n title: 'Book Title',\n group: 1, \n group_permissions: \"full\",\n instanceName: \"INSTANCE_NAME\",\n className: \"CLASS_NAME\"\n};\n\nDataObject.please().create(book).then(callback);", "language": "javascript" }, { "code": "Book book = new Book();\nbook.title = \"Title\";\nbook.setGroup(group.getId());\nbook.setGroupPermisions(DataObjectPermissions.FULL);\n\nResponse<Book> response = book.save();", "language": "java", "name": "Android" }, { "code": "// Coming soon!", "language": "objectivec" }, { "code": "// Coming soon!", "language": "objectivec", "name": "Swift" }, { "code": "# Coming soon!", "language": "ruby" } ] } [/block] Now, users from the group with an id = `1` will have full access to this Data Object. These are the possible permissions that users can have: [block:parameters] { "data": { "h-0": "Roll", "h-1": "Description", "0-0": "`full`", "1-0": "`write`", "2-0": "`read`", "1-1": "Read/write access to the object.", "2-1": "Permission to access the object in read-only mode.", "0-1": "Read/write/delete access to the object." }, "cols": 2, "rows": 3 } [/block] The example above showed how to create a Data Object with group permissions but these permissions can be set on various resources. Here's a list of objects that have 'group_permissions` property: * Data Class * Data Object * User [block:callout] { "type": "info", "body": "For more details about the available methods for groups, visit the [Groups API reference](http://docs.syncano.com/v0.1.1/docs/groups-list).", "title": "Learn More" } [/block]