Skip to content

Update attributes #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:

```groovy
implementation("io.appwrite:sdk-for-kotlin:6.0.0")
implementation("io.appwrite:sdk-for-kotlin:6.1.0")
```

### Maven
@@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-kotlin</artifactId>
<version>6.0.0</version>
<version>6.1.0</version>
</dependency>
</dependencies>
```
1 change: 1 addition & 0 deletions docs/examples/java/databases/update-boolean-attribute.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ databases.updateBooleanAttribute(
"", // key
false, // required
false, // default
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
1 change: 1 addition & 0 deletions docs/examples/java/databases/update-datetime-attribute.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ databases.updateDatetimeAttribute(
"", // key
false, // required
"", // default
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
1 change: 1 addition & 0 deletions docs/examples/java/databases/update-email-attribute.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ databases.updateEmailAttribute(
"", // key
false, // required
"email@example.com", // default
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
1 change: 1 addition & 0 deletions docs/examples/java/databases/update-enum-attribute.md
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ databases.updateEnumAttribute(
listOf(), // elements
false, // required
"<DEFAULT>", // default
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
1 change: 1 addition & 0 deletions docs/examples/java/databases/update-float-attribute.md
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ databases.updateFloatAttribute(
0, // min
0, // max
0, // default
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
1 change: 1 addition & 0 deletions docs/examples/java/databases/update-integer-attribute.md
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ databases.updateIntegerAttribute(
0, // min
0, // max
0, // default
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
1 change: 1 addition & 0 deletions docs/examples/java/databases/update-ip-attribute.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ databases.updateIpAttribute(
"", // key
false, // required
"", // default
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ databases.updateRelationshipAttribute(
"<COLLECTION_ID>", // collectionId
"", // key
RelationMutate.CASCADE, // onDelete (optional)
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
2 changes: 2 additions & 0 deletions docs/examples/java/databases/update-string-attribute.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@ databases.updateStringAttribute(
"", // key
false, // required
"<DEFAULT>", // default
0, // size (optional)
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
1 change: 1 addition & 0 deletions docs/examples/java/databases/update-url-attribute.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ databases.updateUrlAttribute(
"", // key
false, // required
"https://example.com", // default
"", // newKey (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
3 changes: 2 additions & 1 deletion docs/examples/kotlin/databases/update-boolean-attribute.md
Original file line number Diff line number Diff line change
@@ -14,5 +14,6 @@ val response = databases.updateBooleanAttribute(
collectionId = "<COLLECTION_ID>",
key = "",
required = false,
default = false
default = false,
newKey = "" // optional
)
3 changes: 2 additions & 1 deletion docs/examples/kotlin/databases/update-datetime-attribute.md
Original file line number Diff line number Diff line change
@@ -14,5 +14,6 @@ val response = databases.updateDatetimeAttribute(
collectionId = "<COLLECTION_ID>",
key = "",
required = false,
default = ""
default = "",
newKey = "" // optional
)
3 changes: 2 additions & 1 deletion docs/examples/kotlin/databases/update-email-attribute.md
Original file line number Diff line number Diff line change
@@ -14,5 +14,6 @@ val response = databases.updateEmailAttribute(
collectionId = "<COLLECTION_ID>",
key = "",
required = false,
default = "email@example.com"
default = "email@example.com",
newKey = "" // optional
)
3 changes: 2 additions & 1 deletion docs/examples/kotlin/databases/update-enum-attribute.md
Original file line number Diff line number Diff line change
@@ -15,5 +15,6 @@ val response = databases.updateEnumAttribute(
key = "",
elements = listOf(),
required = false,
default = "<DEFAULT>"
default = "<DEFAULT>",
newKey = "" // optional
)
3 changes: 2 additions & 1 deletion docs/examples/kotlin/databases/update-float-attribute.md
Original file line number Diff line number Diff line change
@@ -16,5 +16,6 @@ val response = databases.updateFloatAttribute(
required = false,
min = 0,
max = 0,
default = 0
default = 0,
newKey = "" // optional
)
3 changes: 2 additions & 1 deletion docs/examples/kotlin/databases/update-integer-attribute.md
Original file line number Diff line number Diff line change
@@ -16,5 +16,6 @@ val response = databases.updateIntegerAttribute(
required = false,
min = 0,
max = 0,
default = 0
default = 0,
newKey = "" // optional
)
3 changes: 2 additions & 1 deletion docs/examples/kotlin/databases/update-ip-attribute.md
Original file line number Diff line number Diff line change
@@ -14,5 +14,6 @@ val response = databases.updateIpAttribute(
collectionId = "<COLLECTION_ID>",
key = "",
required = false,
default = ""
default = "",
newKey = "" // optional
)
Original file line number Diff line number Diff line change
@@ -13,5 +13,6 @@ val response = databases.updateRelationshipAttribute(
databaseId = "<DATABASE_ID>",
collectionId = "<COLLECTION_ID>",
key = "",
onDelete = "cascade" // optional
onDelete = "cascade", // optional
newKey = "" // optional
)
4 changes: 3 additions & 1 deletion docs/examples/kotlin/databases/update-string-attribute.md
Original file line number Diff line number Diff line change
@@ -14,5 +14,7 @@ val response = databases.updateStringAttribute(
collectionId = "<COLLECTION_ID>",
key = "",
required = false,
default = "<DEFAULT>"
default = "<DEFAULT>",
size = 0, // optional
newKey = "" // optional
)
3 changes: 2 additions & 1 deletion docs/examples/kotlin/databases/update-url-attribute.md
Original file line number Diff line number Diff line change
@@ -14,5 +14,6 @@ val response = databases.updateUrlAttribute(
collectionId = "<COLLECTION_ID>",
key = "",
required = false,
default = "https://example.com"
default = "https://example.com",
newKey = "" // optional
)
4 changes: 2 additions & 2 deletions src/main/kotlin/io/appwrite/Client.kt
Original file line number Diff line number Diff line change
@@ -57,11 +57,11 @@ class Client @JvmOverloads constructor(
init {
headers = mutableMapOf(
"content-type" to "application/json",
"user-agent" to "AppwriteKotlinSDK/6.0.0 ${System.getProperty("http.agent")}",
"user-agent" to "AppwriteKotlinSDK/6.1.0 ${System.getProperty("http.agent")}",
"x-sdk-name" to "Kotlin",
"x-sdk-platform" to "server",
"x-sdk-language" to "kotlin",
"x-sdk-version" to "6.0.0",
"x-sdk-version" to "6.1.0",
"x-appwrite-response-format" to "1.6.0",
)

42 changes: 42 additions & 0 deletions src/main/kotlin/io/appwrite/services/Databases.kt
Original file line number Diff line number Diff line change
@@ -497,15 +497,18 @@ class Databases(client: Client) : Service(client) {
* @param key Attribute Key.
* @param required Is attribute required?
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeBoolean]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateBooleanAttribute(
databaseId: String,
collectionId: String,
key: String,
required: Boolean,
default: Boolean? = null,
newKey: String? = null,
): io.appwrite.models.AttributeBoolean {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}"
.replace("{databaseId}", databaseId)
@@ -515,6 +518,7 @@ class Databases(client: Client) : Service(client) {
val apiParams = mutableMapOf<String, Any?>(
"required" to required,
"default" to default,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -591,15 +595,18 @@ class Databases(client: Client) : Service(client) {
* @param key Attribute Key.
* @param required Is attribute required?
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeDatetime]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateDatetimeAttribute(
databaseId: String,
collectionId: String,
key: String,
required: Boolean,
default: String? = null,
newKey: String? = null,
): io.appwrite.models.AttributeDatetime {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}"
.replace("{databaseId}", databaseId)
@@ -609,6 +616,7 @@ class Databases(client: Client) : Service(client) {
val apiParams = mutableMapOf<String, Any?>(
"required" to required,
"default" to default,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -685,15 +693,18 @@ class Databases(client: Client) : Service(client) {
* @param key Attribute Key.
* @param required Is attribute required?
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeEmail]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateEmailAttribute(
databaseId: String,
collectionId: String,
key: String,
required: Boolean,
default: String? = null,
newKey: String? = null,
): io.appwrite.models.AttributeEmail {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}"
.replace("{databaseId}", databaseId)
@@ -703,6 +714,7 @@ class Databases(client: Client) : Service(client) {
val apiParams = mutableMapOf<String, Any?>(
"required" to required,
"default" to default,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -783,8 +795,10 @@ class Databases(client: Client) : Service(client) {
* @param elements Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long.
* @param required Is attribute required?
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeEnum]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateEnumAttribute(
databaseId: String,
@@ -793,6 +807,7 @@ class Databases(client: Client) : Service(client) {
elements: List<String>,
required: Boolean,
default: String? = null,
newKey: String? = null,
): io.appwrite.models.AttributeEnum {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}"
.replace("{databaseId}", databaseId)
@@ -803,6 +818,7 @@ class Databases(client: Client) : Service(client) {
"elements" to elements,
"required" to required,
"default" to default,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -887,8 +903,10 @@ class Databases(client: Client) : Service(client) {
* @param min Minimum value to enforce on new documents
* @param max Maximum value to enforce on new documents
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeFloat]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateFloatAttribute(
databaseId: String,
@@ -898,6 +916,7 @@ class Databases(client: Client) : Service(client) {
min: Double,
max: Double,
default: Double? = null,
newKey: String? = null,
): io.appwrite.models.AttributeFloat {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}"
.replace("{databaseId}", databaseId)
@@ -909,6 +928,7 @@ class Databases(client: Client) : Service(client) {
"min" to min,
"max" to max,
"default" to default,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -993,8 +1013,10 @@ class Databases(client: Client) : Service(client) {
* @param min Minimum value to enforce on new documents
* @param max Maximum value to enforce on new documents
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeInteger]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateIntegerAttribute(
databaseId: String,
@@ -1004,6 +1026,7 @@ class Databases(client: Client) : Service(client) {
min: Long,
max: Long,
default: Long? = null,
newKey: String? = null,
): io.appwrite.models.AttributeInteger {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}"
.replace("{databaseId}", databaseId)
@@ -1015,6 +1038,7 @@ class Databases(client: Client) : Service(client) {
"min" to min,
"max" to max,
"default" to default,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -1091,15 +1115,18 @@ class Databases(client: Client) : Service(client) {
* @param key Attribute Key.
* @param required Is attribute required?
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeIp]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateIpAttribute(
databaseId: String,
collectionId: String,
key: String,
required: Boolean,
default: String? = null,
newKey: String? = null,
): io.appwrite.models.AttributeIp {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}"
.replace("{databaseId}", databaseId)
@@ -1109,6 +1136,7 @@ class Databases(client: Client) : Service(client) {
val apiParams = mutableMapOf<String, Any?>(
"required" to required,
"default" to default,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -1246,15 +1274,20 @@ class Databases(client: Client) : Service(client) {
* @param key Attribute Key.
* @param required Is attribute required?
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param size Maximum size of the string attribute.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeString]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateStringAttribute(
databaseId: String,
collectionId: String,
key: String,
required: Boolean,
default: String? = null,
size: Long? = null,
newKey: String? = null,
): io.appwrite.models.AttributeString {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}"
.replace("{databaseId}", databaseId)
@@ -1264,6 +1297,8 @@ class Databases(client: Client) : Service(client) {
val apiParams = mutableMapOf<String, Any?>(
"required" to required,
"default" to default,
"size" to size,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -1340,15 +1375,18 @@ class Databases(client: Client) : Service(client) {
* @param key Attribute Key.
* @param required Is attribute required?
* @param default Default value for attribute when not provided. Cannot be set when attribute is required.
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeUrl]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updateUrlAttribute(
databaseId: String,
collectionId: String,
key: String,
required: Boolean,
default: String? = null,
newKey: String? = null,
): io.appwrite.models.AttributeUrl {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}"
.replace("{databaseId}", databaseId)
@@ -1358,6 +1396,7 @@ class Databases(client: Client) : Service(client) {
val apiParams = mutableMapOf<String, Any?>(
"required" to required,
"default" to default,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
@@ -1454,6 +1493,7 @@ class Databases(client: Client) : Service(client) {
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
* @param key Attribute Key.
* @param onDelete Constraints option
* @param newKey New attribute key.
* @return [io.appwrite.models.AttributeRelationship]
*/
@JvmOverloads
@@ -1463,6 +1503,7 @@ class Databases(client: Client) : Service(client) {
collectionId: String,
key: String,
onDelete: io.appwrite.enums.RelationMutate? = null,
newKey: String? = null,
): io.appwrite.models.AttributeRelationship {
val apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship"
.replace("{databaseId}", databaseId)
@@ -1471,6 +1512,7 @@ class Databases(client: Client) : Service(client) {

val apiParams = mutableMapOf<String, Any?>(
"onDelete" to onDelete,
"newKey" to newKey,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",