# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. # typed: true # frozen_string_literal: true require 'faraday' require 'faraday/multipart' require 'sorbet-runtime' module OpenApiSDK extend T::Sig class Workspaces extend T::Sig sig { params(sdk_config: SDKConfiguration).void } def initialize(sdk_config) @sdk_configuration = sdk_config end sig { returns(::OpenApiSDK::Operations::GetWorkspacesResponse) } def get_all # get_all - Get workspaces for a user # Returns a list of workspaces a user has access too url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/v1/workspaces" headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GetWorkspacesResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, T::Array[::OpenApiSDK::Shared::Workspace]) res.workspaces = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { returns(::OpenApiSDK::Operations::GetWorkspaceByContextResponse) } def get # get - Get workspace by context # Get information about a particular workspace by context. url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/v1/workspace" headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GetWorkspaceByContextResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::WorkspaceAndOrganization) res.workspace_and_organization = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(request: ::OpenApiSDK::Shared::Workspace).returns(::OpenApiSDK::Operations::CreateWorkspaceResponse) } def create(request) # create - Create a workspace # Creates a workspace url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/v1/workspace" headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :request, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::CreateWorkspaceResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Workspace) res.workspace = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String).returns(::OpenApiSDK::Operations::GetWorkspaceResponse) } def get_by_id(workspace_id) # get_by_id - Get workspace # Get information about a particular workspace. request = ::OpenApiSDK::Operations::GetWorkspaceRequest.new( workspace_id: workspace_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GetWorkspaceRequest, base_url, '/v1/workspace/{workspace_id}', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GetWorkspaceResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Workspace) res.workspace = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String, workspace: ::OpenApiSDK::Shared::Workspace).returns(::OpenApiSDK::Operations::UpdateWorkspaceDetailsResponse) } def update_details(workspace_id, workspace) # update_details - Update workspace details # Update information about a particular workspace. request = ::OpenApiSDK::Operations::UpdateWorkspaceDetailsRequest.new( workspace_id: workspace_id, workspace: workspace ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::UpdateWorkspaceDetailsRequest, base_url, '/v1/workspace/{workspace_id}/details', request, @sdk_configuration.globals ) headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :workspace, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::UpdateWorkspaceDetailsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String).returns(::OpenApiSDK::Operations::GetWorkspaceSettingsResponse) } def get_settings(workspace_id) # get_settings - Get workspace settings # Get settings about a particular workspace. request = ::OpenApiSDK::Operations::GetWorkspaceSettingsRequest.new( workspace_id: workspace_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GetWorkspaceSettingsRequest, base_url, '/v1/workspace/{workspace_id}/settings', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GetWorkspaceSettingsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::WorkspaceSettings) res.workspace_settings = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String, workspace_settings: ::OpenApiSDK::Shared::WorkspaceSettings).returns(::OpenApiSDK::Operations::UpdateWorkspaceSettingsResponse) } def update_settings(workspace_id, workspace_settings) # update_settings - Update workspace settings # Update settings about a particular workspace. request = ::OpenApiSDK::Operations::UpdateWorkspaceSettingsRequest.new( workspace_id: workspace_id, workspace_settings: workspace_settings ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::UpdateWorkspaceSettingsRequest, base_url, '/v1/workspace/{workspace_id}/settings', request, @sdk_configuration.globals ) headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :workspace_settings, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.put(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::UpdateWorkspaceSettingsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String).returns(::OpenApiSDK::Operations::GetWorkspaceTeamResponse) } def get_team(workspace_id) # get_team - Get team members for a particular workspace request = ::OpenApiSDK::Operations::GetWorkspaceTeamRequest.new( workspace_id: workspace_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GetWorkspaceTeamRequest, base_url, '/v1/workspace/{workspace_id}/team', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GetWorkspaceTeamResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::WorkspaceTeamResponse) res.workspace_team_response = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String, email: ::String).returns(::OpenApiSDK::Operations::GrantUserAccessToWorkspaceResponse) } def grant_access(workspace_id, email) # grant_access - Grant a user access to a particular workspace request = ::OpenApiSDK::Operations::GrantUserAccessToWorkspaceRequest.new( workspace_id: workspace_id, email: email ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GrantUserAccessToWorkspaceRequest, base_url, '/v1/workspace/{workspace_id}/team/email/{email}', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.put(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GrantUserAccessToWorkspaceResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::WorkspaceInviteResponse) res.workspace_invite_response = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String, user_id: ::String).returns(::OpenApiSDK::Operations::RevokeUserAccessToWorkspaceResponse) } def revoke_access(workspace_id, user_id) # revoke_access - Revoke a user's access to a particular workspace request = ::OpenApiSDK::Operations::RevokeUserAccessToWorkspaceRequest.new( workspace_id: workspace_id, user_id: user_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::RevokeUserAccessToWorkspaceRequest, base_url, '/v1/workspace/{workspace_id}/team/{userId}', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.delete(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::RevokeUserAccessToWorkspaceResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String).returns(::OpenApiSDK::Operations::GetWorkspaceTokensResponse) } def get_tokens(workspace_id) # get_tokens - Get tokens for a particular workspace request = ::OpenApiSDK::Operations::GetWorkspaceTokensRequest.new( workspace_id: workspace_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GetWorkspaceTokensRequest, base_url, '/v1/workspace/{workspace_id}/tokens', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GetWorkspaceTokensResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, T::Array[::OpenApiSDK::Shared::WorkspaceToken]) res.workspace_tokens = out end elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String, workspace_token: ::OpenApiSDK::Shared::WorkspaceToken).returns(::OpenApiSDK::Operations::CreateWorkspaceTokenResponse) } def create_token(workspace_id, workspace_token) # create_token - Create a token for a particular workspace request = ::OpenApiSDK::Operations::CreateWorkspaceTokenRequest.new( workspace_id: workspace_id, workspace_token: workspace_token ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::CreateWorkspaceTokenRequest, base_url, '/v1/workspace/{workspace_id}/tokens', request, @sdk_configuration.globals ) headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :workspace_token, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::CreateWorkspaceTokenResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String, token_id: ::String).returns(::OpenApiSDK::Operations::DeleteWorkspaceTokenResponse) } def delete_token(workspace_id, token_id) # delete_token - Delete a token for a particular workspace request = ::OpenApiSDK::Operations::DeleteWorkspaceTokenRequest.new( workspace_id: workspace_id, token_id: token_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::DeleteWorkspaceTokenRequest, base_url, '/v1/workspace/{workspace_id}/tokens/{tokenID}', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.delete(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::DeleteWorkspaceTokenResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status >= 200 && r.status < 300 elsif r.status >= 400 && r.status < 500 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end sig { params(workspace_id: ::String).returns(::OpenApiSDK::Operations::GetWorkspaceFeatureFlagsResponse) } def get_feature_flags(workspace_id) # get_feature_flags - Get workspace feature flags request = ::OpenApiSDK::Operations::GetWorkspaceFeatureFlagsRequest.new( workspace_id: workspace_id ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::GetWorkspaceFeatureFlagsRequest, base_url, '/v1/workspace/{workspace_id}/feature_flags', request, @sdk_configuration.globals ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GetWorkspaceFeatureFlagsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::WorkspaceFeatureFlagResponse) res.workspace_feature_flag_response = out end elsif r.status >= 500 && r.status < 600 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::Error) res.error = out end end res end end end