=begin #HubDB endpoints #HubDB is a relational data store that presents data as rows, columns, and cells in a table, much like a spreadsheet. HubDB tables can be added or modified [in the HubSpot CMS](https://knowledge.hubspot.com/cos-general/how-to-edit-hubdb-tables), but you can also use the API endpoints documented here. For more information on HubDB tables and using their data on a HubSpot site, see the [CMS developers site](https://designers.hubspot.com/docs/tools/hubdb). You can also see the [documentation for dynamic pages](https://designers.hubspot.com/docs/tutorials/how-to-build-dynamic-pages-with-hubdb) for more details about the `useForPages` field. HubDB tables support `draft` and `published` versions. This allows you to update data in the table, either for testing or to allow for a manual approval process, without affecting any live pages using the existing data. Draft data can be reviewed, and published by a user working in HubSpot or published via the API. Draft data can also be discarded, allowing users to go back to the published version of the data without disrupting it. If a table is set to be `allowed for public access`, you can access the published version of the table and rows without any authentication by specifying the portal id via the query parameter `portalId`. The version of the OpenAPI document: v3 Generated by: https://openapi-generator.tech OpenAPI Generator version: 4.3.1 =end require 'cgi' module Hubspot module Cms module Hubdb class RowsBatchApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Clone rows in batch # Clones rows in the `draft` version of the specified table, given a set of row ids. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_string [BatchInputString] The JSON array of row ids # @param [Hash] opts the optional parameters # @return [Object] def batch_clone_draft_table_rows(table_id_or_name, batch_input_string, opts = {}) data, _status_code, _headers = batch_clone_draft_table_rows_with_http_info(table_id_or_name, batch_input_string, opts) data end # Clone rows in batch # Clones rows in the `draft` version of the specified table, given a set of row ids. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_string [BatchInputString] The JSON array of row ids # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def batch_clone_draft_table_rows_with_http_info(table_id_or_name, batch_input_string, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RowsBatchApi.batch_clone_draft_table_rows ...' end # verify the required parameter 'table_id_or_name' is set if @api_client.config.client_side_validation && table_id_or_name.nil? fail ArgumentError, "Missing the required parameter 'table_id_or_name' when calling RowsBatchApi.batch_clone_draft_table_rows" end # verify the required parameter 'batch_input_string' is set if @api_client.config.client_side_validation && batch_input_string.nil? fail ArgumentError, "Missing the required parameter 'batch_input_string' when calling RowsBatchApi.batch_clone_draft_table_rows" end # resource path local_var_path = '/cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/clone'.sub('{' + 'tableIdOrName' + '}', CGI.escape(table_id_or_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(batch_input_string) # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || ['hapikey', 'oauth2'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: RowsBatchApi#batch_clone_draft_table_rows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create rows in batch # Creates rows in the `draft` version of the specified table, given an array of row objects. See the overview section for more details with an example. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_hub_db_table_row_v3_request [BatchInputHubDbTableRowV3Request] JSON array of row objects # @param [Hash] opts the optional parameters # @return [Object] def batch_create_draft_table_rows(table_id_or_name, batch_input_hub_db_table_row_v3_request, opts = {}) data, _status_code, _headers = batch_create_draft_table_rows_with_http_info(table_id_or_name, batch_input_hub_db_table_row_v3_request, opts) data end # Create rows in batch # Creates rows in the `draft` version of the specified table, given an array of row objects. See the overview section for more details with an example. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_hub_db_table_row_v3_request [BatchInputHubDbTableRowV3Request] JSON array of row objects # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def batch_create_draft_table_rows_with_http_info(table_id_or_name, batch_input_hub_db_table_row_v3_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RowsBatchApi.batch_create_draft_table_rows ...' end # verify the required parameter 'table_id_or_name' is set if @api_client.config.client_side_validation && table_id_or_name.nil? fail ArgumentError, "Missing the required parameter 'table_id_or_name' when calling RowsBatchApi.batch_create_draft_table_rows" end # verify the required parameter 'batch_input_hub_db_table_row_v3_request' is set if @api_client.config.client_side_validation && batch_input_hub_db_table_row_v3_request.nil? fail ArgumentError, "Missing the required parameter 'batch_input_hub_db_table_row_v3_request' when calling RowsBatchApi.batch_create_draft_table_rows" end # resource path local_var_path = '/cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/create'.sub('{' + 'tableIdOrName' + '}', CGI.escape(table_id_or_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(batch_input_hub_db_table_row_v3_request) # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || ['hapikey', 'oauth2'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: RowsBatchApi#batch_create_draft_table_rows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Permanently deletes rows # Permanently deletes rows from the `draft` version of the table, given a set of row ids. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_string [BatchInputString] JSON array of row ids. # @param [Hash] opts the optional parameters # @return [nil] def batch_purge_draft_table_rows(table_id_or_name, batch_input_string, opts = {}) batch_purge_draft_table_rows_with_http_info(table_id_or_name, batch_input_string, opts) nil end # Permanently deletes rows # Permanently deletes rows from the `draft` version of the table, given a set of row ids. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_string [BatchInputString] JSON array of row ids. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def batch_purge_draft_table_rows_with_http_info(table_id_or_name, batch_input_string, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RowsBatchApi.batch_purge_draft_table_rows ...' end # verify the required parameter 'table_id_or_name' is set if @api_client.config.client_side_validation && table_id_or_name.nil? fail ArgumentError, "Missing the required parameter 'table_id_or_name' when calling RowsBatchApi.batch_purge_draft_table_rows" end # verify the required parameter 'batch_input_string' is set if @api_client.config.client_side_validation && batch_input_string.nil? fail ArgumentError, "Missing the required parameter 'batch_input_string' when calling RowsBatchApi.batch_purge_draft_table_rows" end # resource path local_var_path = '/cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/purge'.sub('{' + 'tableIdOrName' + '}', CGI.escape(table_id_or_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(batch_input_string) # return_type return_type = opts[:return_type] # auth_names auth_names = opts[:auth_names] || ['hapikey', 'oauth2'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: RowsBatchApi#batch_purge_draft_table_rows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a set of rows from draft table # Returns rows in the `draft` version of the specified table, given a set of row ids. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_string [BatchInputString] JSON array of row ids. # @param [Hash] opts the optional parameters # @return [Object] def batch_read_draft_table_rows(table_id_or_name, batch_input_string, opts = {}) data, _status_code, _headers = batch_read_draft_table_rows_with_http_info(table_id_or_name, batch_input_string, opts) data end # Get a set of rows from draft table # Returns rows in the `draft` version of the specified table, given a set of row ids. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_string [BatchInputString] JSON array of row ids. # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def batch_read_draft_table_rows_with_http_info(table_id_or_name, batch_input_string, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RowsBatchApi.batch_read_draft_table_rows ...' end # verify the required parameter 'table_id_or_name' is set if @api_client.config.client_side_validation && table_id_or_name.nil? fail ArgumentError, "Missing the required parameter 'table_id_or_name' when calling RowsBatchApi.batch_read_draft_table_rows" end # verify the required parameter 'batch_input_string' is set if @api_client.config.client_side_validation && batch_input_string.nil? fail ArgumentError, "Missing the required parameter 'batch_input_string' when calling RowsBatchApi.batch_read_draft_table_rows" end # resource path local_var_path = '/cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/read'.sub('{' + 'tableIdOrName' + '}', CGI.escape(table_id_or_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(batch_input_string) # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || ['hapikey', 'oauth2'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: RowsBatchApi#batch_read_draft_table_rows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a set of rows # Returns rows in the `published` version of the specified table, given a set of row ids. **Note:** This endpoint can be accessed without any authentication if the table is set to be allowed for public access. # @param table_id_or_name [String] The ID or name of the table to query. # @param batch_input_string [BatchInputString] The JSON array of row ids # @param [Hash] opts the optional parameters # @return [Object] def batch_read_table_rows(table_id_or_name, batch_input_string, opts = {}) data, _status_code, _headers = batch_read_table_rows_with_http_info(table_id_or_name, batch_input_string, opts) data end # Get a set of rows # Returns rows in the `published` version of the specified table, given a set of row ids. **Note:** This endpoint can be accessed without any authentication if the table is set to be allowed for public access. # @param table_id_or_name [String] The ID or name of the table to query. # @param batch_input_string [BatchInputString] The JSON array of row ids # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def batch_read_table_rows_with_http_info(table_id_or_name, batch_input_string, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RowsBatchApi.batch_read_table_rows ...' end # verify the required parameter 'table_id_or_name' is set if @api_client.config.client_side_validation && table_id_or_name.nil? fail ArgumentError, "Missing the required parameter 'table_id_or_name' when calling RowsBatchApi.batch_read_table_rows" end # verify the required parameter 'batch_input_string' is set if @api_client.config.client_side_validation && batch_input_string.nil? fail ArgumentError, "Missing the required parameter 'batch_input_string' when calling RowsBatchApi.batch_read_table_rows" end # resource path local_var_path = '/cms/v3/hubdb/tables/{tableIdOrName}/rows/batch/read'.sub('{' + 'tableIdOrName' + '}', CGI.escape(table_id_or_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(batch_input_string) # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || ['hapikey', 'oauth2'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: RowsBatchApi#batch_read_table_rows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Replace rows in batch in draft table # Replaces multiple rows as a batch in the `draft` version of the table. See the endpoint `PUT /tables/{tableIdOrName}/rows/{rowId}/draft` for details on updating a single row. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_hub_db_table_row_v3_request [BatchInputHubDbTableRowV3Request] JSON array of row objects. # @param [Hash] opts the optional parameters # @return [Object] def batch_replace_draft_table_rows(table_id_or_name, batch_input_hub_db_table_row_v3_request, opts = {}) data, _status_code, _headers = batch_replace_draft_table_rows_with_http_info(table_id_or_name, batch_input_hub_db_table_row_v3_request, opts) data end # Replace rows in batch in draft table # Replaces multiple rows as a batch in the `draft` version of the table. See the endpoint `PUT /tables/{tableIdOrName}/rows/{rowId}/draft` for details on updating a single row. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_hub_db_table_row_v3_request [BatchInputHubDbTableRowV3Request] JSON array of row objects. # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def batch_replace_draft_table_rows_with_http_info(table_id_or_name, batch_input_hub_db_table_row_v3_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RowsBatchApi.batch_replace_draft_table_rows ...' end # verify the required parameter 'table_id_or_name' is set if @api_client.config.client_side_validation && table_id_or_name.nil? fail ArgumentError, "Missing the required parameter 'table_id_or_name' when calling RowsBatchApi.batch_replace_draft_table_rows" end # verify the required parameter 'batch_input_hub_db_table_row_v3_request' is set if @api_client.config.client_side_validation && batch_input_hub_db_table_row_v3_request.nil? fail ArgumentError, "Missing the required parameter 'batch_input_hub_db_table_row_v3_request' when calling RowsBatchApi.batch_replace_draft_table_rows" end # resource path local_var_path = '/cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/replace'.sub('{' + 'tableIdOrName' + '}', CGI.escape(table_id_or_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(batch_input_hub_db_table_row_v3_request) # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || ['hapikey', 'oauth2'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: RowsBatchApi#batch_replace_draft_table_rows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update rows in batch in draft table # Updates multiple rows as a batch in the `draft` version of the table. See the endpoint `PATCH /tables/{tableIdOrName}/rows/{rowId}/draft` for details on updating a single row. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_json_node [BatchInputJsonNode] JSON array of row objects. # @param [Hash] opts the optional parameters # @return [Object] def batch_update_draft_table_rows(table_id_or_name, batch_input_json_node, opts = {}) data, _status_code, _headers = batch_update_draft_table_rows_with_http_info(table_id_or_name, batch_input_json_node, opts) data end # Update rows in batch in draft table # Updates multiple rows as a batch in the `draft` version of the table. See the endpoint `PATCH /tables/{tableIdOrName}/rows/{rowId}/draft` for details on updating a single row. # @param table_id_or_name [String] The ID or name of the table # @param batch_input_json_node [BatchInputJsonNode] JSON array of row objects. # @param [Hash] opts the optional parameters # @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers def batch_update_draft_table_rows_with_http_info(table_id_or_name, batch_input_json_node, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: RowsBatchApi.batch_update_draft_table_rows ...' end # verify the required parameter 'table_id_or_name' is set if @api_client.config.client_side_validation && table_id_or_name.nil? fail ArgumentError, "Missing the required parameter 'table_id_or_name' when calling RowsBatchApi.batch_update_draft_table_rows" end # verify the required parameter 'batch_input_json_node' is set if @api_client.config.client_side_validation && batch_input_json_node.nil? fail ArgumentError, "Missing the required parameter 'batch_input_json_node' when calling RowsBatchApi.batch_update_draft_table_rows" end # resource path local_var_path = '/cms/v3/hubdb/tables/{tableIdOrName}/rows/draft/batch/update'.sub('{' + 'tableIdOrName' + '}', CGI.escape(table_id_or_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(batch_input_json_node) # return_type return_type = opts[:return_type] || 'Object' # auth_names auth_names = opts[:auth_names] || ['hapikey', 'oauth2'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: RowsBatchApi#batch_update_draft_table_rows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end end end