emass_client 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1284 -0
  3. data/Rakefile +8 -0
  4. data/lib/emass_client/api/artifacts_api.rb +310 -0
  5. data/lib/emass_client/api/artifacts_export_api.rb +86 -0
  6. data/lib/emass_client/api/cac_api.rb +143 -0
  7. data/lib/emass_client/api/cmmc_assessments_api.rb +77 -0
  8. data/lib/emass_client/api/controls_api.rb +143 -0
  9. data/lib/emass_client/api/milestones_api.rb +366 -0
  10. data/lib/emass_client/api/pac_api.rb +140 -0
  11. data/lib/emass_client/api/poam_api.rb +345 -0
  12. data/lib/emass_client/api/registration_api.rb +78 -0
  13. data/lib/emass_client/api/static_code_scans_api.rb +84 -0
  14. data/lib/emass_client/api/system_roles_api.rb +150 -0
  15. data/lib/emass_client/api/systems_api.rb +162 -0
  16. data/lib/emass_client/api/test_api.rb +70 -0
  17. data/lib/emass_client/api/test_results_api.rb +149 -0
  18. data/lib/emass_client/api/workflow_definitions_api.rb +76 -0
  19. data/lib/emass_client/api/workflow_instances_api.rb +153 -0
  20. data/lib/emass_client/api_client.rb +389 -0
  21. data/lib/emass_client/api_error.rb +57 -0
  22. data/lib/emass_client/configuration.rb +224 -0
  23. data/lib/emass_client/models/artifacts_delete.rb +201 -0
  24. data/lib/emass_client/models/artifacts_delete_inner.rb +207 -0
  25. data/lib/emass_client/models/artifacts_get.rb +383 -0
  26. data/lib/emass_client/models/artifacts_request_put_body.rb +363 -0
  27. data/lib/emass_client/models/artifacts_response_del.rb +217 -0
  28. data/lib/emass_client/models/artifacts_response_del_data.rb +225 -0
  29. data/lib/emass_client/models/artifacts_response_get.rb +217 -0
  30. data/lib/emass_client/models/artifacts_response_put_post.rb +217 -0
  31. data/lib/emass_client/models/cac_get.rb +301 -0
  32. data/lib/emass_client/models/cac_request_post_body.rb +217 -0
  33. data/lib/emass_client/models/cac_response_get.rb +217 -0
  34. data/lib/emass_client/models/cac_response_post.rb +217 -0
  35. data/lib/emass_client/models/cac_response_post_data.rb +225 -0
  36. data/lib/emass_client/models/cmmc_get.rb +398 -0
  37. data/lib/emass_client/models/cmmc_response_get.rb +217 -0
  38. data/lib/emass_client/models/connectivity_ccsd.rb +217 -0
  39. data/lib/emass_client/models/controls_get.rb +663 -0
  40. data/lib/emass_client/models/controls_put.rb +227 -0
  41. data/lib/emass_client/models/controls_request_put_body.rb +606 -0
  42. data/lib/emass_client/models/controls_response_get.rb +217 -0
  43. data/lib/emass_client/models/controls_response_put.rb +217 -0
  44. data/lib/emass_client/models/definition_transitions.rb +274 -0
  45. data/lib/emass_client/models/delete_milestone.rb +212 -0
  46. data/lib/emass_client/models/delete_poam.rb +212 -0
  47. data/lib/emass_client/models/empty200_response.rb +197 -0
  48. data/lib/emass_client/models/error.rb +225 -0
  49. data/lib/emass_client/models/instances_transitions.rb +327 -0
  50. data/lib/emass_client/models/milestone_response_get.rb +217 -0
  51. data/lib/emass_client/models/milestone_response_post.rb +217 -0
  52. data/lib/emass_client/models/milestone_response_put.rb +217 -0
  53. data/lib/emass_client/models/milestones_delete.rb +197 -0
  54. data/lib/emass_client/models/milestones_get.rb +291 -0
  55. data/lib/emass_client/models/milestones_post.rb +197 -0
  56. data/lib/emass_client/models/milestones_put.rb +197 -0
  57. data/lib/emass_client/models/milestones_put_post_delete.rb +247 -0
  58. data/lib/emass_client/models/milestones_request_post_body.rb +242 -0
  59. data/lib/emass_client/models/milestones_request_put_body.rb +242 -0
  60. data/lib/emass_client/models/milestones_required_post.rb +227 -0
  61. data/lib/emass_client/models/milestones_required_put.rb +242 -0
  62. data/lib/emass_client/models/model_200.rb +208 -0
  63. data/lib/emass_client/models/model_201.rb +206 -0
  64. data/lib/emass_client/models/model_201_meta.rb +219 -0
  65. data/lib/emass_client/models/model_400.rb +206 -0
  66. data/lib/emass_client/models/model_400_meta.rb +219 -0
  67. data/lib/emass_client/models/model_400_response.rb +206 -0
  68. data/lib/emass_client/models/model_401.rb +206 -0
  69. data/lib/emass_client/models/model_401_meta.rb +219 -0
  70. data/lib/emass_client/models/model_403.rb +206 -0
  71. data/lib/emass_client/models/model_403_meta.rb +219 -0
  72. data/lib/emass_client/models/model_404.rb +219 -0
  73. data/lib/emass_client/models/model_404_response.rb +206 -0
  74. data/lib/emass_client/models/model_405.rb +206 -0
  75. data/lib/emass_client/models/model_405_meta.rb +219 -0
  76. data/lib/emass_client/models/model_411.rb +206 -0
  77. data/lib/emass_client/models/model_411_meta.rb +219 -0
  78. data/lib/emass_client/models/model_490.rb +206 -0
  79. data/lib/emass_client/models/model_490_meta.rb +219 -0
  80. data/lib/emass_client/models/model_500.rb +206 -0
  81. data/lib/emass_client/models/model_500_meta.rb +219 -0
  82. data/lib/emass_client/models/pac_get.rb +311 -0
  83. data/lib/emass_client/models/pac_post.rb +259 -0
  84. data/lib/emass_client/models/pac_request_post_body.rb +261 -0
  85. data/lib/emass_client/models/pac_response_get.rb +217 -0
  86. data/lib/emass_client/models/pac_response_post.rb +217 -0
  87. data/lib/emass_client/models/poam_delete.rb +197 -0
  88. data/lib/emass_client/models/poam_get.rb +646 -0
  89. data/lib/emass_client/models/poam_post.rb +197 -0
  90. data/lib/emass_client/models/poam_post_put_del.rb +237 -0
  91. data/lib/emass_client/models/poam_put.rb +197 -0
  92. data/lib/emass_client/models/poam_request_post_body.rb +197 -0
  93. data/lib/emass_client/models/poam_request_put_body.rb +197 -0
  94. data/lib/emass_client/models/poam_required_post.rb +564 -0
  95. data/lib/emass_client/models/poam_required_put.rb +594 -0
  96. data/lib/emass_client/models/poam_response_delete.rb +217 -0
  97. data/lib/emass_client/models/poam_response_get.rb +217 -0
  98. data/lib/emass_client/models/poam_response_post.rb +217 -0
  99. data/lib/emass_client/models/poam_response_put.rb +217 -0
  100. data/lib/emass_client/models/register.rb +215 -0
  101. data/lib/emass_client/models/register_data.rb +206 -0
  102. data/lib/emass_client/models/register_user_request_post_body.rb +211 -0
  103. data/lib/emass_client/models/role_category.rb +272 -0
  104. data/lib/emass_client/models/roles.rb +274 -0
  105. data/lib/emass_client/models/ssps.rb +227 -0
  106. data/lib/emass_client/models/stage.rb +252 -0
  107. data/lib/emass_client/models/static_code_application.rb +303 -0
  108. data/lib/emass_client/models/static_code_request_post_body.rb +197 -0
  109. data/lib/emass_client/models/static_code_required_post.rb +217 -0
  110. data/lib/emass_client/models/static_code_required_post_application.rb +217 -0
  111. data/lib/emass_client/models/success200_response.rb +217 -0
  112. data/lib/emass_client/models/system_id_artifacts_body.rb +284 -0
  113. data/lib/emass_client/models/system_response.rb +217 -0
  114. data/lib/emass_client/models/system_roles_category_response.rb +217 -0
  115. data/lib/emass_client/models/system_roles_response.rb +217 -0
  116. data/lib/emass_client/models/system_roles_response_data.rb +219 -0
  117. data/lib/emass_client/models/systems.rb +1137 -0
  118. data/lib/emass_client/models/test.rb +215 -0
  119. data/lib/emass_client/models/test_data.rb +206 -0
  120. data/lib/emass_client/models/test_results_get.rb +333 -0
  121. data/lib/emass_client/models/test_results_post.rb +227 -0
  122. data/lib/emass_client/models/test_results_request_post_body.rb +306 -0
  123. data/lib/emass_client/models/test_results_response_get.rb +217 -0
  124. data/lib/emass_client/models/test_results_response_post.rb +217 -0
  125. data/lib/emass_client/models/users.rb +224 -0
  126. data/lib/emass_client/models/workflow_definition_get.rb +282 -0
  127. data/lib/emass_client/models/workflow_definition_response_get.rb +217 -0
  128. data/lib/emass_client/models/workflow_instances_get.rb +368 -0
  129. data/lib/emass_client/models/workflow_instances_response_get.rb +217 -0
  130. data/lib/emass_client/version.rb +14 -0
  131. data/lib/emass_client.rb +161 -0
  132. metadata +259 -0
