Skip to content

Commit

Permalink
Merge pull request #29 from hostari/extract-hash-method
Browse files Browse the repository at this point in the history
Add extract_hash method
  • Loading branch information
paula4230 authored Nov 24, 2022
2 parents 875adec + 96f761b commit 9ae7c82
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fleet_app/brooce_command/create.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FleetApp
class Server
class BrooceCommand
# Sends a brooce command to be executed.
# Sends a brooce command to be executed for a server.
#
# Use `host` to specify the queue name in brooce to send to.
# For example, use `2013191.xyz` if the command should be executed on tms1.
Expand Down
31 changes: 31 additions & 0 deletions src/fleet_app/extract_hash.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module FleetApp
class ModLibrary
# Downloads a mod as a zip file from a library (e.g. Thunderstore) into /srv/{mod_library} folder of tms7,
# unzips the file, and walks through each of the directories to extract the sha256 hashes from each file.

# Host will always be tms7 and does not require a server_id.

# `body` is an optional, JSON-formatted string that is sent as the request body which defaults to an empty string.
# This is used to override the default command in fleet app.
# For example, you can send this: `{command: "echo 'foobar'"}.to_json`
#
# `environment` is an optional string that specifies which fleet app to send the request to.

def self.extract_hash(host : String, command : String = "", environment : String = "production", username : String = "")
FleetApp::ClientWrapper.new(environment).post(
game_name: game_name,
path: "/api/v1/mod_library/brooce_command?queue_name=#{host}",
body: {command: command}.to_json
)
end

def self.extract_hash_with_auth(host : String, basic_auth : String, command : String = "", environment : String = "production", username : String = "")
FleetApp::ClientWrapper.new(environment).post_with_auth(
game_name: game_name,
path: "/api/v1/mod_library/brooce_command?queue_name=#{host}",
body: {command: command}.to_json,
basic_auth: basic_auth
)
end
end
end

0 comments on commit 9ae7c82

Please sign in to comment.