vantage-client 0.0.1.beta.1

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.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +111 -0
  4. data/Rakefile +8 -0
  5. data/docs/PingApi.md +53 -0
  6. data/docs/Price.md +14 -0
  7. data/docs/Prices.md +9 -0
  8. data/docs/PricesApi.md +323 -0
  9. data/docs/Product.md +12 -0
  10. data/docs/Products.md +9 -0
  11. data/docs/Provider.md +10 -0
  12. data/docs/Providers.md +9 -0
  13. data/docs/Service.md +11 -0
  14. data/docs/Services.md +9 -0
  15. data/git_push.sh +55 -0
  16. data/lib/vantage-client/api/ping_api.rb +66 -0
  17. data/lib/vantage-client/api/prices_api.rb +323 -0
  18. data/lib/vantage-client/api_client.rb +391 -0
  19. data/lib/vantage-client/api_error.rb +38 -0
  20. data/lib/vantage-client/configuration.rb +209 -0
  21. data/lib/vantage-client/models/price.rb +245 -0
  22. data/lib/vantage-client/models/prices.rb +196 -0
  23. data/lib/vantage-client/models/product.rb +225 -0
  24. data/lib/vantage-client/models/products.rb +196 -0
  25. data/lib/vantage-client/models/provider.rb +204 -0
  26. data/lib/vantage-client/models/providers.rb +196 -0
  27. data/lib/vantage-client/models/service.rb +214 -0
  28. data/lib/vantage-client/models/services.rb +196 -0
  29. data/lib/vantage-client/version.rb +15 -0
  30. data/lib/vantage-client.rb +49 -0
  31. data/spec/api/ping_api_spec.rb +45 -0
  32. data/spec/api/prices_api_spec.rb +103 -0
  33. data/spec/api_client_spec.rb +243 -0
  34. data/spec/configuration_spec.rb +42 -0
  35. data/spec/models/price_spec.rb +77 -0
  36. data/spec/models/prices_spec.rb +47 -0
  37. data/spec/models/product_spec.rb +65 -0
  38. data/spec/models/products_spec.rb +47 -0
  39. data/spec/models/provider_spec.rb +53 -0
  40. data/spec/models/providers_spec.rb +47 -0
  41. data/spec/models/service_spec.rb +59 -0
  42. data/spec/models/services_spec.rb +47 -0
  43. data/spec/spec_helper.rb +111 -0
  44. data/vantage-client-0.0.1.pre.gem +0 -0
  45. data/vantage-client.gemspec +46 -0
  46. metadata +300 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8b3b6e5c6f534e26d84d3a6aac5e525b68cca4361f4904ada855149df5e2d62b
