uiza_framgia_test 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +535 -0
  3. data/.rubocop_disable.yml +78 -0
  4. data/.rubocop_enable.yml +786 -0
  5. data/CHANGELOG.md +29 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/CONTRIBUTORS.txt +3 -0
  8. data/Gemfile +6 -0
  9. data/Gemfile.lock +65 -0
  10. data/History.txt +1 -0
  11. data/LICENSE.txt +21 -0
  12. data/PULL_REQUEST_TEMPLATE.md +44 -0
  13. data/README.md +181 -0
  14. data/Rakefile +6 -0
  15. data/bin/console +14 -0
  16. data/bin/setup +8 -0
  17. data/doc/ANALYTIC.md +5 -0
  18. data/doc/CALLBACK.md +4 -0
  19. data/doc/CATEGORY.md +289 -0
  20. data/doc/EMBED_METADATA.md +4 -0
  21. data/doc/ENTITY.md +486 -0
  22. data/doc/ERRORS_CODE.md +60 -0
  23. data/doc/LIVE_STREAMING.md +6 -0
  24. data/doc/STORAGE.md +195 -0
  25. data/lib/uiza.rb +42 -0
  26. data/lib/uiza/api_operation/add.rb +16 -0
  27. data/lib/uiza/api_operation/create.rb +16 -0
  28. data/lib/uiza/api_operation/delete.rb +15 -0
  29. data/lib/uiza/api_operation/list.rb +14 -0
  30. data/lib/uiza/api_operation/remove.rb +15 -0
  31. data/lib/uiza/api_operation/retrieve.rb +15 -0
  32. data/lib/uiza/api_operation/update.rb +16 -0
  33. data/lib/uiza/api_resource/category_resource.rb +33 -0
  34. data/lib/uiza/api_resource/entity_resource.rb +41 -0
  35. data/lib/uiza/api_resource/storage_resource.rb +21 -0
  36. data/lib/uiza/category.rb +44 -0
  37. data/lib/uiza/entity.rb +68 -0
  38. data/lib/uiza/error/bad_request_error.rb +8 -0
  39. data/lib/uiza/error/client_error.rb +8 -0
  40. data/lib/uiza/error/internal_server_error.rb +8 -0
  41. data/lib/uiza/error/not_found_error.rb +8 -0
  42. data/lib/uiza/error/server_error.rb +8 -0
  43. data/lib/uiza/error/service_unavailable_error.rb +8 -0
  44. data/lib/uiza/error/uiza_error.rb +18 -0
  45. data/lib/uiza/error/unauthorized_error.rb +8 -0
  46. data/lib/uiza/error/unprocessable_error.rb +8 -0
  47. data/lib/uiza/storage.rb +17 -0
  48. data/lib/uiza/uiza_client.rb +82 -0
  49. data/lib/uiza/version.rb +3 -0
  50. data/uiza.gemspec +36 -0
  51. metadata +137 -0
