Class: Appwrite::Project

Inherits:
Service show all
Defined in:
lib/appwrite/services/project.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Project

Returns a new instance of Project.



6
7
8
# File 'lib/appwrite/services/project.rb', line 6

def initialize(client)
    @client = client
end

Instance Method Details

#create_variable(variable_id:, key:, value:, secret: nil) ⇒ Variable

Create a new project environment variable. These variables can be accessed by all functions and sites in the project.

Parameters:

  • variable_id (String)

    Variable ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • key (String)

    Variable key. Max length: 255 chars.

  • value (String)

    Variable value. Max length: 8192 chars.

  • []

    secret Secret variables can be updated or deleted, but only projects can read them during build and runtime.

Returns:

  • (Variable)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/appwrite/services/project.rb', line 45

def create_variable(variable_id:, key:, value:, secret: nil)
    api_path = '/project/variables'

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    if key.nil?
      raise Appwrite::Exception.new('Missing required parameter: "key"')
    end

    if value.nil?
      raise Appwrite::Exception.new('Missing required parameter: "value"')
    end

    api_params = {
        variableId: variable_id,
        key: key,
        value: value,
        secret: secret,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )
end

#delete_variable(variable_id:) ⇒ Object

Delete a variable by its unique ID.

Parameters:

  • variable_id (String)

    Variable ID.

Returns:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/appwrite/services/project.rb', line 148

def delete_variable(variable_id:)
    api_path = '/project/variables/{variableId}'
        .gsub('{variableId}', variable_id)

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end

#get_variable(variable_id:) ⇒ Variable

Get a variable by its unique ID.

Parameters:

  • variable_id (String)

    Variable ID.

Returns:

  • (Variable)


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/appwrite/services/project.rb', line 85

def get_variable(variable_id:)
    api_path = '/project/variables/{variableId}'
        .gsub('{variableId}', variable_id)

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    api_params = {
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )
end

#list_variables(queries: nil, total: nil) ⇒ VariableList

Get a list of all project environment variables.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (VariableList)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/appwrite/services/project.rb', line 16

def list_variables(queries: nil, total: nil)
    api_path = '/project/variables'

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::VariableList
    )
end

#update_variable(variable_id:, key: nil, value: nil, secret: nil) ⇒ Variable

Update variable by its unique ID.

Parameters:

  • variable_id (String)

    Variable ID.

  • key (String) (defaults to: nil)

    Variable key. Max length: 255 chars.

  • value (String) (defaults to: nil)

    Variable value. Max length: 8192 chars.

  • []

    secret Secret variables can be updated or deleted, but only projects can read them during build and runtime.

Returns:

  • (Variable)


116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/appwrite/services/project.rb', line 116

def update_variable(variable_id:, key: nil, value: nil, secret: nil)
    api_path = '/project/variables/{variableId}'
        .gsub('{variableId}', variable_id)

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    api_params = {
        key: key,
        value: value,
        secret: secret,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )
end