4
+ data.tar.gz: 18eaf4925a9b4a76a16fa3670a09672e2d26963cb24a07819d1d001221d87a85
5
+ SHA512:
6
+ metadata.gz: 6215a44441f74d46f4651da777eab3b3b497dc46e8ad9be74c1afc187e791d25c0b33625a7715f734c6f7de9c308717b698a2e4a2d7c69bc2a99762ffe3047ee
7
+ data.tar.gz: 91eff07d89265beef7d2151d6d763aee9fed9d20e29b14162639b1cc484ee511bbfae1886f2496050222991ad15982631f03433ec12bedb63d4729c7ddb49797
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rake', '~> 12.3.3'
7
+ end
data/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # vantage-client
2
+
3
+ Vantage - the Ruby gem for the Vantage
4
+
5
+ Vantage API
6
+
7
+ This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
8
+
9
+ - API version: 1.0.0
10
+ - Package version: 0.0.1.beta.1
11
+ - Build package: io.swagger.codegen.languages.RubyClientCodegen
12
+ For more information, please visit [https://www.vantage.sh](https://www.vantage.sh)
13
+
14
+ ## Installation
15
+
16
+ ### Build a gem
17
+
18
+ To build the Ruby code into a gem:
19
+
20
+ ```shell
21
+ gem build vantage-client.gemspec
22
+ ```
23
+
24
+ Then either install the gem locally:
25
+
26
+ ```shell
27
+ gem install ./vantage-client-0.0.1.beta.1.gem
28
+ ```
29
+ (for development, run `gem install --dev ./vantage-client-0.0.1.beta.1.gem` to install the development dependencies)
30
+
31
+ or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
32
+
33
+ Finally add this to the Gemfile:
34
+
35
+ gem 'vantage-client', '~> 0.0.1.beta.1'
36
+
37
+ ### Install from Git
38
+
39
+ If the Ruby gem is hosted at a git repository: https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO, then add the following in the Gemfile:
40
+
41
+ gem 'vantage-client', :git => 'https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO.git'
42
+
43
+ ### Include the Ruby code directly
44
+
45
+ Include the Ruby code directly using `-I` as follows:
46
+
47
+ ```shell
48
+ ruby -Ilib script.rb
49
+ ```
50
+
51
+ ## Getting Started
52
+
53
+ Please follow the [installation](#installation) procedure and then run the following code:
54
+ ```ruby
55
+ # Load the gem
56
+ require 'vantage-client'
57
+
58
+ # Setup authorization
59
+ Vantage.configure do |config|
60
+ # Configure OAuth2 access token for authorization: oauth2
61
+ config.access_token = 'YOUR ACCESS TOKEN'
62
+ end
63
+
64
+ api_instance = Vantage::PingApi.new
65
+
66
+ begin
67
+ api_instance.ping
68
+ rescue Vantage::ApiError => e
69
+ puts "Exception when calling PingApi->ping: #{e}"
70
+ end
71
+
72
+ ```
73
+
74
+ ## Documentation for API Endpoints
75
+
76
+ All URIs are relative to *https://api.vantage.sh*
77
+
78
+ Class | Method | HTTP request | Description
79
+ ------------ | ------------- | ------------- | -------------
80
+ *Vantage::PingApi* | [**ping**](docs/PingApi.md#ping) | **GET** /v1/ping |
81
+ *Vantage::PricesApi* | [**get_price**](docs/PricesApi.md#get_price) | **GET** /v1/products/{product_id}/prices/{id} |
82
+ *Vantage::PricesApi* | [**get_prices**](docs/PricesApi.md#get_prices) | **GET** /v1/products/{product_id}/prices |
83
+ *Vantage::PricesApi* | [**get_product**](docs/PricesApi.md#get_product) | **GET** /v1/products/{id} |
84
+ *Vantage::PricesApi* | [**get_products**](docs/PricesApi.md#get_products) | **GET** /v1/products |
85
+ *Vantage::PricesApi* | [**get_providers**](docs/PricesApi.md#get_providers) | **GET** /v1/providers |
86
+ *Vantage::PricesApi* | [**get_services**](docs/PricesApi.md#get_services) | **GET** /v1/services |
87
+
88
+
89
+ ## Documentation for Models
90
+
91
+ - [Vantage::Price](docs/Price.md)
92
+ - [Vantage::Prices](docs/Prices.md)
93
+ - [Vantage::Product](docs/Product.md)
94
+ - [Vantage::Products](docs/Products.md)
95
+ - [Vantage::Provider](docs/Provider.md)
96
+ - [Vantage::Providers](docs/Providers.md)
97
+ - [Vantage::Service](docs/Service.md)
98
+ - [Vantage::Services](docs/Services.md)
99
+
100
+
101
+ ## Documentation for Authorization
102
+
103
+
104
+ ### oauth2
105
+
106
+ - **Type**: OAuth
107
+ - **Flow**: application
108
+ - **Authorization URL**:
109
+ - **Scopes**:
110
+ - read: Grants read access
111
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ begin
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
6
+ rescue LoadError
7
+ # no rspec available
8
+ end
data/docs/PingApi.md ADDED
@@ -0,0 +1,53 @@
1
+ # Vantage::PingApi
2
+
3
+ All URIs are relative to *https://api.vantage.sh*
4
+
5
+ Method | HTTP request | Description
6
+ ------------- | ------------- | -------------
7
+ [**ping**](PingApi.md#ping) | **GET** /v1/ping |
8
+
9
+
10
+ # **ping**
11
+ > ping
12
+
13
+
14
+
15
+ This is a health check endpoint that can be used to determine Vantage API healthiness. It will return a 200 success with the raw text of \"pong\" if everything is running smoothly.
16
+
17
+ ### Example
18
+ ```ruby
19
+ # load the gem
20
+ require 'vantage-client'
21
+ # setup authorization
22
+ Vantage.configure do |config|
23
+ # Configure OAuth2 access token for authorization: oauth2
24
+ config.access_token = 'YOUR ACCESS TOKEN'
25
+ end
26
+
27
+ api_instance = Vantage::PingApi.new
28
+
29
+ begin
30
+ api_instance.ping
31
+ rescue Vantage::ApiError => e
32
+ puts "Exception when calling PingApi->ping: #{e}"
33
+ end
34
+ ```
35
+
36
+ ### Parameters
37
+ This endpoint does not need any parameter.
38
+
39
+ ### Return type
40
+
41
+ nil (empty response body)
42
+
43
+ ### Authorization
44
+
45
+ [oauth2](../README.md#oauth2)
46
+
47
+ ### HTTP request headers
48
+
49
+ - **Content-Type**: Not defined
50
+ - **Accept**: application/json
51
+
52
+
53
+
data/docs/Price.md ADDED
@@ -0,0 +1,14 @@
1
+ # Vantage::Price
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **id** | **String** | | [optional]
7
+ **unit** | **String** | The unit in which the amount is billed. | [optional]
8
+ **region** | **String** | The region the price is specific to. | [optional]
9
+ **rate_type** | **String** | The part of the product the price applies to. (compute, transfer, etc..) | [optional]
10
+ **currency** | **String** | The currency of the amount. | [optional]
11
+ **amount** | **Float** | The amount of money this specific product price costs. | [optional]
12
+ **details** | **Object** | Service specific metadata. | [optional]
13
+
14
+
data/docs/Prices.md ADDED
@@ -0,0 +1,9 @@
1
+ # Vantage::Prices
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **links** | **Object** | | [optional]
7
+ **prices** | [**Array<Price>**](Price.md) | | [optional]
8
+
9
+
data/docs/PricesApi.md ADDED
@@ -0,0 +1,323 @@
1
+ # Vantage::PricesApi
2
+
3
+ All URIs are relative to *https://api.vantage.sh*
4
+
5
+ Method | HTTP request | Description
6
+ ------------- | ------------- | -------------
7
+ [**get_price**](PricesApi.md#get_price) | **GET** /v1/products/{product_id}/prices/{id} |
8
+ [**get_prices**](PricesApi.md#get_prices) | **GET** /v1/products/{product_id}/prices |
9
+ [**get_product**](PricesApi.md#get_product) | **GET** /v1/products/{id} |
10
+ [**get_products**](PricesApi.md#get_products) | **GET** /v1/products |
11
+ [**get_providers**](PricesApi.md#get_providers) | **GET** /v1/providers |
12
+ [**get_services**](PricesApi.md#get_services) | **GET** /v1/services |
13
+
14
+
15
+ # **get_price**
16
+ > Price get_price(product_id, id)
17
+
18
+
19
+
20
+ Returns a price
21
+
22
+ ### Example
23
+ ```ruby
24
+ # load the gem
25
+ require 'vantage-client'
26
+ # setup authorization
27
+ Vantage.configure do |config|
28
+ # Configure OAuth2 access token for authorization: oauth2
29
+ config.access_token = 'YOUR ACCESS TOKEN'
30
+ end
31
+
32
+ api_instance = Vantage::PricesApi.new
33
+
34
+ product_id = 'product_id_example' # String |
35
+
36
+ id = 'id_example' # String | Unique identifier of the price e.g. aws-ec2-m5d_16xlarge-eu_central_1-on_demand-linux_enterprise
37
+
38
+
39
+ begin
40
+ result = api_instance.get_price(product_id, id)
41
+ p result
42
+ rescue Vantage::ApiError => e
43
+ puts "Exception when calling PricesApi->get_price: #{e}"
44
+ end
45
+ ```
46
+
47
+ ### Parameters
48
+
49
+ Name | Type | Description | Notes
50
+ ------------- | ------------- | ------------- | -------------
51
+ **product_id** | **String**| |
52
+ **id** | **String**| Unique identifier of the price e.g. aws-ec2-m5d_16xlarge-eu_central_1-on_demand-linux_enterprise |
53
+
54
+ ### Return type
55
+
56
+ [**Price**](Price.md)
57
+
58
+ ### Authorization
59
+
60
+ [oauth2](../README.md#oauth2)
61
+
62
+ ### HTTP request headers
63
+
64
+ - **Content-Type**: Not defined
65
+ - **Accept**: application/json
66
+
67
+
68
+
69
+ # **get_prices**
70
+ > Prices get_prices(product_id)
71
+
72
+
73
+
74
+ Return available Prices across all Regions for a Product.
75
+
76
+ ### Example
77
+ ```ruby
78
+ # load the gem
79
+ require 'vantage-client'
80
+ # setup authorization
81
+ Vantage.configure do |config|
82
+ # Configure OAuth2 access token for authorization: oauth2
83
+ config.access_token = 'YOUR ACCESS TOKEN'
84
+ end
85
+
86
+ api_instance = Vantage::PricesApi.new
87
+
88
+ product_id = 'product_id_example' # String | The Product ID that you wish to query prices for.
89
+
90
+
91
+ begin
92
+ result = api_instance.get_prices(product_id)
93
+ p result
94
+ rescue Vantage::ApiError => e
95
+ puts "Exception when calling PricesApi->get_prices: #{e}"
96
+ end
97
+ ```
98
+
99
+ ### Parameters
100
+
101
+ Name | Type | Description | Notes
102
+ ------------- | ------------- | ------------- | -------------
103
+ **product_id** | **String**| The Product ID that you wish to query prices for. |
104
+
105
+ ### Return type
106
+
107
+ [**Prices**](Prices.md)
108
+
109
+ ### Authorization
110
+
111
+ [oauth2](../README.md#oauth2)
112
+
113
+ ### HTTP request headers
114
+
115
+ - **Content-Type**: Not defined
116
+ - **Accept**: application/json
117
+
118
+
119
+
120
+ # **get_product**
121
+ > Product get_product(id)
122
+
123
+
124
+
125
+ Return a product
126
+
127
+ ### Example
128
+ ```ruby
129
+ # load the gem
130
+ require 'vantage-client'
131
+ # setup authorization
132
+ Vantage.configure do |config|
133
+ # Configure OAuth2 access token for authorization: oauth2
134
+ config.access_token = 'YOUR ACCESS TOKEN'
135
+ end
136
+
137
+ api_instance = Vantage::PricesApi.new
138
+
139
+ id = 'id_example' # String | Unique identifier of the product e.g. aws-ec2-m5d_16xlarge
140
+
141
+
142
+ begin
143
+ result = api_instance.get_product(id)
144
+ p result
145
+ rescue Vantage::ApiError => e
146
+ puts "Exception when calling PricesApi->get_product: #{e}"
147
+ end
148
+ ```
149
+
150
+ ### Parameters
151
+
152
+ Name | Type | Description | Notes
153
+ ------------- | ------------- | ------------- | -------------
154
+ **id** | **String**| Unique identifier of the product e.g. aws-ec2-m5d_16xlarge |
155
+
156
+ ### Return type
157
+
158
+ [**Product**](Product.md)
159
+
160
+ ### Authorization
161
+
162
+ [oauth2](../README.md#oauth2)
163
+
164
+ ### HTTP request headers
165
+
166
+ - **Content-Type**: Not defined
167
+ - **Accept**: application/json
168
+
169
+
170
+
171
+ # **get_products**
172
+ > Products get_products(opts)
173
+
174
+
175
+
176
+ Return available Products for a Service. For example, with a Provider of AWS and a Service of EC2, Products will be a list of all EC2 Instances. By default, this endpoint returns all Products across all Services and Providers but has optional query parameters for filtering listed below.
177
+
178
+ ### Example
179
+ ```ruby
180
+ # load the gem
181
+ require 'vantage-client'
182
+ # setup authorization
183
+ Vantage.configure do |config|
184
+ # Configure OAuth2 access token for authorization: oauth2
185
+ config.access_token = 'YOUR ACCESS TOKEN'
186
+ end
187
+
188
+ api_instance = Vantage::PricesApi.new
189
+
190
+ opts = {
191
+ provider_id: 'provider_id_example', # String | Query by Provider to list all Products across all Services for a Provider. e.g. aws
192
+ service_id: 'service_id_example', # String | Query by Service to list all Products for a specific provider service. e.g. aws-ec2
193
+ name: 'name_example' # String | Query by name of the Product to see a list of products which match that name. e.g. m5a.16xlarge
194
+ }
195
+
196
+ begin
197
+ result = api_instance.get_products(opts)
198
+ p result
199
+ rescue Vantage::ApiError => e
200
+ puts "Exception when calling PricesApi->get_products: #{e}"
201
+ end
202
+ ```
203
+
204
+ ### Parameters
205
+
206
+ Name | Type | Description | Notes
207
+ ------------- | ------------- | ------------- | -------------
208
+ **provider_id** | **String**| Query by Provider to list all Products across all Services for a Provider. e.g. aws | [optional]
209
+ **service_id** | **String**| Query by Service to list all Products for a specific provider service. e.g. aws-ec2 | [optional]
210
+ **name** | **String**| Query by name of the Product to see a list of products which match that name. e.g. m5a.16xlarge | [optional]
211
+
212
+ ### Return type
213
+
214
+ [**Products**](Products.md)
215
+
216
+ ### Authorization
217
+
218
+ [oauth2](../README.md#oauth2)
219
+
220
+ ### HTTP request headers
221
+
222
+ - **Content-Type**: Not defined
223
+ - **Accept**: application/json
224
+
225
+
226
+
227
+ # **get_providers**
228
+ > Providers get_providers
229
+
230
+
231
+
232
+ Providers are cloud infrastructure and service providers from which all cloud prices are derived. You can think of example Providers as being AWS, GCP, Cloudflare or Datadog. Currently, Vantage only supports a single provider of AWS but over time more will be added. Use this endpoint to retrieve a provider id for other API calls.
233
+
234
+ ### Example
235
+ ```ruby
236
+ # load the gem
237
+ require 'vantage-client'
238
+ # setup authorization
239
+ Vantage.configure do |config|
240
+ # Configure OAuth2 access token for authorization: oauth2
241
+ config.access_token = 'YOUR ACCESS TOKEN'
242
+ end
243
+
244
+ api_instance = Vantage::PricesApi.new
245
+
246
+ begin
247
+ result = api_instance.get_providers
248
+ p result
249
+ rescue Vantage::ApiError => e
250
+ puts "Exception when calling PricesApi->get_providers: #{e}"
251
+ end
252
+ ```
253
+
254
+ ### Parameters
255
+ This endpoint does not need any parameter.
256
+
257
+ ### Return type
258
+
259
+ [**Providers**](Providers.md)
260
+
261
+ ### Authorization
262
+
263
+ [oauth2](../README.md#oauth2)
264
+
265
+ ### HTTP request headers
266
+
267
+ - **Content-Type**: Not defined
268
+ - **Accept**: application/json
269
+
270
+
271
+
272
+ # **get_services**
273
+ > Services get_services(opts)
274
+
275
+
276
+
277
+ Return all Services. Examples of Services are EC2 for AWS. This endpoint will return all Services by default but you have the ability to filter Services by Provider using the optional query parameter documented below.
278
+
279
+ ### Example
280
+ ```ruby
281
+ # load the gem
282
+ require 'vantage-client'
283
+ # setup authorization
284
+ Vantage.configure do |config|
285
+ # Configure OAuth2 access token for authorization: oauth2
286
+ config.access_token = 'YOUR ACCESS TOKEN'
287
+ end
288
+
289
+ api_instance = Vantage::PricesApi.new
290
+
291
+ opts = {
292
+ provider_id: 'provider_id_example' # String | Query services for a specific provider. e.g. aws
293
+ }
294
+
295
+ begin
296
+ result = api_instance.get_services(opts)
297
+ p result
298
+ rescue Vantage::ApiError => e
299
+ puts "Exception when calling PricesApi->get_services: #{e}"
300
+ end
301
+ ```
302
+
303
+ ### Parameters
304
+
305
+ Name | Type | Description | Notes
306
+ ------------- | ------------- | ------------- | -------------
307
+ **provider_id** | **String**| Query services for a specific provider. e.g. aws | [optional]
308
+
309
+ ### Return type
310
+
311
+ [**Services**](Services.md)
312
+
313
+ ### Authorization
314
+
315
+ [oauth2](../README.md#oauth2)
316
+
317
+ ### HTTP request headers
318
+
319
+ - **Content-Type**: Not defined
320
+ - **Accept**: application/json
321
+
322
+
323
+
data/docs/Product.md ADDED
@@ -0,0 +1,12 @@
1
+ # Vantage::Product
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **id** | **String** | | [optional]
7
+ **category** | **String** | The category of the cloud product | [optional]
8
+ **name** | **String** | The common name of the product. | [optional]
9
+ **service_id** | **String** | A unique slug for the service the product belongs to. | [optional]
10
+ **provider_id** | **String** | A unique slug for the provider the product belongs to. | [optional]
11
+
12
+
data/docs/Products.md ADDED
@@ -0,0 +1,9 @@
1
+ # Vantage::Products
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **links** | **Object** | | [optional]
7
+ **products** | [**Array<Product>**](Product.md) | | [optional]
8
+
9
+
data/docs/Provider.md ADDED
@@ -0,0 +1,10 @@
1
+ # Vantage::Provider
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **id** | **String** | | [optional]
7
+ **name** | **String** | The common name of the provider. | [optional]
8
+ **description** | **String** | The full descriptive name of the provider. | [optional]
9
+
10
+
data/docs/Providers.md ADDED
@@ -0,0 +1,9 @@
1
+ # Vantage::Providers
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **links** | **Object** | | [optional]
7
+ **providers** | [**Array<Provider>**](Provider.md) | | [optional]
8
+
9
+
data/docs/Service.md ADDED
@@ -0,0 +1,11 @@
1
+ # Vantage::Service
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **id** | **String** | | [optional]
7
+ **category** | **String** | The type of cloud service. | [optional]
8
+ **name** | **String** | The common name of the service. Usually an abbreviation. | [optional]
9
+ **description** | **String** | The full name of the service. | [optional]
10
+
11
+
data/docs/Services.md ADDED
@@ -0,0 +1,9 @@
1
+ # Vantage::Services
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **links** | **Object** | | [optional]
7
+ **services** | [**Array<Service>**](Service.md) | | [optional]
8
+
9
+
data/git_push.sh ADDED
@@ -0,0 +1,55 @@
1
+ #!/bin/sh
2
+ #
3
+ # Generated by: https://github.com/swagger-api/swagger-codegen.git
4
+ #
5
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
6
+ #
7
+ # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
8
+
9
+ git_user_id=$1
10
+ git_repo_id=$2
11
+ release_note=$3
12
+
13
+ if [ "$git_user_id" = "" ]; then
14
+ git_user_id=""
15
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
16
+ fi
17
+
18
+ if [ "$git_repo_id" = "" ]; then
19
+ git_repo_id=""
20
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
21
+ fi
22
+
23
+ if [ "$release_note" = "" ]; then
24
+ release_note=""
25
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
26
+ fi
27
+
28
+ # Initialize the local directory as a Git repository
29
+ git init
30
+
31
+ # Adds the files in the local repository and stages them for commit.
32
+ git add .
33
+
34
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
35
+ git commit -m "$release_note"
36
+
37
+ # Sets the new remote
38
+ git_remote=`git remote`
39
+ if [ "$git_remote" = "" ]; then # git remote not defined
40
+
41
+ if [ "$GIT_TOKEN" = "" ]; then
42
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
43
+ git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
44
+ else
45
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
46
+ fi
47
+
48
+ fi
49
+
50
+ git pull origin master
51
+
52
+ # Pushes (Forces) the changes in the local repository up to the remote repository
53
+ echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
54
+ git push origin master 2>&1 | grep -v 'To https'
55
+