spartera_api_sdk 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +69 -0
- data/LICENSE +21 -0
- data/README.md +360 -0
- data/Rakefile +10 -0
- data/config.json +10 -0
- data/docs/APIKeysApi.md +353 -0
- data/docs/Alert.md +36 -0
- data/docs/AlertsApi.md +511 -0
- data/docs/Apikey.md +36 -0
- data/docs/Asset.md +110 -0
- data/docs/AssetPriceHistoryApi.md +573 -0
- data/docs/Assetpricehistory.md +38 -0
- data/docs/AssetsApi.md +1131 -0
- data/docs/CloudProvidersApi.md +341 -0
- data/docs/Cloudprovider.md +30 -0
- data/docs/CompaniesApi.md +619 -0
- data/docs/Company.md +44 -0
- data/docs/Connection.md +54 -0
- data/docs/ConnectionsApi.md +497 -0
- data/docs/Error.md +24 -0
- data/docs/Favorite.md +36 -0
- data/docs/FavoritesApi.md +581 -0
- data/docs/InlineObject.md +22 -0
- data/docs/InlineObject1.md +20 -0
- data/docs/InlineObject2.md +20 -0
- data/docs/InlineObject3.md +20 -0
- data/docs/User.md +34 -0
- data/docs/UsersApi.md +357 -0
- data/example.rb +51 -0
- data/git_push.sh +57 -0
- data/lib/spartera_api_sdk/api/alerts_api.rb +543 -0
- data/lib/spartera_api_sdk/api/api_keys_api.rb +345 -0
- data/lib/spartera_api_sdk/api/asset_price_history_api.rb +576 -0
- data/lib/spartera_api_sdk/api/assets_api.rb +1106 -0
- data/lib/spartera_api_sdk/api/cloud_providers_api.rb +315 -0
- data/lib/spartera_api_sdk/api/companies_api.rb +571 -0
- data/lib/spartera_api_sdk/api/connections_api.rb +501 -0
- data/lib/spartera_api_sdk/api/favorites_api.rb +610 -0
- data/lib/spartera_api_sdk/api/users_api.rb +367 -0
- data/lib/spartera_api_sdk/api_client.rb +393 -0
- data/lib/spartera_api_sdk/api_error.rb +58 -0
- data/lib/spartera_api_sdk/configuration.rb +320 -0
- data/lib/spartera_api_sdk/models/alert.rb +353 -0
- data/lib/spartera_api_sdk/models/apikey.rb +370 -0
- data/lib/spartera_api_sdk/models/asset.rb +686 -0
- data/lib/spartera_api_sdk/models/assetpricehistory.rb +345 -0
- data/lib/spartera_api_sdk/models/cloudprovider.rb +292 -0
- data/lib/spartera_api_sdk/models/company.rb +389 -0
- data/lib/spartera_api_sdk/models/connection.rb +434 -0
- data/lib/spartera_api_sdk/models/error.rb +285 -0
- data/lib/spartera_api_sdk/models/favorite.rb +353 -0
- data/lib/spartera_api_sdk/models/inline_object.rb +240 -0
- data/lib/spartera_api_sdk/models/inline_object1.rb +229 -0
- data/lib/spartera_api_sdk/models/inline_object2.rb +229 -0
- data/lib/spartera_api_sdk/models/inline_object3.rb +229 -0
- data/lib/spartera_api_sdk/models/user.rb +327 -0
- data/lib/spartera_api_sdk/version.rb +15 -0
- data/lib/spartera_api_sdk.rb +62 -0
- data/spartera_api_sdk.gemspec +28 -0
- data/spec/api/alerts_api_spec.rb +126 -0
- data/spec/api/api_keys_api_spec.rb +93 -0
- data/spec/api/asset_price_history_api_spec.rb +134 -0
- data/spec/api/assets_api_spec.rb +228 -0
- data/spec/api/cloud_providers_api_spec.rb +88 -0
- data/spec/api/companies_api_spec.rb +134 -0
- data/spec/api/connections_api_spec.rb +119 -0
- data/spec/api/favorites_api_spec.rb +138 -0
- data/spec/api/users_api_spec.rb +95 -0
- data/spec/models/alert_spec.rb +90 -0
- data/spec/models/apikey_spec.rb +90 -0
- data/spec/models/asset_spec.rb +312 -0
- data/spec/models/assetpricehistory_spec.rb +96 -0
- data/spec/models/cloudprovider_spec.rb +72 -0
- data/spec/models/company_spec.rb +114 -0
- data/spec/models/connection_spec.rb +144 -0
- data/spec/models/error_spec.rb +54 -0
- data/spec/models/favorite_spec.rb +90 -0
- data/spec/models/inline_object1_spec.rb +42 -0
- data/spec/models/inline_object2_spec.rb +42 -0
- data/spec/models/inline_object3_spec.rb +42 -0
- data/spec/models/inline_object_spec.rb +48 -0
- data/spec/models/user_spec.rb +84 -0
- data/spec/spec_helper.rb +111 -0
- data/test.sh +42 -0
- metadata +204 -0
data/docs/UsersApi.md
ADDED
@@ -0,0 +1,357 @@
|
|
1
|
+
# SparteraApiSdk::UsersApi
|
2
|
+
|
3
|
+
All URIs are relative to *https://api.spartera.com*
|
4
|
+
|
5
|
+
| Method | HTTP request | Description |
|
6
|
+
| ------ | ------------ | ----------- |
|
7
|
+
| [**companies_company_id_users_get**](UsersApi.md#companies_company_id_users_get) | **GET** /companies/{company_id}/users | Get a list of all users for a particular company |
|
8
|
+
| [**companies_company_id_users_post**](UsersApi.md#companies_company_id_users_post) | **POST** /companies/{company_id}/users | Create a new user |
|
9
|
+
| [**companies_company_id_users_user_id_delete**](UsersApi.md#companies_company_id_users_user_id_delete) | **DELETE** /companies/{company_id}/users/{user_id} | Delete single user by ID |
|
10
|
+
| [**companies_company_id_users_user_id_get**](UsersApi.md#companies_company_id_users_user_id_get) | **GET** /companies/{company_id}/users/{user_id} | Get single user by ID |
|
11
|
+
| [**companies_company_id_users_user_id_patch**](UsersApi.md#companies_company_id_users_user_id_patch) | **PATCH** /companies/{company_id}/users/{user_id} | Update an existing user by ID |
|
12
|
+
|
13
|
+
|
14
|
+
## companies_company_id_users_get
|
15
|
+
|
16
|
+
> Object companies_company_id_users_get(company_id)
|
17
|
+
|
18
|
+
Get a list of all users for a particular company
|
19
|
+
|
20
|
+
### Examples
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require 'time'
|
24
|
+
require 'spartera_api_sdk'
|
25
|
+
# setup authorization
|
26
|
+
SparteraApiSdk.configure do |config|
|
27
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
28
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
29
|
+
end
|
30
|
+
|
31
|
+
api_instance = SparteraApiSdk::UsersApi.new
|
32
|
+
company_id = 'company_id_example' # String |
|
33
|
+
|
34
|
+
begin
|
35
|
+
# Get a list of all users for a particular company
|
36
|
+
result = api_instance.companies_company_id_users_get(company_id)
|
37
|
+
p result
|
38
|
+
rescue SparteraApiSdk::ApiError => e
|
39
|
+
puts "Error when calling UsersApi->companies_company_id_users_get: #{e}"
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
#### Using the companies_company_id_users_get_with_http_info variant
|
44
|
+
|
45
|
+
This returns an Array which contains the response data, status code and headers.
|
46
|
+
|
47
|
+
> <Array(Object, Integer, Hash)> companies_company_id_users_get_with_http_info(company_id)
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
begin
|
51
|
+
# Get a list of all users for a particular company
|
52
|
+
data, status_code, headers = api_instance.companies_company_id_users_get_with_http_info(company_id)
|
53
|
+
p status_code # => 2xx
|
54
|
+
p headers # => { ... }
|
55
|
+
p data # => Object
|
56
|
+
rescue SparteraApiSdk::ApiError => e
|
57
|
+
puts "Error when calling UsersApi->companies_company_id_users_get_with_http_info: #{e}"
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
### Parameters
|
62
|
+
|
63
|
+
| Name | Type | Description | Notes |
|
64
|
+
| ---- | ---- | ----------- | ----- |
|
65
|
+
| **company_id** | **String** | | |
|
66
|
+
|
67
|
+
### Return type
|
68
|
+
|
69
|
+
**Object**
|
70
|
+
|
71
|
+
### Authorization
|
72
|
+
|
73
|
+
[bearerAuth](../README.md#bearerAuth)
|
74
|
+
|
75
|
+
### HTTP request headers
|
76
|
+
|
77
|
+
- **Content-Type**: Not defined
|
78
|
+
- **Accept**: application/json
|
79
|
+
|
80
|
+
|
81
|
+
## companies_company_id_users_post
|
82
|
+
|
83
|
+
> Object companies_company_id_users_post(company_id, user)
|
84
|
+
|
85
|
+
Create a new user
|
86
|
+
|
87
|
+
### Examples
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
require 'time'
|
91
|
+
require 'spartera_api_sdk'
|
92
|
+
# setup authorization
|
93
|
+
SparteraApiSdk.configure do |config|
|
94
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
95
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
96
|
+
end
|
97
|
+
|
98
|
+
api_instance = SparteraApiSdk::UsersApi.new
|
99
|
+
company_id = 'company_id_example' # String |
|
100
|
+
user = SparteraApiSdk::User.new({company_id: 'company_id_example', status: 'status_example'}) # User |
|
101
|
+
|
102
|
+
begin
|
103
|
+
# Create a new user
|
104
|
+
result = api_instance.companies_company_id_users_post(company_id, user)
|
105
|
+
p result
|
106
|
+
rescue SparteraApiSdk::ApiError => e
|
107
|
+
puts "Error when calling UsersApi->companies_company_id_users_post: #{e}"
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
#### Using the companies_company_id_users_post_with_http_info variant
|
112
|
+
|
113
|
+
This returns an Array which contains the response data, status code and headers.
|
114
|
+
|
115
|
+
> <Array(Object, Integer, Hash)> companies_company_id_users_post_with_http_info(company_id, user)
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
begin
|
119
|
+
# Create a new user
|
120
|
+
data, status_code, headers = api_instance.companies_company_id_users_post_with_http_info(company_id, user)
|
121
|
+
p status_code # => 2xx
|
122
|
+
p headers # => { ... }
|
123
|
+
p data # => Object
|
124
|
+
rescue SparteraApiSdk::ApiError => e
|
125
|
+
puts "Error when calling UsersApi->companies_company_id_users_post_with_http_info: #{e}"
|
126
|
+
end
|
127
|
+
```
|
128
|
+
|
129
|
+
### Parameters
|
130
|
+
|
131
|
+
| Name | Type | Description | Notes |
|
132
|
+
| ---- | ---- | ----------- | ----- |
|
133
|
+
| **company_id** | **String** | | |
|
134
|
+
| **user** | [**User**](User.md) | | |
|
135
|
+
|
136
|
+
### Return type
|
137
|
+
|
138
|
+
**Object**
|
139
|
+
|
140
|
+
### Authorization
|
141
|
+
|
142
|
+
[bearerAuth](../README.md#bearerAuth)
|
143
|
+
|
144
|
+
### HTTP request headers
|
145
|
+
|
146
|
+
- **Content-Type**: application/json
|
147
|
+
- **Accept**: application/json
|
148
|
+
|
149
|
+
|
150
|
+
## companies_company_id_users_user_id_delete
|
151
|
+
|
152
|
+
> Object companies_company_id_users_user_id_delete(company_id, user_id)
|
153
|
+
|
154
|
+
Delete single user by ID
|
155
|
+
|
156
|
+
### Examples
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
require 'time'
|
160
|
+
require 'spartera_api_sdk'
|
161
|
+
# setup authorization
|
162
|
+
SparteraApiSdk.configure do |config|
|
163
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
164
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
165
|
+
end
|
166
|
+
|
167
|
+
api_instance = SparteraApiSdk::UsersApi.new
|
168
|
+
company_id = 'company_id_example' # String |
|
169
|
+
user_id = 'user_id_example' # String |
|
170
|
+
|
171
|
+
begin
|
172
|
+
# Delete single user by ID
|
173
|
+
result = api_instance.companies_company_id_users_user_id_delete(company_id, user_id)
|
174
|
+
p result
|
175
|
+
rescue SparteraApiSdk::ApiError => e
|
176
|
+
puts "Error when calling UsersApi->companies_company_id_users_user_id_delete: #{e}"
|
177
|
+
end
|
178
|
+
```
|
179
|
+
|
180
|
+
#### Using the companies_company_id_users_user_id_delete_with_http_info variant
|
181
|
+
|
182
|
+
This returns an Array which contains the response data, status code and headers.
|
183
|
+
|
184
|
+
> <Array(Object, Integer, Hash)> companies_company_id_users_user_id_delete_with_http_info(company_id, user_id)
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
begin
|
188
|
+
# Delete single user by ID
|
189
|
+
data, status_code, headers = api_instance.companies_company_id_users_user_id_delete_with_http_info(company_id, user_id)
|
190
|
+
p status_code # => 2xx
|
191
|
+
p headers # => { ... }
|
192
|
+
p data # => Object
|
193
|
+
rescue SparteraApiSdk::ApiError => e
|
194
|
+
puts "Error when calling UsersApi->companies_company_id_users_user_id_delete_with_http_info: #{e}"
|
195
|
+
end
|
196
|
+
```
|
197
|
+
|
198
|
+
### Parameters
|
199
|
+
|
200
|
+
| Name | Type | Description | Notes |
|
201
|
+
| ---- | ---- | ----------- | ----- |
|
202
|
+
| **company_id** | **String** | | |
|
203
|
+
| **user_id** | **String** | | |
|
204
|
+
|
205
|
+
### Return type
|
206
|
+
|
207
|
+
**Object**
|
208
|
+
|
209
|
+
### Authorization
|
210
|
+
|
211
|
+
[bearerAuth](../README.md#bearerAuth)
|
212
|
+
|
213
|
+
### HTTP request headers
|
214
|
+
|
215
|
+
- **Content-Type**: Not defined
|
216
|
+
- **Accept**: application/json
|
217
|
+
|
218
|
+
|
219
|
+
## companies_company_id_users_user_id_get
|
220
|
+
|
221
|
+
> Object companies_company_id_users_user_id_get(company_id, user_id)
|
222
|
+
|
223
|
+
Get single user by ID
|
224
|
+
|
225
|
+
### Examples
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
require 'time'
|
229
|
+
require 'spartera_api_sdk'
|
230
|
+
# setup authorization
|
231
|
+
SparteraApiSdk.configure do |config|
|
232
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
233
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
234
|
+
end
|
235
|
+
|
236
|
+
api_instance = SparteraApiSdk::UsersApi.new
|
237
|
+
company_id = 'company_id_example' # String |
|
238
|
+
user_id = 'user_id_example' # String |
|
239
|
+
|
240
|
+
begin
|
241
|
+
# Get single user by ID
|
242
|
+
result = api_instance.companies_company_id_users_user_id_get(company_id, user_id)
|
243
|
+
p result
|
244
|
+
rescue SparteraApiSdk::ApiError => e
|
245
|
+
puts "Error when calling UsersApi->companies_company_id_users_user_id_get: #{e}"
|
246
|
+
end
|
247
|
+
```
|
248
|
+
|
249
|
+
#### Using the companies_company_id_users_user_id_get_with_http_info variant
|
250
|
+
|
251
|
+
This returns an Array which contains the response data, status code and headers.
|
252
|
+
|
253
|
+
> <Array(Object, Integer, Hash)> companies_company_id_users_user_id_get_with_http_info(company_id, user_id)
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
begin
|
257
|
+
# Get single user by ID
|
258
|
+
data, status_code, headers = api_instance.companies_company_id_users_user_id_get_with_http_info(company_id, user_id)
|
259
|
+
p status_code # => 2xx
|
260
|
+
p headers # => { ... }
|
261
|
+
p data # => Object
|
262
|
+
rescue SparteraApiSdk::ApiError => e
|
263
|
+
puts "Error when calling UsersApi->companies_company_id_users_user_id_get_with_http_info: #{e}"
|
264
|
+
end
|
265
|
+
```
|
266
|
+
|
267
|
+
### Parameters
|
268
|
+
|
269
|
+
| Name | Type | Description | Notes |
|
270
|
+
| ---- | ---- | ----------- | ----- |
|
271
|
+
| **company_id** | **String** | | |
|
272
|
+
| **user_id** | **String** | | |
|
273
|
+
|
274
|
+
### Return type
|
275
|
+
|
276
|
+
**Object**
|
277
|
+
|
278
|
+
### Authorization
|
279
|
+
|
280
|
+
[bearerAuth](../README.md#bearerAuth)
|
281
|
+
|
282
|
+
### HTTP request headers
|
283
|
+
|
284
|
+
- **Content-Type**: Not defined
|
285
|
+
- **Accept**: application/json
|
286
|
+
|
287
|
+
|
288
|
+
## companies_company_id_users_user_id_patch
|
289
|
+
|
290
|
+
> Object companies_company_id_users_user_id_patch(company_id, user_id, user)
|
291
|
+
|
292
|
+
Update an existing user by ID
|
293
|
+
|
294
|
+
### Examples
|
295
|
+
|
296
|
+
```ruby
|
297
|
+
require 'time'
|
298
|
+
require 'spartera_api_sdk'
|
299
|
+
# setup authorization
|
300
|
+
SparteraApiSdk.configure do |config|
|
301
|
+
# Configure Bearer authorization (JWT): bearerAuth
|
302
|
+
config.access_token = 'YOUR_BEARER_TOKEN'
|
303
|
+
end
|
304
|
+
|
305
|
+
api_instance = SparteraApiSdk::UsersApi.new
|
306
|
+
company_id = 'company_id_example' # String |
|
307
|
+
user_id = 'user_id_example' # String |
|
308
|
+
user = SparteraApiSdk::User.new({company_id: 'company_id_example', status: 'status_example'}) # User |
|
309
|
+
|
310
|
+
begin
|
311
|
+
# Update an existing user by ID
|
312
|
+
result = api_instance.companies_company_id_users_user_id_patch(company_id, user_id, user)
|
313
|
+
p result
|
314
|
+
rescue SparteraApiSdk::ApiError => e
|
315
|
+
puts "Error when calling UsersApi->companies_company_id_users_user_id_patch: #{e}"
|
316
|
+
end
|
317
|
+
```
|
318
|
+
|
319
|
+
#### Using the companies_company_id_users_user_id_patch_with_http_info variant
|
320
|
+
|
321
|
+
This returns an Array which contains the response data, status code and headers.
|
322
|
+
|
323
|
+
> <Array(Object, Integer, Hash)> companies_company_id_users_user_id_patch_with_http_info(company_id, user_id, user)
|
324
|
+
|
325
|
+
```ruby
|
326
|
+
begin
|
327
|
+
# Update an existing user by ID
|
328
|
+
data, status_code, headers = api_instance.companies_company_id_users_user_id_patch_with_http_info(company_id, user_id, user)
|
329
|
+
p status_code # => 2xx
|
330
|
+
p headers # => { ... }
|
331
|
+
p data # => Object
|
332
|
+
rescue SparteraApiSdk::ApiError => e
|
333
|
+
puts "Error when calling UsersApi->companies_company_id_users_user_id_patch_with_http_info: #{e}"
|
334
|
+
end
|
335
|
+
```
|
336
|
+
|
337
|
+
### Parameters
|
338
|
+
|
339
|
+
| Name | Type | Description | Notes |
|
340
|
+
| ---- | ---- | ----------- | ----- |
|
341
|
+
| **company_id** | **String** | | |
|
342
|
+
| **user_id** | **String** | | |
|
343
|
+
| **user** | [**User**](User.md) | | |
|
344
|
+
|
345
|
+
### Return type
|
346
|
+
|
347
|
+
**Object**
|
348
|
+
|
349
|
+
### Authorization
|
350
|
+
|
351
|
+
[bearerAuth](../README.md#bearerAuth)
|
352
|
+
|
353
|
+
### HTTP request headers
|
354
|
+
|
355
|
+
- **Content-Type**: application/json
|
356
|
+
- **Accept**: application/json
|
357
|
+
|
data/example.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Simple Spartera API Ruby SDK Example
|
4
|
+
#
|
5
|
+
# This example demonstrates basic SDK initialization and configuration.
|
6
|
+
|
7
|
+
require 'spartera_api_sdk'
|
8
|
+
|
9
|
+
def main
|
10
|
+
puts "đ Spartera API Ruby SDK Example"
|
11
|
+
puts "=" * 40
|
12
|
+
|
13
|
+
# Configure the client
|
14
|
+
SparteraApiSdk.configure do |config|
|
15
|
+
# Set API base URL
|
16
|
+
config.host = ENV['SPARTERA_API_BASE_URL'] || 'https://api.spartera.com'
|
17
|
+
|
18
|
+
# IMPORTANT: Spartera uses X-API-Key header authentication
|
19
|
+
api_key = ENV['SPARTERA_API_KEY'] || 'your-api-key-here'
|
20
|
+
config.api_key['X-API-Key'] = api_key
|
21
|
+
|
22
|
+
# Optional: Set timeout
|
23
|
+
config.timeout = 30
|
24
|
+
end
|
25
|
+
|
26
|
+
# Get company ID from environment
|
27
|
+
company_id = ENV['SPARTERA_COMPANY_ID'] || 'your-company-id'
|
28
|
+
|
29
|
+
# Check environment variables
|
30
|
+
if ENV['SPARTERA_API_KEY'].nil? || ENV['SPARTERA_API_KEY'] == 'your-api-key-here'
|
31
|
+
puts "â ď¸ Set SPARTERA_API_KEY environment variable with your actual API key"
|
32
|
+
end
|
33
|
+
if ENV['SPARTERA_COMPANY_ID'].nil? || ENV['SPARTERA_COMPANY_ID'] == 'your-company-id'
|
34
|
+
puts "â ď¸ Set SPARTERA_COMPANY_ID environment variable with your company ID"
|
35
|
+
end
|
36
|
+
|
37
|
+
puts ""
|
38
|
+
puts "Configured client for: #{SparteraApiSdk.configuration.host}"
|
39
|
+
puts "Company ID: #{company_id}"
|
40
|
+
puts "API configuration created: #{SparteraApiSdk.configuration.host ? 'true' : 'false'}"
|
41
|
+
|
42
|
+
puts "\nâ
SDK basic initialization test completed successfully!"
|
43
|
+
puts "\nđ To test with real API calls, set your credentials and modify this example"
|
44
|
+
puts " export SPARTERA_API_KEY='your-actual-api-key'"
|
45
|
+
puts " export SPARTERA_COMPANY_ID='your-actual-company-id'"
|
46
|
+
end
|
47
|
+
|
48
|
+
# Run the example
|
49
|
+
if __FILE__ == $0
|
50
|
+
main
|
51
|
+
end
|
data/git_push.sh
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
3
|
+
#
|
4
|
+
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
5
|
+
|
6
|
+
git_user_id=$1
|
7
|
+
git_repo_id=$2
|
8
|
+
release_note=$3
|
9
|
+
git_host=$4
|
10
|
+
|
11
|
+
if [ "$git_host" = "" ]; then
|
12
|
+
git_host="github.com"
|
13
|
+
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
14
|
+
fi
|
15
|
+
|
16
|
+
if [ "$git_user_id" = "" ]; then
|
17
|
+
git_user_id="spartera-com"
|
18
|
+
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
19
|
+
fi
|
20
|
+
|
21
|
+
if [ "$git_repo_id" = "" ]; then
|
22
|
+
git_repo_id="spartera-ruby-sdk"
|
23
|
+
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
24
|
+
fi
|
25
|
+
|
26
|
+
if [ "$release_note" = "" ]; then
|
27
|
+
release_note="Minor update"
|
28
|
+
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
29
|
+
fi
|
30
|
+
|
31
|
+
# Initialize the local directory as a Git repository
|
32
|
+
git init
|
33
|
+
|
34
|
+
# Adds the files in the local repository and stages them for commit.
|
35
|
+
git add .
|
36
|
+
|
37
|
+
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
38
|
+
git commit -m "$release_note"
|
39
|
+
|
40
|
+
# Sets the new remote
|
41
|
+
git_remote=$(git remote)
|
42
|
+
if [ "$git_remote" = "" ]; then # git remote not defined
|
43
|
+
|
44
|
+
if [ "$GIT_TOKEN" = "" ]; then
|
45
|
+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
46
|
+
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
47
|
+
else
|
48
|
+
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
49
|
+
fi
|
50
|
+
|
51
|
+
fi
|
52
|
+
|
53
|
+
git pull origin master
|
54
|
+
|
55
|
+
# Pushes (Forces) the changes in the local repository up to the remote repository
|
56
|
+
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
57
|
+
git push origin master 2>&1 | grep -v 'To https'
|