license_manager 0.1.0
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/CHANGELOG.md +5 -0
- data/Gemfile +9 -0
- data/LICENSE +201 -0
- data/README.md +96 -0
- data/Rakefile +10 -0
- data/docs/ConnectStripe.md +18 -0
- data/docs/CreateCustomer.md +20 -0
- data/docs/CreateIntegrationMapping.md +20 -0
- data/docs/CreateLicense.md +36 -0
- data/docs/CreatePolicy.md +30 -0
- data/docs/CreatePortalLink.md +18 -0
- data/docs/CreateProduct.md +20 -0
- data/docs/CreateProductWithPolicy.md +24 -0
- data/docs/CreateRelease.md +20 -0
- data/docs/CreateToken.md +20 -0
- data/docs/Customer.md +30 -0
- data/docs/CustomerList.md +20 -0
- data/docs/CustomersApi.md +385 -0
- data/docs/Error.md +18 -0
- data/docs/ErrorError.md +22 -0
- data/docs/ErrorErrorIssuesInner.md +20 -0
- data/docs/ErrorErrorIssuesInnerPathInner.md +15 -0
- data/docs/Event.md +34 -0
- data/docs/EventActor.md +55 -0
- data/docs/EventActorOneOf.md +26 -0
- data/docs/EventActorOneOf1.md +24 -0
- data/docs/EventActorOneOf2.md +22 -0
- data/docs/EventActorOneOf3.md +18 -0
- data/docs/EventActorOneOf4.md +22 -0
- data/docs/EventList.md +20 -0
- data/docs/EventMachine.md +22 -0
- data/docs/EventType.md +15 -0
- data/docs/EventsApi.md +173 -0
- data/docs/FixedMaxVersion.md +20 -0
- data/docs/Integration.md +38 -0
- data/docs/IntegrationMapping.md +38 -0
- data/docs/IntegrationStatus.md +15 -0
- data/docs/IntegrationsApi.md +587 -0
- data/docs/License.md +50 -0
- data/docs/LicenseList.md +20 -0
- data/docs/LicenseMaxVersion.md +22 -0
- data/docs/LicenseMaxVersionInput.md +22 -0
- data/docs/LicenseStats.md +26 -0
- data/docs/LicenseStatsActivationsByMachineInner.md +24 -0
- data/docs/LicenseStatsActivationsByVersionInner.md +20 -0
- data/docs/LicenseStatus.md +15 -0
- data/docs/LicenseToken.md +18 -0
- data/docs/LicensesApi.md +817 -0
- data/docs/ListPolicyEventsTypeParameter.md +15 -0
- data/docs/ListStripePrices200Response.md +18 -0
- data/docs/LockMaxVersion.md +22 -0
- data/docs/LockMaxVersionMajorAfter.md +49 -0
- data/docs/LockMaxVersionMajorAfterOneOf.md +20 -0
- data/docs/LockMaxVersionMajorAfterOneOf1.md +20 -0
- data/docs/LockMaxVersionMinorAfter.md +20 -0
- data/docs/Machine.md +36 -0
- data/docs/MachineList.md +20 -0
- data/docs/MachinesApi.md +246 -0
- data/docs/Pagination.md +24 -0
- data/docs/PoliciesApi.md +388 -0
- data/docs/Policy.md +40 -0
- data/docs/PolicyDuration.md +20 -0
- data/docs/PolicyList.md +20 -0
- data/docs/PolicyMaxVersion.md +24 -0
- data/docs/PolicySettings.md +24 -0
- data/docs/PolicySettingsDuration.md +20 -0
- data/docs/PolicySettingsDurationAnyOf.md +20 -0
- data/docs/PolicySettingsDurationAnyOf1.md +20 -0
- data/docs/PolicySettingsMaxVersion.md +24 -0
- data/docs/Portal.md +30 -0
- data/docs/PortalApi.md +289 -0
- data/docs/PortalLink.md +22 -0
- data/docs/PortalNotFound.md +22 -0
- data/docs/PortalSettings.md +26 -0
- data/docs/Price.md +20 -0
- data/docs/PriceInput.md +20 -0
- data/docs/Product.md +32 -0
- data/docs/ProductList.md +20 -0
- data/docs/ProductStats.md +54 -0
- data/docs/ProductStatsActivationsByVersionInner.md +20 -0
- data/docs/ProductStatsActiveMachinesByPlatformInner.md +20 -0
- data/docs/ProductStatsActiveMachinesByVersionInner.md +20 -0
- data/docs/ProductStatsNewLicensesByPolicyInner.md +22 -0
- data/docs/ProductsApi.md +666 -0
- data/docs/Release.md +28 -0
- data/docs/ReleaseList.md +20 -0
- data/docs/ReleasesApi.md +388 -0
- data/docs/RequestPortalLink.md +20 -0
- data/docs/Revenue.md +34 -0
- data/docs/SendLicenseKeys.md +18 -0
- data/docs/SendPortalLink.md +18 -0
- data/docs/SigningKey.md +27 -0
- data/docs/StripeIntegration.md +26 -0
- data/docs/StripePermission.md +22 -0
- data/docs/StripePrice.md +28 -0
- data/docs/Token.md +24 -0
- data/docs/TokensApi.md +235 -0
- data/docs/UpdateCustomer.md +20 -0
- data/docs/UpdateIntegrationMapping.md +18 -0
- data/docs/UpdateLicense.md +28 -0
- data/docs/UpdatePolicy.md +30 -0
- data/docs/UpdateProduct.md +22 -0
- data/docs/UpdateProductPortal.md +26 -0
- data/docs/UpdateRelease.md +20 -0
- data/docs/ValidateKey.md +26 -0
- data/docs/ValidateKeyError.md +18 -0
- data/docs/ValidateKeyErrorError.md +24 -0
- data/git_push.sh +54 -0
- data/lib/license_manager/api/customers_api.rb +398 -0
- data/lib/license_manager/api/events_api.rb +207 -0
- data/lib/license_manager/api/integrations_api.rb +559 -0
- data/lib/license_manager/api/licenses_api.rb +885 -0
- data/lib/license_manager/api/machines_api.rb +257 -0
- data/lib/license_manager/api/policies_api.rb +412 -0
- data/lib/license_manager/api/portal_api.rb +310 -0
- data/lib/license_manager/api/products_api.rb +653 -0
- data/lib/license_manager/api/releases_api.rb +408 -0
- data/lib/license_manager/api/tokens_api.rb +244 -0
- data/lib/license_manager/api_client.rb +441 -0
- data/lib/license_manager/api_error.rb +58 -0
- data/lib/license_manager/api_model_base.rb +88 -0
- data/lib/license_manager/configuration.rb +400 -0
- data/lib/license_manager/models/connect_stripe.rb +187 -0
- data/lib/license_manager/models/create_customer.rb +222 -0
- data/lib/license_manager/models/create_integration_mapping.rb +222 -0
- data/lib/license_manager/models/create_license.rb +361 -0
- data/lib/license_manager/models/create_policy.rb +347 -0
- data/lib/license_manager/models/create_portal_link.rb +196 -0
- data/lib/license_manager/models/create_product.rb +244 -0
- data/lib/license_manager/models/create_product_with_policy.rb +270 -0
- data/lib/license_manager/models/create_release.rb +208 -0
- data/lib/license_manager/models/create_token.rb +237 -0
- data/lib/license_manager/models/customer.rb +308 -0
- data/lib/license_manager/models/customer_list.rb +206 -0
- data/lib/license_manager/models/error.rb +177 -0
- data/lib/license_manager/models/error_error.rb +215 -0
- data/lib/license_manager/models/error_error_issues_inner.rb +205 -0
- data/lib/license_manager/models/error_error_issues_inner_path_inner.rb +103 -0
- data/lib/license_manager/models/event.rb +340 -0
- data/lib/license_manager/models/event_actor.rb +108 -0
- data/lib/license_manager/models/event_actor_one_of.rb +251 -0
- data/lib/license_manager/models/event_actor_one_of1.rb +239 -0
- data/lib/license_manager/models/event_actor_one_of2.rb +257 -0
- data/lib/license_manager/models/event_actor_one_of3.rb +201 -0
- data/lib/license_manager/models/event_actor_one_of4.rb +243 -0
- data/lib/license_manager/models/event_list.rb +206 -0
- data/lib/license_manager/models/event_machine.rb +216 -0
- data/lib/license_manager/models/event_type.rb +46 -0
- data/lib/license_manager/models/fixed_max_version.rb +240 -0
- data/lib/license_manager/models/integration.rb +412 -0
- data/lib/license_manager/models/integration_mapping.rb +435 -0
- data/lib/license_manager/models/integration_status.rb +42 -0
- data/lib/license_manager/models/license.rb +542 -0
- data/lib/license_manager/models/license_list.rb +206 -0
- data/lib/license_manager/models/license_max_version.rb +208 -0
- data/lib/license_manager/models/license_max_version_input.rb +202 -0
- data/lib/license_manager/models/license_stats.rb +292 -0
- data/lib/license_manager/models/license_stats_activations_by_machine_inner.rb +244 -0
- data/lib/license_manager/models/license_stats_activations_by_version_inner.rb +206 -0
- data/lib/license_manager/models/license_status.rb +42 -0
- data/lib/license_manager/models/license_token.rb +178 -0
- data/lib/license_manager/models/list_policy_events_type_parameter.rb +104 -0
- data/lib/license_manager/models/list_stripe_prices200_response.rb +179 -0
- data/lib/license_manager/models/lock_max_version.rb +240 -0
- data/lib/license_manager/models/lock_max_version_major_after.rb +105 -0
- data/lib/license_manager/models/lock_max_version_major_after_one_of.rb +245 -0
- data/lib/license_manager/models/lock_max_version_major_after_one_of1.rb +246 -0
- data/lib/license_manager/models/lock_max_version_minor_after.rb +104 -0
- data/lib/license_manager/models/machine.rb +383 -0
- data/lib/license_manager/models/machine_list.rb +206 -0
- data/lib/license_manager/models/pagination.rb +260 -0
- data/lib/license_manager/models/policy.rb +425 -0
- data/lib/license_manager/models/policy_duration.rb +104 -0
- data/lib/license_manager/models/policy_list.rb +206 -0
- data/lib/license_manager/models/policy_max_version.rb +104 -0
- data/lib/license_manager/models/policy_settings.rb +244 -0
- data/lib/license_manager/models/policy_settings_duration.rb +104 -0
- data/lib/license_manager/models/policy_settings_duration_any_of.rb +245 -0
- data/lib/license_manager/models/policy_settings_duration_any_of1.rb +246 -0
- data/lib/license_manager/models/policy_settings_max_version.rb +104 -0
- data/lib/license_manager/models/portal.rb +281 -0
- data/lib/license_manager/models/portal_link.rb +232 -0
- data/lib/license_manager/models/portal_not_found.rb +204 -0
- data/lib/license_manager/models/portal_settings.rb +304 -0
- data/lib/license_manager/models/price.rb +206 -0
- data/lib/license_manager/models/price_input.rb +224 -0
- data/lib/license_manager/models/product.rb +333 -0
- data/lib/license_manager/models/product_list.rb +206 -0
- data/lib/license_manager/models/product_stats.rb +682 -0
- data/lib/license_manager/models/product_stats_activations_by_version_inner.rb +193 -0
- data/lib/license_manager/models/product_stats_active_machines_by_platform_inner.rb +190 -0
- data/lib/license_manager/models/product_stats_active_machines_by_version_inner.rb +190 -0
- data/lib/license_manager/models/product_stats_new_licenses_by_policy_inner.rb +235 -0
- data/lib/license_manager/models/release.rb +308 -0
- data/lib/license_manager/models/release_list.rb +206 -0
- data/lib/license_manager/models/request_portal_link.rb +216 -0
- data/lib/license_manager/models/revenue.rb +401 -0
- data/lib/license_manager/models/send_license_keys.rb +198 -0
- data/lib/license_manager/models/send_portal_link.rb +187 -0
- data/lib/license_manager/models/signing_key.rb +282 -0
- data/lib/license_manager/models/stripe_integration.rb +276 -0
- data/lib/license_manager/models/stripe_permission.rb +253 -0
- data/lib/license_manager/models/stripe_price.rb +280 -0
- data/lib/license_manager/models/token.rb +274 -0
- data/lib/license_manager/models/update_customer.rb +215 -0
- data/lib/license_manager/models/update_integration_mapping.rb +186 -0
- data/lib/license_manager/models/update_license.rb +268 -0
- data/lib/license_manager/models/update_policy.rb +340 -0
- data/lib/license_manager/models/update_product.rb +246 -0
- data/lib/license_manager/models/update_product_portal.rb +274 -0
- data/lib/license_manager/models/update_release.rb +201 -0
- data/lib/license_manager/models/validate_key.rb +362 -0
- data/lib/license_manager/models/validate_key_error.rb +177 -0
- data/lib/license_manager/models/validate_key_error_error.rb +226 -0
- data/lib/license_manager/version.rb +15 -0
- data/lib/license_manager.rb +142 -0
- data/license_manager.gemspec +41 -0
- data/openapi.json +9825 -0
- data/spec/api/customers_api_spec.rb +102 -0
- data/spec/api/events_api_spec.rb +68 -0
- data/spec/api/integrations_api_spec.rb +134 -0
- data/spec/api/licenses_api_spec.rb +200 -0
- data/spec/api/machines_api_spec.rb +77 -0
- data/spec/api/policies_api_spec.rb +105 -0
- data/spec/api/portal_api_spec.rb +87 -0
- data/spec/api/products_api_spec.rb +148 -0
- data/spec/api/releases_api_spec.rb +105 -0
- data/spec/api/tokens_api_spec.rb +74 -0
- data/spec/models/connect_stripe_spec.rb +36 -0
- data/spec/models/create_customer_spec.rb +42 -0
- data/spec/models/create_integration_mapping_spec.rb +42 -0
- data/spec/models/create_license_spec.rb +90 -0
- data/spec/models/create_policy_spec.rb +72 -0
- data/spec/models/create_portal_link_spec.rb +36 -0
- data/spec/models/create_product_spec.rb +42 -0
- data/spec/models/create_product_with_policy_spec.rb +54 -0
- data/spec/models/create_release_spec.rb +42 -0
- data/spec/models/create_token_spec.rb +46 -0
- data/spec/models/customer_list_spec.rb +42 -0
- data/spec/models/customer_spec.rb +72 -0
- data/spec/models/error_error_issues_inner_path_inner_spec.rb +21 -0
- data/spec/models/error_error_issues_inner_spec.rb +42 -0
- data/spec/models/error_error_spec.rb +48 -0
- data/spec/models/error_spec.rb +36 -0
- data/spec/models/event_actor_one_of1_spec.rb +58 -0
- data/spec/models/event_actor_one_of2_spec.rb +56 -0
- data/spec/models/event_actor_one_of3_spec.rb +40 -0
- data/spec/models/event_actor_one_of4_spec.rb +56 -0
- data/spec/models/event_actor_one_of_spec.rb +64 -0
- data/spec/models/event_actor_spec.rb +32 -0
- data/spec/models/event_list_spec.rb +42 -0
- data/spec/models/event_machine_spec.rb +48 -0
- data/spec/models/event_spec.rb +84 -0
- data/spec/models/event_type_spec.rb +30 -0
- data/spec/models/fixed_max_version_spec.rb +46 -0
- data/spec/models/integration_mapping_spec.rb +100 -0
- data/spec/models/integration_spec.rb +100 -0
- data/spec/models/integration_status_spec.rb +30 -0
- data/spec/models/license_list_spec.rb +42 -0
- data/spec/models/license_max_version_input_spec.rb +48 -0
- data/spec/models/license_max_version_spec.rb +48 -0
- data/spec/models/license_spec.rb +132 -0
- data/spec/models/license_stats_activations_by_machine_inner_spec.rb +54 -0
- data/spec/models/license_stats_activations_by_version_inner_spec.rb +42 -0
- data/spec/models/license_stats_spec.rb +60 -0
- data/spec/models/license_status_spec.rb +30 -0
- data/spec/models/license_token_spec.rb +36 -0
- data/spec/models/list_policy_events_type_parameter_spec.rb +21 -0
- data/spec/models/list_stripe_prices200_response_spec.rb +36 -0
- data/spec/models/lock_max_version_major_after_one_of1_spec.rb +46 -0
- data/spec/models/lock_max_version_major_after_one_of_spec.rb +46 -0
- data/spec/models/lock_max_version_major_after_spec.rb +32 -0
- data/spec/models/lock_max_version_minor_after_spec.rb +21 -0
- data/spec/models/lock_max_version_spec.rb +52 -0
- data/spec/models/machine_list_spec.rb +42 -0
- data/spec/models/machine_spec.rb +94 -0
- data/spec/models/pagination_spec.rb +54 -0
- data/spec/models/policy_duration_spec.rb +21 -0
- data/spec/models/policy_list_spec.rb +42 -0
- data/spec/models/policy_max_version_spec.rb +21 -0
- data/spec/models/policy_settings_duration_any_of1_spec.rb +46 -0
- data/spec/models/policy_settings_duration_any_of_spec.rb +46 -0
- data/spec/models/policy_settings_duration_spec.rb +21 -0
- data/spec/models/policy_settings_max_version_spec.rb +21 -0
- data/spec/models/policy_settings_spec.rb +54 -0
- data/spec/models/policy_spec.rb +102 -0
- data/spec/models/portal_link_spec.rb +48 -0
- data/spec/models/portal_not_found_spec.rb +48 -0
- data/spec/models/portal_settings_spec.rb +60 -0
- data/spec/models/portal_spec.rb +72 -0
- data/spec/models/price_input_spec.rb +42 -0
- data/spec/models/price_spec.rb +42 -0
- data/spec/models/product_list_spec.rb +42 -0
- data/spec/models/product_spec.rb +78 -0
- data/spec/models/product_stats_activations_by_version_inner_spec.rb +42 -0
- data/spec/models/product_stats_active_machines_by_platform_inner_spec.rb +42 -0
- data/spec/models/product_stats_active_machines_by_version_inner_spec.rb +42 -0
- data/spec/models/product_stats_new_licenses_by_policy_inner_spec.rb +48 -0
- data/spec/models/product_stats_spec.rb +144 -0
- data/spec/models/release_list_spec.rb +42 -0
- data/spec/models/release_spec.rb +66 -0
- data/spec/models/request_portal_link_spec.rb +42 -0
- data/spec/models/revenue_spec.rb +84 -0
- data/spec/models/send_license_keys_spec.rb +36 -0
- data/spec/models/send_portal_link_spec.rb +36 -0
- data/spec/models/signing_key_spec.rb +58 -0
- data/spec/models/stripe_integration_spec.rb +60 -0
- data/spec/models/stripe_permission_spec.rb +52 -0
- data/spec/models/stripe_price_spec.rb +66 -0
- data/spec/models/token_spec.rb +62 -0
- data/spec/models/update_customer_spec.rb +42 -0
- data/spec/models/update_integration_mapping_spec.rb +36 -0
- data/spec/models/update_license_spec.rb +66 -0
- data/spec/models/update_policy_spec.rb +72 -0
- data/spec/models/update_product_portal_spec.rb +60 -0
- data/spec/models/update_product_spec.rb +48 -0
- data/spec/models/update_release_spec.rb +42 -0
- data/spec/models/validate_key_error_error_spec.rb +54 -0
- data/spec/models/validate_key_error_spec.rb +36 -0
- data/spec/models/validate_key_spec.rb +60 -0
- data/spec/spec_helper.rb +111 -0
- metadata +532 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#LicenseManager API
|
|
3
|
+
|
|
4
|
+
#Public API. Authenticate with an organization API key, or with a token scoped to a customer, license or machine on the endpoints that accept one. ## Conventions - **Errors** answer `{ \"error\": { \"code\", \"message\" } }`. Branch on `code`, which is stable, not on `message`. Each response lists the codes it can return, except `404`, which answers `not_found` unless it says otherwise. Unexpected errors answer `500` with `internal_error`. - **Validation** errors answer `422`, not `400`, with the `validation_error` code and an `issues` array giving the `path` and `message` of each invalid value. - **Unknown body fields are ignored**, not rejected: sending a field an endpoint doesn't accept, like `policyId` to `updateLicense`, changes nothing and doesn't fail. - **Strings** are trimmed before they're validated and stored. Emails are stored lower cased. - **Updates** only change the fields that are sent. A field sent as `null` is cleared, when it can be. - **Dates** can be sent with any offset, and are always returned in UTC, like `2026-01-15T09:30:00.000Z`. Calendar months and days are counted in UTC. - **Ids** are 8 letters and digits, after `test_` for test products and their resources. - **Lists** are paginated with `page` and `pageSize`. Items with the same value for the `sort` field are ordered by id, so pages are stable, but items created or deleted between two requests shift the pages. Items without a value for the `sort` field come last in ascending order, and first in descending order, unless the endpoint says otherwise. - **Test products** are sandboxes of a live product. Test API keys only reach test products, live API keys only live ones: the others answer `404`, as if they didn't exist. Sessions and tokens reach both.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.26.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module LicenseManager
|
|
17
|
+
class LockMaxVersionMajorAfterOneOf < ApiModelBase
|
|
18
|
+
attr_accessor :value
|
|
19
|
+
|
|
20
|
+
attr_accessor :unit
|
|
21
|
+
|
|
22
|
+
class EnumAttributeValidator
|
|
23
|
+
attr_reader :datatype
|
|
24
|
+
attr_reader :allowable_values
|
|
25
|
+
|
|
26
|
+
def initialize(datatype, allowable_values)
|
|
27
|
+
@allowable_values = allowable_values.map do |value|
|
|
28
|
+
case datatype.to_s
|
|
29
|
+
when /Integer/i
|
|
30
|
+
value.to_i
|
|
31
|
+
when /Float/i
|
|
32
|
+
value.to_f
|
|
33
|
+
else
|
|
34
|
+
value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def valid?(value)
|
|
40
|
+
!value || allowable_values.include?(value)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
45
|
+
def self.attribute_map
|
|
46
|
+
{
|
|
47
|
+
:'value' => :'value',
|
|
48
|
+
:'unit' => :'unit'
|
|
49
|
+
}
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Returns attribute mapping this model knows about
|
|
53
|
+
def self.acceptable_attribute_map
|
|
54
|
+
attribute_map
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Returns all the JSON keys this model knows about
|
|
58
|
+
def self.acceptable_attributes
|
|
59
|
+
acceptable_attribute_map.values
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Attribute type mapping.
|
|
63
|
+
def self.openapi_types
|
|
64
|
+
{
|
|
65
|
+
:'value' => :'Integer',
|
|
66
|
+
:'unit' => :'String'
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# List of attributes with nullable: true
|
|
71
|
+
def self.openapi_nullable
|
|
72
|
+
Set.new([
|
|
73
|
+
])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Returns attribute type mapping
|
|
77
|
+
def self.acceptable_openapi_types
|
|
78
|
+
openapi_types
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Returns the nullable attributes
|
|
82
|
+
def self.acceptable_openapi_nullable
|
|
83
|
+
openapi_nullable
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Initializes the object
|
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
88
|
+
def initialize(attributes = {})
|
|
89
|
+
if (!attributes.is_a?(Hash))
|
|
90
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `LicenseManager::LockMaxVersionMajorAfterOneOf` initialize method"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
94
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
95
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
96
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
97
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `LicenseManager::LockMaxVersionMajorAfterOneOf`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
98
|
+
end
|
|
99
|
+
h[k.to_sym] = v
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if attributes.key?(:'value')
|
|
103
|
+
self.value = attributes[:'value']
|
|
104
|
+
else
|
|
105
|
+
self.value = nil
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
if attributes.key?(:'unit')
|
|
109
|
+
self.unit = attributes[:'unit']
|
|
110
|
+
else
|
|
111
|
+
self.unit = nil
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
116
|
+
# @return Array for valid properties with the reasons
|
|
117
|
+
def list_invalid_properties
|
|
118
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
119
|
+
invalid_properties = Array.new
|
|
120
|
+
if @value.nil?
|
|
121
|
+
invalid_properties.push('invalid value for "value", value cannot be nil.')
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
if @value > 2147483647
|
|
125
|
+
invalid_properties.push('invalid value for "value", must be smaller than or equal to 2147483647.')
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
if @value < 0
|
|
129
|
+
invalid_properties.push('invalid value for "value", must be greater than or equal to 0.')
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
if @unit.nil?
|
|
133
|
+
invalid_properties.push('invalid value for "unit", unit cannot be nil.')
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
invalid_properties
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Check to see if the all the properties in the model are valid
|
|
140
|
+
# @return true if the model is valid
|
|
141
|
+
def valid?
|
|
142
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
143
|
+
return false if @value.nil?
|
|
144
|
+
return false if @value > 2147483647
|
|
145
|
+
return false if @value < 0
|
|
146
|
+
return false if @unit.nil?
|
|
147
|
+
unit_validator = EnumAttributeValidator.new('String', ["seconds", "unknown_default_open_api"])
|
|
148
|
+
return false unless unit_validator.valid?(@unit)
|
|
149
|
+
true
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Custom attribute writer method with validation
|
|
153
|
+
# @param [Object] value Value to be assigned
|
|
154
|
+
def value=(value)
|
|
155
|
+
if value.nil?
|
|
156
|
+
fail ArgumentError, 'value cannot be nil'
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
if value > 2147483647
|
|
160
|
+
fail ArgumentError, 'invalid value for "value", must be smaller than or equal to 2147483647.'
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
if value < 0
|
|
164
|
+
fail ArgumentError, 'invalid value for "value", must be greater than or equal to 0.'
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
@value = value
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
171
|
+
# @param [Object] unit Object to be assigned
|
|
172
|
+
def unit=(unit)
|
|
173
|
+
validator = EnumAttributeValidator.new('String', ["seconds", "unknown_default_open_api"])
|
|
174
|
+
unless validator.valid?(unit)
|
|
175
|
+
fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}."
|
|
176
|
+
end
|
|
177
|
+
@unit = unit
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Checks equality by comparing each attribute.
|
|
181
|
+
# @param [Object] Object to be compared
|
|
182
|
+
def ==(o)
|
|
183
|
+
return true if self.equal?(o)
|
|
184
|
+
self.class == o.class &&
|
|
185
|
+
value == o.value &&
|
|
186
|
+
unit == o.unit
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# @see the `==` method
|
|
190
|
+
# @param [Object] Object to be compared
|
|
191
|
+
def eql?(o)
|
|
192
|
+
self == o
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Calculates hash code according to all attributes.
|
|
196
|
+
# @return [Integer] Hash code
|
|
197
|
+
def hash
|
|
198
|
+
[value, unit].hash
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Builds the object from hash
|
|
202
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
203
|
+
# @return [Object] Returns the model itself
|
|
204
|
+
def self.build_from_hash(attributes)
|
|
205
|
+
return nil unless attributes.is_a?(Hash)
|
|
206
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
207
|
+
# include attributes inherited from allOf parents (the nearest declaration wins)
|
|
208
|
+
map = acceptable_attribute_map
|
|
209
|
+
transformed_hash = {}
|
|
210
|
+
acceptable_openapi_types.each_pair do |key, type|
|
|
211
|
+
if attributes.key?(map[key]) && attributes[map[key]].nil?
|
|
212
|
+
transformed_hash["#{key}"] = nil
|
|
213
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
214
|
+
# check to ensure the input is an array given that the attribute
|
|
215
|
+
# is documented as an array but the input is not
|
|
216
|
+
if attributes[map[key]].is_a?(Array)
|
|
217
|
+
transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) }
|
|
218
|
+
end
|
|
219
|
+
elsif !attributes[map[key]].nil?
|
|
220
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]])
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
new(transformed_hash)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Returns the object in the form of hash
|
|
227
|
+
# @return [Hash] Returns the object in the form of hash
|
|
228
|
+
def to_hash
|
|
229
|
+
hash = {}
|
|
230
|
+
# include attributes inherited from allOf parents (the nearest declaration wins)
|
|
231
|
+
self.class.acceptable_attribute_map.each_pair do |attr, param|
|
|
232
|
+
value = self.send(attr)
|
|
233
|
+
if value.nil?
|
|
234
|
+
is_nullable = self.class.acceptable_openapi_nullable.include?(attr)
|
|
235
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
hash[param] = _to_hash(value)
|
|
239
|
+
end
|
|
240
|
+
hash
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
end
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#LicenseManager API
|
|
3
|
+
|
|
4
|
+
#Public API. Authenticate with an organization API key, or with a token scoped to a customer, license or machine on the endpoints that accept one. ## Conventions - **Errors** answer `{ \"error\": { \"code\", \"message\" } }`. Branch on `code`, which is stable, not on `message`. Each response lists the codes it can return, except `404`, which answers `not_found` unless it says otherwise. Unexpected errors answer `500` with `internal_error`. - **Validation** errors answer `422`, not `400`, with the `validation_error` code and an `issues` array giving the `path` and `message` of each invalid value. - **Unknown body fields are ignored**, not rejected: sending a field an endpoint doesn't accept, like `policyId` to `updateLicense`, changes nothing and doesn't fail. - **Strings** are trimmed before they're validated and stored. Emails are stored lower cased. - **Updates** only change the fields that are sent. A field sent as `null` is cleared, when it can be. - **Dates** can be sent with any offset, and are always returned in UTC, like `2026-01-15T09:30:00.000Z`. Calendar months and days are counted in UTC. - **Ids** are 8 letters and digits, after `test_` for test products and their resources. - **Lists** are paginated with `page` and `pageSize`. Items with the same value for the `sort` field are ordered by id, so pages are stable, but items created or deleted between two requests shift the pages. Items without a value for the `sort` field come last in ascending order, and first in descending order, unless the endpoint says otherwise. - **Test products** are sandboxes of a live product. Test API keys only reach test products, live API keys only live ones: the others answer `404`, as if they didn't exist. Sessions and tokens reach both.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.26.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module LicenseManager
|
|
17
|
+
class LockMaxVersionMajorAfterOneOf1 < ApiModelBase
|
|
18
|
+
attr_accessor :value
|
|
19
|
+
|
|
20
|
+
# Calendar months: a license created on January 31 with a 1 month duration expires on the last day of February.
|
|
21
|
+
attr_accessor :unit
|
|
22
|
+
|
|
23
|
+
class EnumAttributeValidator
|
|
24
|
+
attr_reader :datatype
|
|
25
|
+
attr_reader :allowable_values
|
|
26
|
+
|
|
27
|
+
def initialize(datatype, allowable_values)
|
|
28
|
+
@allowable_values = allowable_values.map do |value|
|
|
29
|
+
case datatype.to_s
|
|
30
|
+
when /Integer/i
|
|
31
|
+
value.to_i
|
|
32
|
+
when /Float/i
|
|
33
|
+
value.to_f
|
|
34
|
+
else
|
|
35
|
+
value
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def valid?(value)
|
|
41
|
+
!value || allowable_values.include?(value)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
46
|
+
def self.attribute_map
|
|
47
|
+
{
|
|
48
|
+
:'value' => :'value',
|
|
49
|
+
:'unit' => :'unit'
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns attribute mapping this model knows about
|
|
54
|
+
def self.acceptable_attribute_map
|
|
55
|
+
attribute_map
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns all the JSON keys this model knows about
|
|
59
|
+
def self.acceptable_attributes
|
|
60
|
+
acceptable_attribute_map.values
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Attribute type mapping.
|
|
64
|
+
def self.openapi_types
|
|
65
|
+
{
|
|
66
|
+
:'value' => :'Integer',
|
|
67
|
+
:'unit' => :'String'
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# List of attributes with nullable: true
|
|
72
|
+
def self.openapi_nullable
|
|
73
|
+
Set.new([
|
|
74
|
+
])
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Returns attribute type mapping
|
|
78
|
+
def self.acceptable_openapi_types
|
|
79
|
+
openapi_types
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Returns the nullable attributes
|
|
83
|
+
def self.acceptable_openapi_nullable
|
|
84
|
+
openapi_nullable
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Initializes the object
|
|
88
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
89
|
+
def initialize(attributes = {})
|
|
90
|
+
if (!attributes.is_a?(Hash))
|
|
91
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `LicenseManager::LockMaxVersionMajorAfterOneOf1` initialize method"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
95
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
96
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
97
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
98
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `LicenseManager::LockMaxVersionMajorAfterOneOf1`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
99
|
+
end
|
|
100
|
+
h[k.to_sym] = v
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if attributes.key?(:'value')
|
|
104
|
+
self.value = attributes[:'value']
|
|
105
|
+
else
|
|
106
|
+
self.value = nil
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'unit')
|
|
110
|
+
self.unit = attributes[:'unit']
|
|
111
|
+
else
|
|
112
|
+
self.unit = nil
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
117
|
+
# @return Array for valid properties with the reasons
|
|
118
|
+
def list_invalid_properties
|
|
119
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
120
|
+
invalid_properties = Array.new
|
|
121
|
+
if @value.nil?
|
|
122
|
+
invalid_properties.push('invalid value for "value", value cannot be nil.')
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
if @value > 12000
|
|
126
|
+
invalid_properties.push('invalid value for "value", must be smaller than or equal to 12000.')
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
if @value < 0
|
|
130
|
+
invalid_properties.push('invalid value for "value", must be greater than or equal to 0.')
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
if @unit.nil?
|
|
134
|
+
invalid_properties.push('invalid value for "unit", unit cannot be nil.')
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
invalid_properties
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Check to see if the all the properties in the model are valid
|
|
141
|
+
# @return true if the model is valid
|
|
142
|
+
def valid?
|
|
143
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
144
|
+
return false if @value.nil?
|
|
145
|
+
return false if @value > 12000
|
|
146
|
+
return false if @value < 0
|
|
147
|
+
return false if @unit.nil?
|
|
148
|
+
unit_validator = EnumAttributeValidator.new('String', ["months", "unknown_default_open_api"])
|
|
149
|
+
return false unless unit_validator.valid?(@unit)
|
|
150
|
+
true
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Custom attribute writer method with validation
|
|
154
|
+
# @param [Object] value Value to be assigned
|
|
155
|
+
def value=(value)
|
|
156
|
+
if value.nil?
|
|
157
|
+
fail ArgumentError, 'value cannot be nil'
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
if value > 12000
|
|
161
|
+
fail ArgumentError, 'invalid value for "value", must be smaller than or equal to 12000.'
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
if value < 0
|
|
165
|
+
fail ArgumentError, 'invalid value for "value", must be greater than or equal to 0.'
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
@value = value
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
172
|
+
# @param [Object] unit Object to be assigned
|
|
173
|
+
def unit=(unit)
|
|
174
|
+
validator = EnumAttributeValidator.new('String', ["months", "unknown_default_open_api"])
|
|
175
|
+
unless validator.valid?(unit)
|
|
176
|
+
fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}."
|
|
177
|
+
end
|
|
178
|
+
@unit = unit
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Checks equality by comparing each attribute.
|
|
182
|
+
# @param [Object] Object to be compared
|
|
183
|
+
def ==(o)
|
|
184
|
+
return true if self.equal?(o)
|
|
185
|
+
self.class == o.class &&
|
|
186
|
+
value == o.value &&
|
|
187
|
+
unit == o.unit
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# @see the `==` method
|
|
191
|
+
# @param [Object] Object to be compared
|
|
192
|
+
def eql?(o)
|
|
193
|
+
self == o
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Calculates hash code according to all attributes.
|
|
197
|
+
# @return [Integer] Hash code
|
|
198
|
+
def hash
|
|
199
|
+
[value, unit].hash
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Builds the object from hash
|
|
203
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
204
|
+
# @return [Object] Returns the model itself
|
|
205
|
+
def self.build_from_hash(attributes)
|
|
206
|
+
return nil unless attributes.is_a?(Hash)
|
|
207
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
208
|
+
# include attributes inherited from allOf parents (the nearest declaration wins)
|
|
209
|
+
map = acceptable_attribute_map
|
|
210
|
+
transformed_hash = {}
|
|
211
|
+
acceptable_openapi_types.each_pair do |key, type|
|
|
212
|
+
if attributes.key?(map[key]) && attributes[map[key]].nil?
|
|
213
|
+
transformed_hash["#{key}"] = nil
|
|
214
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
215
|
+
# check to ensure the input is an array given that the attribute
|
|
216
|
+
# is documented as an array but the input is not
|
|
217
|
+
if attributes[map[key]].is_a?(Array)
|
|
218
|
+
transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) }
|
|
219
|
+
end
|
|
220
|
+
elsif !attributes[map[key]].nil?
|
|
221
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]])
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
new(transformed_hash)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Returns the object in the form of hash
|
|
228
|
+
# @return [Hash] Returns the object in the form of hash
|
|
229
|
+
def to_hash
|
|
230
|
+
hash = {}
|
|
231
|
+
# include attributes inherited from allOf parents (the nearest declaration wins)
|
|
232
|
+
self.class.acceptable_attribute_map.each_pair do |attr, param|
|
|
233
|
+
value = self.send(attr)
|
|
234
|
+
if value.nil?
|
|
235
|
+
is_nullable = self.class.acceptable_openapi_nullable.include?(attr)
|
|
236
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
hash[param] = _to_hash(value)
|
|
240
|
+
end
|
|
241
|
+
hash
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#LicenseManager API
|
|
3
|
+
|
|
4
|
+
#Public API. Authenticate with an organization API key, or with a token scoped to a customer, license or machine on the endpoints that accept one. ## Conventions - **Errors** answer `{ \"error\": { \"code\", \"message\" } }`. Branch on `code`, which is stable, not on `message`. Each response lists the codes it can return, except `404`, which answers `not_found` unless it says otherwise. Unexpected errors answer `500` with `internal_error`. - **Validation** errors answer `422`, not `400`, with the `validation_error` code and an `issues` array giving the `path` and `message` of each invalid value. - **Unknown body fields are ignored**, not rejected: sending a field an endpoint doesn't accept, like `policyId` to `updateLicense`, changes nothing and doesn't fail. - **Strings** are trimmed before they're validated and stored. Emails are stored lower cased. - **Updates** only change the fields that are sent. A field sent as `null` is cleared, when it can be. - **Dates** can be sent with any offset, and are always returned in UTC, like `2026-01-15T09:30:00.000Z`. Calendar months and days are counted in UTC. - **Ids** are 8 letters and digits, after `test_` for test products and their resources. - **Lists** are paginated with `page` and `pageSize`. Items with the same value for the `sort` field are ordered by id, so pages are stable, but items created or deleted between two requests shift the pages. Items without a value for the `sort` field come last in ascending order, and first in descending order, unless the endpoint says otherwise. - **Test products** are sandboxes of a live product. Test API keys only reach test products, live API keys only live ones: the others answer `404`, as if they didn't exist. Sessions and tokens reach both.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.26.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module LicenseManager
|
|
17
|
+
# Time after the creation of a license its minor version is locked, in seconds or calendar months: it then only gets the bug fixes of the minor version released by then. Never shorter than `majorAfter`, whatever the length of the months: 1 month is longer than 28 days but may be shorter than 31. `0` locks it when the license is created. `null` to never lock it.
|
|
18
|
+
module LockMaxVersionMinorAfter
|
|
19
|
+
class << self
|
|
20
|
+
# List of class defined in anyOf (OpenAPI v3)
|
|
21
|
+
def openapi_any_of
|
|
22
|
+
[
|
|
23
|
+
:'LockMaxVersionMajorAfterOneOf',
|
|
24
|
+
:'LockMaxVersionMajorAfterOneOf1'
|
|
25
|
+
]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Builds the object
|
|
29
|
+
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
30
|
+
# @return [Object] Returns the model or the data itself
|
|
31
|
+
def build(data)
|
|
32
|
+
# Go through the list of anyOf items and attempt to identify the appropriate one.
|
|
33
|
+
# Note:
|
|
34
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
35
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
36
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
37
|
+
# - TODO: logging when debugging is set.
|
|
38
|
+
openapi_any_of.each do |klass|
|
|
39
|
+
begin
|
|
40
|
+
next if klass == :AnyType # "nullable: true"
|
|
41
|
+
return find_and_cast_into_type(klass, data)
|
|
42
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
openapi_any_of.include?(:AnyType) ? data : nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
52
|
+
|
|
53
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
54
|
+
def find_and_cast_into_type(klass, data)
|
|
55
|
+
return if data.nil?
|
|
56
|
+
|
|
57
|
+
case klass.to_s
|
|
58
|
+
when 'Boolean'
|
|
59
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
60
|
+
when 'Float'
|
|
61
|
+
return data if data.instance_of?(Float)
|
|
62
|
+
when 'Integer'
|
|
63
|
+
return data if data.instance_of?(Integer)
|
|
64
|
+
when 'Time'
|
|
65
|
+
return Time.parse(data)
|
|
66
|
+
when 'Date'
|
|
67
|
+
return Date.iso8601(data)
|
|
68
|
+
when 'String'
|
|
69
|
+
return data if data.instance_of?(String)
|
|
70
|
+
when 'Object' # "type: object"
|
|
71
|
+
return data if data.instance_of?(Hash)
|
|
72
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
73
|
+
if data.instance_of?(Array)
|
|
74
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
75
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
76
|
+
end
|
|
77
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
78
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
79
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
80
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
81
|
+
end
|
|
82
|
+
else # model
|
|
83
|
+
const = LicenseManager.const_get(klass)
|
|
84
|
+
if const
|
|
85
|
+
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
86
|
+
model = const.build(data)
|
|
87
|
+
return model if model
|
|
88
|
+
else
|
|
89
|
+
# raise if data contains keys that are not known to the model
|
|
90
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
91
|
+
model = const.build_from_hash(data)
|
|
92
|
+
return model if model
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
raise # if no match by now, raise
|
|
98
|
+
rescue
|
|
99
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|