@@ -0,0 +1,76 @@
1
+ =begin
2
+ #Enterprise Mission Assurance Support Service (eMASS)
3
+
4
+ #The Enterprise Mission Assurance Support Service (eMASS) Representational State Transfer (REST) Application Programming Interface (API) enables users to perform assessments and complete actions associated with system records. The `emasser` is a command-line interface (CLI) tool that implements all of the eMASS endpoints defined in the eMASS REST API v3.2, dated October 21, 2021.</br><br> <strong>Register CLI</strong></br> New users will need to register an API key with the eMASS development team prior to accessing the site for the first time. The eMASS REST API requires a client certificate (SSL/TLS, DoD PKI only) where {url}/api/register (POST) is used to register the client certificate.</br></br> Every call to the eMASS REST API will require the use of the agreed upon public key certificate and API key. The API key must be provided in the request header for all endpoint calls (api-key). If the service receives an untrusted certificate or API key, a 401 error response code will be returned along with an error message.</br></br> <strong>Available Request Headers:</strong></br> <table> <tr> <th align=left>key</th> <th align=left>Example Value</th> <th align=left>Description</th> </tr> <tr> <td>`api-key`</td> <td>api-key-provided-by-emass</td> <td>This API key must be provided in the request header for all endpoint calls</td> </tr> <tr> <td>`user-uid`</td> <td>USER.UID.KEY</td> <td>This User unique identifier key must be provided in the request header for all PUT, POST, and DELETE endpoint calls</td> </tr> <tr> <td></td><td></td> <td> Note: For DoD users this is the DoD ID Number (EIDIPI) on their DoD CAC </td> </tr> </table> </br><strong>Approve API Client for Actionable Requests</strong></br> Users are required to log-in to eMASS and grant permissions for a client to update data within eMASS on their behalf. This is only required for actionable requests (PUT, POST, DELETE). The Registration Endpoint and all GET requests can be accessed without completing this process with the correct permissions. Please note that leaving a field parameter blank (for PUT/POST requests) has the potential to clear information in the active eMASS records. To establish an account with eMASS and/or acquire an api-key/user-uid, contact one of the listed POC:
5
+
6
+ OpenAPI spec version: v3.2
7
+ Contact: disa.meade.id.mbx.emass-tier-iii-support@mail.mil
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.26
10
+ =end
11
+
12
+ module EmassClient
13
+ class WorkflowDefinitionsApi
14
+ attr_accessor :api_client
15
+
16
+ def initialize(api_client = ApiClient.default)
17
+ @api_client = api_client
18
+ end
19
+ # Get workflow definitions in a site
20
+ # View all workflow schemas available on the eMASS instance filtered by status `includeInactive` and registration type `registrationType`.
21
+ # @param [Hash] opts the optional parameters
22
+ # @option opts [BOOLEAN] :include_inactive **Include Inactive**: If no value is specified, the default returns false to not include outdated workflow definitions. (default to true)
23
+ # @option opts [String] :registration_type **Registration Type**: Filter record by selected registration type (single value or comma delimited values). *Available values:* assessAndAuthorize, assessOnly, guest, regular, functional, cloudServiceProvider, commonControlProvider (default to regular)
24
+ # @return [WorkflowDefinitionResponseGet]
25
+ def get_workflow_definitions(opts = {})
26
+ data, _status_code, _headers = get_workflow_definitions_with_http_info(opts)
27
+ data
28
+ end
29
+
30
+ # Get workflow definitions in a site
31
+ # View all workflow schemas available on the eMASS instance filtered by status &#x60;includeInactive&#x60; and registration type &#x60;registrationType&#x60;.
32
+ # @param [Hash] opts the optional parameters
33
+ # @option opts [BOOLEAN] :include_inactive **Include Inactive**: If no value is specified, the default returns false to not include outdated workflow definitions.
34
+ # @option opts [String] :registration_type **Registration Type**: Filter record by selected registration type (single value or comma delimited values). *Available values:* assessAndAuthorize, assessOnly, guest, regular, functional, cloudServiceProvider, commonControlProvider
35
+ # @return [Array<(WorkflowDefinitionResponseGet, Integer, Hash)>] WorkflowDefinitionResponseGet data, response status code and response headers
36
+ def get_workflow_definitions_with_http_info(opts = {})
37
+ if @api_client.config.debugging
38
+ @api_client.config.logger.debug 'Calling API: WorkflowDefinitionsApi.get_workflow_definitions ...'
39
+ end
40
+ # resource path
41
+ local_var_path = '/api/workflow-definitions'
42
+
43
+ # query parameters
44
+ query_params = opts[:query_params] || {}
45
+ query_params[:'includeInactive'] = opts[:'include_inactive'] if !opts[:'include_inactive'].nil?
46
+ query_params[:'registrationType'] = opts[:'registration_type'] if !opts[:'registration_type'].nil?
47
+
48
+ # header parameters
49
+ header_params = opts[:header_params] || {}
50
+ # HTTP header 'Accept' (if needed)
51
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
52
+
53
+ # form parameters
54
+ form_params = opts[:form_params] || {}
55
+
56
+ # http body (model)
57
+ post_body = opts[:body]
58
+
59
+ return_type = opts[:return_type] || 'WorkflowDefinitionResponseGet'
60
+
61
+ auth_names = opts[:auth_names] || ['apikey', 'mockType', 'userid']
62
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
63
+ :header_params => header_params,
64
+ :query_params => query_params,
65
+ :form_params => form_params,
66
+ :body => post_body,
67
+ :auth_names => auth_names,
68
+ :return_type => return_type)
69
+
70
+ if @api_client.config.debugging
71
+ @api_client.config.logger.debug "API called: WorkflowDefinitionsApi#get_workflow_definitions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
72
+ end
73
+ return data, status_code, headers
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,153 @@
1
+ =begin
2
+ #Enterprise Mission Assurance Support Service (eMASS)
3
+
4
+ #The Enterprise Mission Assurance Support Service (eMASS) Representational State Transfer (REST) Application Programming Interface (API) enables users to perform assessments and complete actions associated with system records. The `emasser` is a command-line interface (CLI) tool that implements all of the eMASS endpoints defined in the eMASS REST API v3.2, dated October 21, 2021.</br><br> <strong>Register CLI</strong></br> New users will need to register an API key with the eMASS development team prior to accessing the site for the first time. The eMASS REST API requires a client certificate (SSL/TLS, DoD PKI only) where {url}/api/register (POST) is used to register the client certificate.</br></br> Every call to the eMASS REST API will require the use of the agreed upon public key certificate and API key. The API key must be provided in the request header for all endpoint calls (api-key). If the service receives an untrusted certificate or API key, a 401 error response code will be returned along with an error message.</br></br> <strong>Available Request Headers:</strong></br> <table> <tr> <th align=left>key</th> <th align=left>Example Value</th> <th align=left>Description</th> </tr> <tr> <td>`api-key`</td> <td>api-key-provided-by-emass</td> <td>This API key must be provided in the request header for all endpoint calls</td> </tr> <tr> <td>`user-uid`</td> <td>USER.UID.KEY</td> <td>This User unique identifier key must be provided in the request header for all PUT, POST, and DELETE endpoint calls</td> </tr> <tr> <td></td><td></td> <td> Note: For DoD users this is the DoD ID Number (EIDIPI) on their DoD CAC </td> </tr> </table> </br><strong>Approve API Client for Actionable Requests</strong></br> Users are required to log-in to eMASS and grant permissions for a client to update data within eMASS on their behalf. This is only required for actionable requests (PUT, POST, DELETE). The Registration Endpoint and all GET requests can be accessed without completing this process with the correct permissions. Please note that leaving a field parameter blank (for PUT/POST requests) has the potential to clear information in the active eMASS records. To establish an account with eMASS and/or acquire an api-key/user-uid, contact one of the listed POC:
5
+
6
+ OpenAPI spec version: v3.2
7
+ Contact: disa.meade.id.mbx.emass-tier-iii-support@mail.mil
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.26
10
+ =end
11
+
12
+ module EmassClient
13
+ class WorkflowInstancesApi
14
+ attr_accessor :api_client
15
+
16
+ def initialize(api_client = ApiClient.default)
17
+ @api_client = api_client
18
+ end
19
+ # Get workflow instances in a system
20
+ # View detailed information on all active and historical workflows for a system `systemId` and filtered by provided parameters.
21
+ # @param system_id **System Id**: The unique system record identifier.
22
+ # @param [Hash] opts the optional parameters
23
+ # @option opts [BOOLEAN] :include_comments **Include Comments**: If no value is specified, the default returns true to not include transition comments. Note: Corresponds to the Comments textbox that is required at most workflow transitions. Does not include other text input fields such as Terms / Conditions for Authorization. (default to true)
24
+ # @option opts [Integer] :page_index **Page Index**: If no value is specified, the default returns true to not include transition comments. (default to 0)
25
+ # @option opts [String] :since_date **Date**: Filter on authorization/assessment date (Unix date format). Note: Filters off the lastEditedDate field. Note: The authorization/assessment decisions on completed workflows can be edited for up to 30 days after the initial decision is made.
26
+ # @option opts [String] :status **Status**: Filter by status. If no value is specified, the default returns all to include both active and inactive workflows. Note: Any workflows at a current stage of Complete or Cancelled are inactive. Ongoing workflows currently at other stages are active. (default to all)
27
+ # @return [WorkflowInstancesResponseGet]
28
+ def get_system_workflow_instances(system_id, opts = {})
29
+ data, _status_code, _headers = get_system_workflow_instances_with_http_info(system_id, opts)
30
+ data
31
+ end
32
+
33
+ # Get workflow instances in a system
34
+ # View detailed information on all active and historical workflows for a system &#x60;systemId&#x60; and filtered by provided parameters.
35
+ # @param system_id **System Id**: The unique system record identifier.
36
+ # @param [Hash] opts the optional parameters
37
+ # @option opts [BOOLEAN] :include_comments **Include Comments**: If no value is specified, the default returns true to not include transition comments. Note: Corresponds to the Comments textbox that is required at most workflow transitions. Does not include other text input fields such as Terms / Conditions for Authorization.
38
+ # @option opts [Integer] :page_index **Page Index**: If no value is specified, the default returns true to not include transition comments.
39
+ # @option opts [String] :since_date **Date**: Filter on authorization/assessment date (Unix date format). Note: Filters off the lastEditedDate field. Note: The authorization/assessment decisions on completed workflows can be edited for up to 30 days after the initial decision is made.
40
+ # @option opts [String] :status **Status**: Filter by status. If no value is specified, the default returns all to include both active and inactive workflows. Note: Any workflows at a current stage of Complete or Cancelled are inactive. Ongoing workflows currently at other stages are active.
41
+ # @return [Array<(WorkflowInstancesResponseGet, Integer, Hash)>] WorkflowInstancesResponseGet data, response status code and response headers
42
+ def get_system_workflow_instances_with_http_info(system_id, opts = {})
43
+ if @api_client.config.debugging
44
+ @api_client.config.logger.debug 'Calling API: WorkflowInstancesApi.get_system_workflow_instances ...'
45
+ end
46
+ # verify the required parameter 'system_id' is set
47
+ if @api_client.config.client_side_validation && system_id.nil?
48
+ fail ArgumentError, "Missing the required parameter 'system_id' when calling WorkflowInstancesApi.get_system_workflow_instances"
49
+ end
50
+ if @api_client.config.client_side_validation && opts[:'status'] && !['active', 'inactive', 'all'].include?(opts[:'status'])
51
+ fail ArgumentError, 'invalid value for "status", must be one of active, inactive, all'
52
+ end
53
+ # resource path
54
+ local_var_path = '/api/systems/{systemId}/workflow-instances'.sub('{' + 'systemId' + '}', system_id.to_s)
55
+
56
+ # query parameters
57
+ query_params = opts[:query_params] || {}
58
+ query_params[:'includeComments'] = opts[:'include_comments'] if !opts[:'include_comments'].nil?
59
+ query_params[:'pageIndex'] = opts[:'page_index'] if !opts[:'page_index'].nil?
60
+ query_params[:'sinceDate'] = opts[:'since_date'] if !opts[:'since_date'].nil?
61
+ query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
62
+
63
+ # header parameters
64
+ header_params = opts[:header_params] || {}
65
+ # HTTP header 'Accept' (if needed)
66
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
67
+
68
+ # form parameters
69
+ form_params = opts[:form_params] || {}
70
+
71
+ # http body (model)
72
+ post_body = opts[:body]
73
+
74
+ return_type = opts[:return_type] || 'WorkflowInstancesResponseGet'
75
+
76
+ auth_names = opts[:auth_names] || ['apikey', 'mockType', 'userid']
77
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
78
+ :header_params => header_params,
79
+ :query_params => query_params,
80
+ :form_params => form_params,
81
+ :body => post_body,
82
+ :auth_names => auth_names,
83
+ :return_type => return_type)
84
+
85
+ if @api_client.config.debugging
86
+ @api_client.config.logger.debug "API called: WorkflowInstancesApi#get_system_workflow_instances\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
87
+ end
88
+ return data, status_code, headers
89
+ end
90
+ # Get workflow instance by ID in a system
91
+ # View detailed information on all active and historical workflows for a system `systemId` and `workflowInstanceId`.
92
+ # @param system_id **System Id**: The unique system record identifier.
93
+ # @param workflow_instance_id **Workflow Instance Id**: The unique milestone record identifier.
94
+ # @param [Hash] opts the optional parameters
95
+ # @return [WorkflowInstancesResponseGet]
96
+ def get_system_workflow_instances_by_workflow_instance_id(system_id, workflow_instance_id, opts = {})
97
+ data, _status_code, _headers = get_system_workflow_instances_by_workflow_instance_id_with_http_info(system_id, workflow_instance_id, opts)
98
+ data
99
+ end
100
+
101
+ # Get workflow instance by ID in a system
102
+ # View detailed information on all active and historical workflows for a system &#x60;systemId&#x60; and &#x60;workflowInstanceId&#x60;.
103
+ # @param system_id **System Id**: The unique system record identifier.
104
+ # @param workflow_instance_id **Workflow Instance Id**: The unique milestone record identifier.
105
+ # @param [Hash] opts the optional parameters
106
+ # @return [Array<(WorkflowInstancesResponseGet, Integer, Hash)>] WorkflowInstancesResponseGet data, response status code and response headers
107
+ def get_system_workflow_instances_by_workflow_instance_id_with_http_info(system_id, workflow_instance_id, opts = {})
108
+ if @api_client.config.debugging
109
+ @api_client.config.logger.debug 'Calling API: WorkflowInstancesApi.get_system_workflow_instances_by_workflow_instance_id ...'
110
+ end
111
+ # verify the required parameter 'system_id' is set
112
+ if @api_client.config.client_side_validation && system_id.nil?
113
+ fail ArgumentError, "Missing the required parameter 'system_id' when calling WorkflowInstancesApi.get_system_workflow_instances_by_workflow_instance_id"
114
+ end
115
+ # verify the required parameter 'workflow_instance_id' is set
116
+ if @api_client.config.client_side_validation && workflow_instance_id.nil?
117
+ fail ArgumentError, "Missing the required parameter 'workflow_instance_id' when calling WorkflowInstancesApi.get_system_workflow_instances_by_workflow_instance_id"
118
+ end
119
+ # resource path
120
+ local_var_path = '/api/systems/{systemId}/workflow-instances/{workflowInstanceId}'.sub('{' + 'systemId' + '}', system_id.to_s).sub('{' + 'workflowInstanceId' + '}', workflow_instance_id.to_s)
121
+
122
+ # query parameters
123
+ query_params = opts[:query_params] || {}
124
+
125
+ # header parameters
126
+ header_params = opts[:header_params] || {}
127
+ # HTTP header 'Accept' (if needed)
128
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
129
+
130
+ # form parameters
131
+ form_params = opts[:form_params] || {}
132
+
133
+ # http body (model)
134
+ post_body = opts[:body]
135
+
136
+ return_type = opts[:return_type] || 'WorkflowInstancesResponseGet'
137
+
138
+ auth_names = opts[:auth_names] || ['apikey', 'mockType', 'userid']
139
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
140
+ :header_params => header_params,
141
+ :query_params => query_params,
142
+ :form_params => form_params,
143
+ :body => post_body,
144
+ :auth_names => auth_names,
145
+ :return_type => return_type)
146
+
147
+ if @api_client.config.debugging
148
+ @api_client.config.logger.debug "API called: WorkflowInstancesApi#get_system_workflow_instances_by_workflow_instance_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
149
+ end
150
+ return data, status_code, headers
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,389 @@
1
+ =begin
2
+ #Enterprise Mission Assurance Support Service (eMASS)
3
+
4
+ #The Enterprise Mission Assurance Support Service (eMASS) Representational State Transfer (REST) Application Programming Interface (API) enables users to perform assessments and complete actions associated with system records. The `emasser` is a command-line interface (CLI) tool that implements all of the eMASS endpoints defined in the eMASS REST API v3.2, dated October 21, 2021.</br><br> <strong>Register CLI</strong></br> New users will need to register an API key with the eMASS development team prior to accessing the site for the first time. The eMASS REST API requires a client certificate (SSL/TLS, DoD PKI only) where {url}/api/register (POST) is used to register the client certificate.</br></br> Every call to the eMASS REST API will require the use of the agreed upon public key certificate and API key. The API key must be provided in the request header for all endpoint calls (api-key). If the service receives an untrusted certificate or API key, a 401 error response code will be returned along with an error message.</br></br> <strong>Available Request Headers:</strong></br> <table> <tr> <th align=left>key</th> <th align=left>Example Value</th> <th align=left>Description</th> </tr> <tr> <td>`api-key`</td> <td>api-key-provided-by-emass</td> <td>This API key must be provided in the request header for all endpoint calls</td> </tr> <tr> <td>`user-uid`</td> <td>USER.UID.KEY</td> <td>This User unique identifier key must be provided in the request header for all PUT, POST, and DELETE endpoint calls</td> </tr> <tr> <td></td><td></td> <td> Note: For DoD users this is the DoD ID Number (EIDIPI) on their DoD CAC </td> </tr> </table> </br><strong>Approve API Client for Actionable Requests</strong></br> Users are required to log-in to eMASS and grant permissions for a client to update data within eMASS on their behalf. This is only required for actionable requests (PUT, POST, DELETE). The Registration Endpoint and all GET requests can be accessed without completing this process with the correct permissions. Please note that leaving a field parameter blank (for PUT/POST requests) has the potential to clear information in the active eMASS records. To establish an account with eMASS and/or acquire an api-key/user-uid, contact one of the listed POC:
5
+
6
+ OpenAPI spec version: v3.2
7
+ Contact: disa.meade.id.mbx.emass-tier-iii-support@mail.mil
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.26
10
+ =end
11
+
12
+ require 'date'
13
+ require 'json'
14
+ require 'logger'
15
+ require 'tempfile'
16
+ require 'typhoeus'
17
+ require 'uri'
18
+
19
+ module EmassClient
20
+ class ApiClient
21
+ # The Configuration object holding settings to be used in the API client.
22
+ attr_accessor :config
23
+
24
+ # Defines the headers to be used in HTTP requests of all API calls by default.
25
+ #
26
+ # @return [Hash]
27
+ attr_accessor :default_headers
28
+
29
+ # Initializes the ApiClient
30
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
31
+ def initialize(config = Configuration.default)
32
+ @config = config
33
+ @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
34
+ @default_headers = {
35
+ 'Content-Type' => 'application/json',
36
+ 'User-Agent' => @user_agent
37
+ }
38
+ end
39
+
40
+ def self.default
41
+ @@default ||= ApiClient.new
42
+ end
43
+
44
+ # Call an API with given options.
45
+ #
46
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
47
+ # the data deserialized from response body (could be nil), response status code and response headers.
48
+ def call_api(http_method, path, opts = {})
49
+ request = build_request(http_method, path, opts)
50
+ response = request.run
51
+
52
+ if @config.debugging
53
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
54
+ end
55
+
56
+ unless response.success?
57
+ if response.timed_out?
58
+ fail ApiError.new('Connection timed out')
59
+ elsif response.code == 0
60
+ # Errors from libcurl will be made visible here
61
+ fail ApiError.new(:code => 0,
62
+ :message => response.return_message)
63
+ else
64
+ fail ApiError.new(:code => response.code,
65
+ :response_headers => response.headers,
66
+ :response_body => response.body),
67
+ response.status_message
68
+ end
69
+ end
70
+
71
+ if opts[:return_type]
72
+ data = deserialize(response, opts[:return_type])
73
+ else
74
+ data = nil
75
+ end
76
+ return data, response.code, response.headers
77
+ end
78
+
79
+ # Builds the HTTP request
80
+ #
81
+ # @param [String] http_method HTTP method/verb (e.g. POST)
82
+ # @param [String] path URL path (e.g. /account/new)
83
+ # @option opts [Hash] :header_params Header parameters
84
+ # @option opts [Hash] :query_params Query parameters
85
+ # @option opts [Hash] :form_params Query parameters
86
+ # @option opts [Object] :body HTTP body (JSON/XML)
87
+ # @return [Typhoeus::Request] A Typhoeus Request
88
+ def build_request(http_method, path, opts = {})
89
+ url = build_request_url(path)
90
+ http_method = http_method.to_sym.downcase
91
+
92
+ header_params = @default_headers.merge(opts[:header_params] || {})
93
+ query_params = opts[:query_params] || {}
94
+ form_params = opts[:form_params] || {}
95
+
96
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
97
+
98
+ # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
99
+ _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
100
+
101
+ req_opts = {
102
+ :method => http_method,
103
+ :headers => header_params,
104
+ :params => query_params,
105
+ :params_encoding => @config.params_encoding,
106
+ :timeout => @config.timeout,
107
+ :ssl_verifypeer => @config.verify_ssl,
108
+ :ssl_verifyhost => _verify_ssl_host,
109
+ :sslcert => @config.cert_file,
110
+ :sslkey => @config.key_file,
111
+ :verbose => @config.debugging,
112
+ :keypasswd => @config.key_password
113
+ }
114
+
115
+ # set custom cert, if provided
116
+ req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
117
+
118
+ if [:post, :patch, :put, :delete].include?(http_method)
119
+ req_body = build_request_body(header_params, form_params, opts[:body])
120
+ req_opts.update :body => req_body
121
+ if @config.debugging
122
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
123
+ end
124
+ end
125
+
126
+ request = Typhoeus::Request.new(url, req_opts)
127
+ download_file(request) if opts[:return_type] == 'File'
128
+ request
129
+ end
130
+
131
+ # Builds the HTTP request body
132
+ #
133
+ # @param [Hash] header_params Header parameters
134
+ # @param [Hash] form_params Query parameters
135
+ # @param [Object] body HTTP body (JSON/XML)
136
+ # @return [String] HTTP body data in the form of string
137
+ def build_request_body(header_params, form_params, body)
138
+ # http form
139
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
140
+ header_params['Content-Type'] == 'multipart/form-data'
141
+ data = {}
142
+ form_params.each do |key, value|
143
+ case value
144
+ when ::File, ::Array, nil
145
+ # let typhoeus handle File, Array and nil parameters
146
+ data[key] = value
147
+ else
148
+ data[key] = value.to_s
149
+ end
150
+ end
151
+ elsif body
152
+ data = body.is_a?(String) ? body : body.to_json
153
+ else
154
+ data = nil
155
+ end
156
+ data
157
+ end
158
+
159
+ # Check if the given MIME is a JSON MIME.
160
+ # JSON MIME examples:
161
+ # application/json
162
+ # application/json; charset=UTF8
163
+ # APPLICATION/JSON
164
+ # */*
165
+ # @param [String] mime MIME
166
+ # @return [Boolean] True if the MIME is application/json
167
+ def json_mime?(mime)
168
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
169
+ end
170
+
171
+ # Deserialize the response to the given return type.
172
+ #
173
+ # @param [Response] response HTTP response
174
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
175
+ def deserialize(response, return_type)
176
+ body = response.body
177
+
178
+ # handle file downloading - return the File instance processed in request callbacks
179
+ # note that response body is empty when the file is written in chunks in request on_body callback
180
+ return @tempfile if return_type == 'File'
181
+
182
+ return nil if body.nil? || body.empty?
183
+
184
+ # return response body directly for String return type
185
+ return body if return_type == 'String'
186
+
187
+ # ensuring a default content type
188
+ content_type = response.headers['Content-Type'] || 'application/json'
189
+
190
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
191
+
192
+ begin
193
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
194
+ rescue JSON::ParserError => e
195
+ if %w(String Date DateTime).include?(return_type)
196
+ data = body
197
+ else
198
+ raise e
199
+ end
200
+ end
201
+
202
+ convert_to_type data, return_type
203
+ end
204
+
205
+ # Convert data to the given return type.
206
+ # @param [Object] data Data to be converted
207
+ # @param [String] return_type Return type
208
+ # @return [Mixed] Data in a particular type
209
+ def convert_to_type(data, return_type)
210
+ return nil if data.nil?
211
+ case return_type
212
+ when 'String'
213
+ data.to_s
214
+ when 'Integer'
215
+ data.to_i
216
+ when 'Float'
217
+ data.to_f
218
+ when 'Boolean'
219
+ data == true
220
+ when 'DateTime'
221
+ # parse date time (expecting ISO 8601 format)
222
+ DateTime.parse data
223
+ when 'Date'
224
+ # parse date time (expecting ISO 8601 format)
225
+ Date.parse data
226
+ when 'Object'
227
+ # generic object (usually a Hash), return directly
228
+ data
229
+ when /\AArray<(.+)>\z/
230
+ # e.g. Array<Pet>
231
+ sub_type = $1
232
+ data.map { |item| convert_to_type(item, sub_type) }
233
+ when /\AHash\<String, (.+)\>\z/
234
+ # e.g. Hash<String, Integer>
235
+ sub_type = $1
236
+ {}.tap do |hash|
237
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
238
+ end
239
+ else
240
+ # models, e.g. Pet
241
+ EmassClient.const_get(return_type).build_from_hash(data)
242
+ end
243
+ end
244
+
245
+ # Save response body into a file in (the defined) temporary folder, using the filename
246
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
247
+ # The response body is written to the file in chunks in order to handle files which
248
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
249
+ # process can use.
250
+ #
251
+ # @see Configuration#temp_folder_path
252
+ def download_file(request)
253
+ tempfile = nil
254
+ encoding = nil
255
+ request.on_headers do |response|
256
+ content_disposition = response.headers['Content-Disposition']
257
+ if content_disposition && content_disposition =~ /filename=/i
258
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
259
+ prefix = sanitize_filename(filename)
260
+ else
261
+ prefix = 'download-'
262
+ end
263
+ prefix = prefix + '-' unless prefix.end_with?('-')
264
+ encoding = response.body.encoding
265
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
266
+ @tempfile = tempfile
267
+ end
268
+ request.on_body do |chunk|
269
+ chunk.force_encoding(encoding)
270
+ tempfile.write(chunk)
271
+ end
272
+ request.on_complete do |response|
273
+ if tempfile
274
+ tempfile.close
275
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
276
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
277
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
278
+ "explicitly with `tempfile.delete`"
279
+ end
280
+ end
281
+ end
282
+
283
+ # Sanitize filename by removing path.
284
+ # e.g. ../../sun.gif becomes sun.gif
285
+ #
286
+ # @param [String] filename the filename to be sanitized
287
+ # @return [String] the sanitized filename
288
+ def sanitize_filename(filename)
289
+ filename.gsub(/.*[\/\\]/, '')
290
+ end
291
+
292
+ def build_request_url(path)
293
+ # Add leading and trailing slashes to path
294
+ path = "/#{path}".gsub(/\/+/, '/')
295
+ @config.base_url + path
296
+ end
297
+
298
+ # Update hearder and query params based on authentication settings.
299
+ #
300
+ # @param [Hash] header_params Header parameters
301
+ # @param [Hash] query_params Query parameters
302
+ # @param [String] auth_names Authentication scheme name
303
+ def update_params_for_auth!(header_params, query_params, auth_names)
304
+ Array(auth_names).each do |auth_name|
305
+ auth_setting = @config.auth_settings[auth_name]
306
+ next unless auth_setting
307
+ case auth_setting[:in]
308
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
309
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
310
+ else fail ArgumentError, 'Authentication token must be in `query` of `header`'
311
+ end
312
+ end
313
+ end
314
+
315
+ # Sets user agent in HTTP header
316
+ #
317
+ # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
318
+ def user_agent=(user_agent)
319
+ @user_agent = user_agent
320
+ @default_headers['User-Agent'] = @user_agent
321
+ end
322
+
323
+ # Return Accept header based on an array of accepts provided.
324
+ # @param [Array] accepts array for Accept
325
+ # @return [String] the Accept header (e.g. application/json)
326
+ def select_header_accept(accepts)
327
+ return nil if accepts.nil? || accepts.empty?
328
+ # use JSON when present, otherwise use all of the provided
329
+ json_accept = accepts.find { |s| json_mime?(s) }
330
+ json_accept || accepts.join(',')
331
+ end
332
+
333
+ # Return Content-Type header based on an array of content types provided.
334
+ # @param [Array] content_types array for Content-Type
335
+ # @return [String] the Content-Type header (e.g. application/json)
336
+ def select_header_content_type(content_types)
337
+ # use application/json by default
338
+ return 'application/json' if content_types.nil? || content_types.empty?
339
+ # use JSON when present, otherwise use the first one
340
+ json_content_type = content_types.find { |s| json_mime?(s) }
341
+ json_content_type || content_types.first
342
+ end
343
+
344
+ # Convert object (array, hash, object, etc) to JSON string.
345
+ # @param [Object] model object to be converted into JSON string
346
+ # @return [String] JSON string representation of the object
347
+ def object_to_http_body(model)
348
+ return model if model.nil? || model.is_a?(String)
349
+ local_body = nil
350
+ if model.is_a?(Array)
351
+ local_body = model.map { |m| object_to_hash(m) }
352
+ else
353
+ local_body = object_to_hash(model)
354
+ end
355
+ local_body.to_json
356
+ end
357
+
358
+ # Convert object(non-array) to hash.
359
+ # @param [Object] obj object to be converted into JSON string
360
+ # @return [String] JSON string representation of the object
361
+ def object_to_hash(obj)
362
+ if obj.respond_to?(:to_hash)
363
+ obj.to_hash
364
+ else
365
+ obj
366
+ end
367
+ end
368
+
369
+ # Build parameter value according to the given collection format.
370
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
371
+ def build_collection_param(param, collection_format)
372
+ case collection_format
373
+ when :csv
374
+ param.join(',')
375
+ when :ssv
376
+ param.join(' ')
377
+ when :tsv
378
+ param.join("\t")
379
+ when :pipes
380
+ param.join('|')
381
+ when :multi
382
+ # return the array directly as typhoeus will handle it as expected
383
+ param
384
+ else
385
+ fail "unknown collection format: #{collection_format.inspect}"
386
+ end
387
+ end
388
+ end
389
+ end