@@ -0,0 +1,60 @@
1
+ ## Errors Code
2
+ Uiza uses conventional HTTP response codes to indicate the success or failure of an API request.
3
+ In general: Codes in the `2xx` range indicate success.
4
+ Codes in the `4xx` range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.).
5
+ Codes in the `5xx` range indicate an error with Uiza's servers.
6
+
7
+ See details [here](https://docs.uiza.io/#errors-code).
8
+
9
+ ## HTTP status code summary
10
+ | Error Code | Detail |
11
+ | ---------------------------:|:--------------------------------------------------------------------------|
12
+ | 200 - OK | Everything worked as expected. |
13
+ | 400 - Bad Request | The request was unacceptable, often due to missing a required parameter. |
14
+ | 401 - Unauthorized | No valid API key provided. |
15
+ | 404 - Not Found | The requested resource doesn't exist. |
16
+ | 422 - Unprocessable | The syntax of the request is correct (often cause of wrong parameter). |
17
+ | 500 - Internal Server Error | We had a problem with our server. Try again later. |
18
+ | 503 - Service Unavailable | The server is overloaded or down for maintenance. |
19
+
20
+ ## Error types
21
+ | Error Type | Detail |
22
+ | -------------------------------:|:--------------------------------------------------------------------------|
23
+ | 400 - BadRequestError | The request was unacceptable, often due to missing a required parameter. |
24
+ | 401 - UnauthorizedError | No valid API key provided. |
25
+ | 404 - NotFoundError | The requested resource doesn't exist. |
26
+ | 422 - UnprocessableError | The syntax of the request is correct (often cause of wrong parameter). |
27
+ | 500 - InternalServerErrorError | We had a problem with our server. Try again later. |
28
+ | 503 - ServiceUnavailableError | The server is overloaded or down for maintenance. |
29
+ | 4xx - ClientError | The error seems to have been caused by the client. |
30
+ | 5xx - ServerError | The server is aware that it has encountered an error. |
31
+
32
+ ## Example Request
33
+ ```ruby
34
+ begin
35
+ # use Uiza's library to make requests ...
36
+ rescue Uiza::Error::BadRequestError => e
37
+ # BadRequestError
38
+ puts "#description_link: {e.description_link}"
39
+ puts "message: #{e.message}"
40
+ puts "code: #{e.code}"
41
+ rescue Uiza::Error::UnauthorizedError => e
42
+ # UnauthorizedError
43
+ rescue Uiza::Error::NotFoundError => e
44
+ # NotFoundError
45
+ rescue Uiza::Error::UnprocessableError => e
46
+ # UnprocessableError
47
+ rescue Uiza::Error::InternalServerErrorError => e
48
+ # InternalServerErrorError
49
+ rescue Uiza::Error::ServiceUnavailableError => e
50
+ # ServiceUnavailableError
51
+ rescue Uiza::Error::ClientError => e
52
+ # ClientError
53
+ rescue Uiza::Error::ServerError => e
54
+ # ServerError
55
+ rescue Uiza::Error::UizaError => e
56
+ # UizaError
57
+ rescue => e
58
+ # Something else happened, completely unrelated to Uiza
59
+ end
60
+ ```
@@ -0,0 +1,6 @@
1
+ ## Live Streaming
2
+ These APIs used to create and manage live streaming event.
3
+ * When a Live is not start : it's named as `Event`.
4
+ * When have an Event , you can start it : it's named as `Feed`.
5
+
6
+ See details [here](https://docs.uiza.io/#live-streaming).
data/doc/STORAGE.md ADDED
@@ -0,0 +1,195 @@
1
+ ## Storage
2
+ You can add your storage (FTP, AWS S3) with UIZA.
3
+ After synced, you can select your content easier from your storage to [create entity](https://docs.uiza.io/#create-entity).
4
+
5
+ See details [here](https://docs.uiza.io/#storage).
6
+
7
+ ## Add a storage
8
+ You can sync your storage (FTP, AWS S3) with UIZA.
9
+ After synced, you can select your content easier from your storage to [create entity](https://docs.uiza.io/#create-entity).
10
+
11
+ See details [here](https://docs.uiza.io/#add-a-storage).
12
+
13
+ ```ruby
14
+ require "uiza"
15
+
16
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
17
+ Uiza.authorization = "your-authorization"
18
+
19
+ params = {
20
+ name: "FTP Uiza",
21
+ description: "FTP of Uiza, use for transcode",
22
+ storageType: "ftp",
23
+ host: "ftp-example.uiza.io"
24
+ }
25
+
26
+ begin
27
+ storage = Uiza.add_storage params
28
+ # or storage = Uiza::Storage.add params
29
+ puts storage.id
30
+ puts storage.name
31
+ rescue Uiza::Error::UizaError => e
32
+ puts "description_link: #{e.description_link}"
33
+ puts "code: #{e.code}"
34
+ puts "message: #{e.message}"
35
+ rescue StandardError => e
36
+ puts "message: #{e.message}"
37
+ end
38
+ ```
39
+
40
+ Example Response
41
+ ```ruby
42
+ {
43
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49",
44
+ "name": "FTP Uiza",
45
+ "description": "FTP of Uiza, use for transcode",
46
+ "storageType": "ftp",
47
+ "usageType": "input",
48
+ "bucket": null,
49
+ "prefix": null,
50
+ "host": "ftp-exemple.uiza.io",
51
+ "awsAccessKey": null,
52
+ "awsSecretKey": null,
53
+ "username": "uiza",
54
+ "password": "=5;9x@LPsd+w7qW",
55
+ "region": null,
56
+ "port": 21,
57
+ "createdAt": "2018-06-19T03:01:56.000Z",
58
+ "updatedAt": "2018-06-19T03:01:56.000Z"
59
+ }
60
+ ```
61
+
62
+ ## Retrieve a storage
63
+ Get information of your added storage (`FTP` or `AWS S3`).
64
+
65
+ See details [here](https://docs.uiza.io/#retrieve-a-storage).
66
+
67
+ ```ruby
68
+ require "json"
69
+
70
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
71
+ Uiza.authorization = "your-authorization"
72
+
73
+ begin
74
+ storage = Uiza.retrieve_storage "your-storage-id"
75
+ # or storage = Uiza::Storage.retrieve "your-storage-id"
76
+ puts storage.id
77
+ puts storage.name
78
+ rescue Uiza::Error::UizaError => e
79
+ puts "description_link: #{e.description_link}"
80
+ puts "code: #{e.code}"
81
+ puts "message: #{e.message}"
82
+ rescue StandardError => e
83
+ puts "message: #{e.message}"
84
+ end
85
+ ```
86
+
87
+ Example Response
88
+ ```ruby
89
+ {
90
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49",
91
+ "name": "FTP Uiza",
92
+ "description": "FTP of Uiza, use for transcode",
93
+ "storageType": "ftp",
94
+ "usageType": "input",
95
+ "bucket": null,
96
+ "prefix": null,
97
+ "host": "ftp-exemple.uiza.io",
98
+ "awsAccessKey": null,
99
+ "awsSecretKey": null,
100
+ "username": "uiza",
101
+ "password": "=5;9x@LPsd+w7qW",
102
+ "region": null,
103
+ "port": 21,
104
+ "createdAt": "2018-06-19T03:01:56.000Z",
105
+ "updatedAt": "2018-06-19T03:01:56.000Z"
106
+ }
107
+ ```
108
+
109
+ ## Update storage
110
+ Update storage's information.
111
+
112
+ See details [here](https://docs.uiza.io/#update-storage).
113
+
114
+ ```ruby
115
+ require "uiza"
116
+
117
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
118
+ Uiza.authorization = "your-authorization"
119
+
120
+ params = {
121
+ id: "your-storage-id",
122
+ name: "FTP Uiza edited",
123
+ host: "ftp-example.uiza.io",
124
+ port: 21,
125
+ storageType: "ftp"
126
+ }
127
+
128
+ begin
129
+ storage = Uiza.update_storage params
130
+ # or storage = Uiza::Storage.update params
131
+
132
+ puts storage.id
133
+ puts storage.name
134
+ rescue Uiza::Error::UizaError => e
135
+ puts "description_link: #{e.description_link}"
136
+ puts "code: #{e.code}"
137
+ puts "message: #{e.message}"
138
+ rescue StandardError => e
139
+ puts "message: #{e.message}"
140
+ end
141
+ ```
142
+
143
+ Example Response
144
+ ```ruby
145
+ {
146
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49",
147
+ "name": "FTP Uiza edited",
148
+ "description": "FTP of Uiza, use for transcode",
149
+ "storageType": "ftp",
150
+ "usageType": "input",
151
+ "bucket": null,
152
+ "prefix": null,
153
+ "host": "ftp-exemple.uiza.io",
154
+ "awsAccessKey": null,
155
+ "awsSecretKey": null,
156
+ "username": "uiza",
157
+ "password": "=5;9x@LPsd+w7qW",
158
+ "region": null,
159
+ "port": 21,
160
+ "createdAt": "2018-06-19T03:01:56.000Z",
161
+ "updatedAt": "2018-06-19T03:01:56.000Z"
162
+ }
163
+ ```
164
+
165
+ ## Remove storage
166
+ Remove storage that added to Uiza.
167
+
168
+ See details [here](https://docs.uiza.io/#remove-storage).
169
+
170
+ ```ruby
171
+ require "uiza"
172
+
173
+ Uiza.workspace_api_domain = "your-workspace-api-domain.uiza.co"
174
+ Uiza.authorization = "your-authorization"
175
+
176
+ begin
177
+ storage = Uiza.remove_storage "your-storage-id"
178
+ # or storage = Uiza::Storage.remove "your-storage-id"
179
+
180
+ puts storage.id
181
+ rescue Uiza::Error::UizaError => e
182
+ puts "description_link: #{e.description_link}"
183
+ puts "code: #{e.code}"
184
+ puts "message: #{e.message}"
185
+ rescue StandardError => e
186
+ puts "message: #{e.message}"
187
+ end
188
+ ```
189
+
190
+ Example Response
191
+ ```ruby
192
+ {
193
+ "id": "cd003123-7ec9-4f3a-9d7c-f2de93e83e49"
194
+ }
195
+ ```
data/lib/uiza.rb ADDED
@@ -0,0 +1,42 @@
1
+ require "net/http"
2
+ require "net/https"
3
+ require "json"
4
+
5
+ require "uiza/version"
6
+ require "uiza/uiza_client"
7
+
8
+ require "uiza/error/uiza_error"
9
+ require "uiza/error/bad_request_error"
10
+ require "uiza/error/unauthorized_error"
11
+ require "uiza/error/not_found_error"
12
+ require "uiza/error/unprocessable_error"
13
+ require "uiza/error/internal_server_error"
14
+ require "uiza/error/service_unavailable_error"
15
+ require "uiza/error/client_error"
16
+ require "uiza/error/server_error"
17
+
18
+ require "uiza/api_operation/create"
19
+ require "uiza/api_operation/add"
20
+ require "uiza/api_operation/retrieve"
21
+ require "uiza/api_operation/list"
22
+ require "uiza/api_operation/update"
23
+ require "uiza/api_operation/delete"
24
+ require "uiza/api_operation/remove"
25
+
26
+ require "uiza/api_resource/entity_resource"
27
+ require "uiza/api_resource/storage_resource"
28
+ require "uiza/api_resource/category_resource"
29
+
30
+ require "uiza/entity"
31
+ require "uiza/storage"
32
+ require "uiza/category"
33
+
34
+ module Uiza
35
+ extend Uiza::APIResource::EntityResource
36
+ extend Uiza::APIResource::StorageResource
37
+ extend Uiza::APIResource::CategoryResource
38
+
39
+ class << self
40
+ attr_accessor :workspace_api_domain, :authorization
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Add
4
+ def add params
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :post
7
+ headers = {"Authorization" => Uiza.authorization}
8
+
9
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:add]
10
+ response = uiza_client.execute_request
11
+
12
+ retrieve response.id
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Create
4
+ def create params
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :post
7
+ headers = {"Authorization" => Uiza.authorization}
8
+
9
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:create]
10
+ response = uiza_client.execute_request
11
+
12
+ retrieve response.id
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Delete
4
+ def delete id
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :delete
7
+ headers = {"Authorization" => Uiza.authorization}
8
+ params = {id: id}
9
+
10
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:delete]
11
+ uiza_client.execute_request
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module List
4
+ def list params = {}
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :get
7
+ headers = {"Authorization" => Uiza.authorization}
8
+
9
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:list]
10
+ uiza_client.execute_request
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Remove
4
+ def remove id
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :delete
7
+ headers = {"Authorization" => Uiza.authorization}
8
+ params = {id: id}
9
+
10
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:remove]
11
+ uiza_client.execute_request
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Retrieve
4
+ def retrieve id
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :get
7
+ headers = {"Authorization" => Uiza.authorization}
8
+ params = {id: id}
9
+
10
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:retrieve]
11
+ uiza_client.execute_request
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Uiza
2
+ module APIOperation
3
+ module Update
4
+ def update params
5
+ url = "https://#{Uiza.workspace_api_domain}/api/public/v3/#{self::OBJECT_API_PATH}"
6
+ method = :put
7
+ headers = {"Authorization" => Uiza.authorization}
8
+
9
+ uiza_client = UizaClient.new url, method, headers, params, self::OBJECT_API_DESCRIPTION_LINK[:update]
10
+ response = uiza_client.execute_request
11
+
12
+ retrieve response.id
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,33 @@
1
+ module Uiza
2
+ module APIResource
3
+ module CategoryResource
4
+ def create_category params
5
+ Uiza::Category.create params
6
+ end
7
+
8
+ def retrieve_category id
9
+ Uiza::Category.retrieve id
10
+ end
11
+
12
+ def list_category params = {}
13
+ Uiza::Category.list params
14
+ end
15
+
16
+ def update_category params
17
+ Uiza::Category.update params
18
+ end
19
+
20
+ def delete_category id
21
+ Uiza::Category.delete id
22
+ end
23
+
24
+ def create_relation_category params
25
+ Uiza::Category.create_relation params
26
+ end
27
+
28
+ def delete_relation_category params
29
+ Uiza::Category.delete_relation params
30
+ end
31
+ end
32
+ end
33
+ end