require 'p4_web_services_auth' require 'p4_phoenix_services/change_commit_handler' require 'p4_phoenix_services/create_project' require 'p4_phoenix_services/phoenix_updater_client' require 'p4_phoenix_services/helpers' require 'p4_phoenix_services/version' require 'p4_project_services_data' require 'rack/parser' require 'sinatra/base' require 'sinatra/json' include P4ProjectServicesData module P4PhoenixServices class App < Sinatra::Base # Automatically parse content as JSON use Rack::Parser, content_types: { 'application/json' => proc { |body| ::MultiJson.decode body } } use P4WebServicesAuth::AuthMiddleware, settings: settings helpers P4PhoenixServices::Helpers before do content_type 'application/json' end configure do set(:p4, 'port' => '1666') set(:token_path, '/tmp/p4_phoenix_services/tokens') set(:p4_project_services_url, 'http://localhost:4567') set(:p4_project_services_prefix, '/p4_project_services/v1') set(:p4_web_api_url, 'http://example.com') set(:p4_web_api_prefix, '/p4_web_api/v1') set(:phoenix_project_depot, '//phoenix') set(:phoenix_updater_url, 'ws://example.com') set :raise_errors, :environment == :test set :dump_errors, :environment == :development set :show_exceptions, :environment == :development enable :logging end error do err = env['sinatra.error'] msg = err.message if ENV['RACK_ENV'] == 'development' msg += "\n#{err.backtrace.join('\n')}" end e = P4WebServicesAuth::P4Error.default_error(msg) return { MessageCode: e.message_code, MessageSeverity: e.message_severity, MessageText: e.message_text }.to_json end # List Phoenix projects in the system available to the user. get '/v1/projects' do # TODO Right now this *only* filters by extension, we probably need more projects = nil options = {extensions: Extensions::Phoenix.content_type} options[:owners] = params['owners'] if params.key?('owners') options[:names] = params['names'] if params.key?('names') open_projects_client do |c| projects = c.projects(options) end projects.to_json end # Load information about an individual Phoenix project get '/v1/projects/*' do id = params[:splat].join('/') project = nil open_projects_client do |c| project = c.project(id) end project.to_json end # Creates a new project post '/v1/projects' do project = Project.json_create(params) created = nil open_projects_client do |proj| open_web_api_client do |api| cp = CreateProject.new(project_client: proj, settings: settings, web_api_client: api) created = cp.run(project) end end # Expect an exception to have occurred if created is not set created.to_json end # Update part of the project definition patch '/v1/projects/*' do halt 400, 'not implemented' end # Delete the Phoenix project delete '/v1/projects/*' do halt 400, 'not implemented' end # Note that this is an *authenticated* method. So the configuration to # determine which user to use actually comes from the webhook. Hm... post '/v1/change-commit' do values = params['values'] open_web_api_client do |api| cc_handler = ChangeCommitHandler.new( settings: settings, web_api_client: api ) cc_handler.run(values) end end def phoenix_updater_client @phoenix_updater_client ||= init_phoenix_updater_client end def init_phoenix_updater_client P4PhoenixServices::PhoenixUpdaterClient.new(settings.phoenix_updater_url) end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 13972 | tjuricek |
Removing old microservice implementations. The system is now mostly a monolith. Eventually there will be a websocket service. |
||
#8 | 13532 | tjuricek |
Qt SDK: Add constructor that uses an application's QSettings for caching Sessions for each URL Added a simple validateSession remote call to ping the services instance to see if the session is indeed usable. Also, removing puma configuraiton that is automatically generated in the (shared) development instance. |
||
#7 | 13530 | tjuricek |
Add p4_phoenix_services package and Salt configuration for deployment. This uncovered a couple of issues from the C++ API during it's conversion to C++03. So, in a nutshell, most operations, except for notifications, appear to be working (well, using Vagrant machines). |
||
#6 | 13482 | tjuricek |
Fix issues with running the Phoenix test suite against basic CRUD operations. Does *not* test the notifications mechanism, but we have preliminary phoenix project caching on create, and does generate a simple stream for each phoenix project. |
||
#5 | 13472 | tjuricek |
Implementation of the phoenix services side of notification handling. This is just implementation and work-in-progress. Phoenix projects will now have paths cached in the phoenix services process, which we'll use to "guess" what file changes affect which Phoenix project. We basically see a changed path, then see that it might be relevant to one of the Phoenix project stream views, and then issue a "p4 changes -m1 //stream..." to see what the last change number is. If the change number goes up, we trigger an update. Note that how this all gets configured is with an account from notification services to phoenix services, which ideally is some kind of system account that sees all relevant files. Otherwise, you'll likely get changes filtered by protections, and thus, updates may not get sent out. |
||
#4 | 13464 | tjuricek | Allow filtering by owners and params. | ||
#3 | 13459 | tjuricek |
Return the created project when creating a new project, since default values will often be filled out. Allow new projects to be created only with names set. We'll generate an ID at the moment, when I have better indexing, I'll double check for uniqueness. |
||
#2 | 13455 | tjuricek | Basic Phoenix project metadata (the project name) can now be created and read back. | ||
#1 | 13421 | tjuricek |
Skeleton of the p4 phoenix services It's very likely that real 'business logic' will need to happen, but a lot of that is TBD. This is mostly to get the infrastructure in place before we start adding details, like, 'every new project lives under //phoenix/[project]/...', yada yada yada. |