require 'json' require 'p4_web_api_client/connection' require 'p4_project_services_data' require 'phoenix_services_client/version' module PhoenixServicesClient class Client attr_accessor :connection def initialize(conn) if !conn.is_a?(P4WebApiClient::Connection) conn[:prefix] = '/p4_phoenix_services/v1' unless conn.key?(:prefix) conn = P4WebApiClient::Connection.new(conn) end @connection = conn end def close connection.run_method_no_body(:delete, "/sessions/#{connection.session_token}") end # Provides standard I/O style interface, where when called in a block, # will automatically close() the client when done. Otherwise, your code # should call client.close() manually. def self.open(connection) client = Client.new(connection) if block_given? yield client else return client end ensure client.close if block_given? && client end # Return information about the session def session(token) execute_method_no_body(:get, "sessions/#{token}") end def projects arr = execute_method_no_body(:get, 'projects') arr.map { |x| P4ProjectServicesData::Project.from_hash(x) } end def create_project(project) unless project.is_a?(P4ProjectServicesData::Project) project = P4ProjectServicesData::Project.new(project) end obj = execute_method_with_body(:post, '/projects', nil, project.to_h) P4ProjectServicesData::Project.from_hash(obj) end private def execute_method_no_body(method, path, params = nil) response = connection.run_method_no_body(method, path, params) JSON.parse(response.body) if response.body && !response.body.empty? end def execute_method_with_body(method, path, params = nil, body = nil) response = connection.run_method_with_body(method, path, params, body) JSON.parse(response.body) if response.body && !response.body.empty? end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 13972 | tjuricek |
Removing old microservice implementations. The system is now mostly a monolith. Eventually there will be a websocket service. |
||
#2 | 13635 | tjuricek |
Exploring modular web applications with Sinatra. If the app has fairly unique content per page, Sinatra works really well actually. (Mostly because it's a thin layer over Rack.) Sharing anything though, basically means implementing a module or base class and implementing it everywhere. An added benefit is that these applications could be used in Rails apps as well. I'd probably think hard about this, because Rails tends to be a resource hog. Here's an example config.ru I used for running against the dev system: require 'pms' app = Pms::App.new Pms::Login.settings.p4_web_api_url = http://172.16.100.20/p4_web_api/v1 ProjectApp.settings.phoenix_services_url = http://172.16.100.20/p4_phoenix_services/v1 app.settings.static = :true app.settings.public_folder = File.absolute_path('../../ui/pms', __FILE__) puts "public_folder is #{app.settings.public_folder}" run app |
||
#1 | 13470 | tjuricek |
Phoenix notification services, client API, including new phoenix_updater This is an interim commit containing a first pass implementation of the phoenix_updater. Notably missing parts: - The Qt API doesn't yet actually interact with the phoenix_updater - The phoenix_services web service doesn't filter out notifications I *may* end up creating another web application *just* to filter out notifications, since this may end up taking up a lot of background workers. |