Skip to main content

Snapser CLI Tool

Project description

Snapser CLI Tool

Dependencies

The Snapser CLI tool depends on Python 3.X and Pip. MacOS comes pre installed with Python. But please make sure you are running Python 3.X. On Windows, you can download Python 3.X from the Windows store. Some of the commands also need docker.

Installation

Installing PIP on MacOS

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py

Installing PIP on Windows

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

Once you have Python and Pip installed

pip install --user snapctl

If you also have Python 2.X on your machine, you may have to run the following command instead

pip3 install --user snapctl
After you install snapctl you may have to add the python bin folder to your path. For example, on MacOSX this is usually **~/Library/Python/3.9/bin**. On Windows this is usually **C:\Users\username\AppData\Roaming\Python\Python39\Scripts**.

Upgrade

Upgrade your snapctl version

pip install --user snapctl --upgrade

Setup

Get your Snapser Access Key

Log in to your Snapser account. Click on your user icon on the top right and select, User Account. In the left navigation click on Developer which will bring up your Personal API Key widget. If you have not generated an API Key yet click on the Generate button to generate a new key. You can generate up to 3 API Keys per user account.

Please make sure you save your API key in a safe place. You will not be able to see it again.

Setup a local config

You have three ways to pass the API key to Snapctl

  1. Pass it via a command line argument with every command
  2. Pass it via an environment variable
  3. Pass it via a config file

Command line argument

Every Snapser command can take a command line argument --api-key <your_key>. This will take precedence over other methods.

Environment Variable

You can set an Environment variable SNAPSER_API_KEY=<your_key> and then run your snapctl commands. This will be evaluated after verifying if there is any command line argument.

Config file

Create a file named ~/.snapser/config. Open it using the editor of your choice and replace with your personal Snapser Access key. Save the file. Advantage of using this method is you can use the --profile argument with your snapctl command to use different API keys.

[default]
snapser_access_key = <key>

Or you can run the following command

on MacOSX

# $your_api_key = Your Snapser developer key
echo -e "[default]\nSNAPSER_API_KEY=$your_api_key" > ~/.snapser/config

on Windows Powershell

# $your_api_key = Your Snapser developer key
echo "[default]
SNAPSER_API_KEY=$your_api_key" | Out-File -encoding utf8 ~\.snapser\config

Verify Snapctl installation

snapctl --version

You should see the latest snapctl version in the output

Advanced Setup

Snapser by default supports access to multiple accounts. You can create multiple profiles in your Snapser config ~/.snapser/config.

[profile personal]
snapser_access_key = <key>

[profile professional]
snapser_access_key = <key>

You can then set an environment variable telling Snapser which profile you want to use.

# Mac
export SNAPSER_PROFILE="my_profile_name";

# Windows
setx SNAPSER_PROFILE="my_profile_name";

Or you can pass --profile my_profile_name with every command to tell Snapser to use a particular profile.

Commands

Run the following to see the list of commands Snapser supports

snapctl --help

BYO Snap - Bring your own Snap

1. byosnap help

See all the supported commands

# Help for the byosnap command
snapctl byosnap --help

2. byosnap create

Create a custom snap. Note that you will have to build, push and publish your snap image, for it to be useable in a Snapend.

# Help for the byosnap command
snapctl byosnap create --help

# Create a new snap
# $byosnap_sid = Snap ID for your snap. Start start with `byosnap-`
# $name = User friendly name for your BYOSnap
# $desc = User friendly description
# $platform = One of linux/arm64, linux/amd64
# $language = One of go, python, ruby, c#, c++, rust, java, node

# Example:
# snapctl byosnap create byosnap-jinks-flask --name "Jinks Flask Microservice" --desc "Custom Microservice" --platform "linux/arm64" --language "go"
snapctl byosnap create $byosnap_sid --name "$name" --desc "$desc" --platform "$platform" --language "$language"

3. byosnap build

Build your snap image

# Help for the byosnap command
snapctl byosnap build --help

# Publish a new image
# $byosnap_sid = Snap ID for your snap
# $image_tag = An image tag for your snap
# $code_root_path = Local code path where your Dockerfile is present
# Example:
# snapctl byosnap build byosnap-jinks-flask --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
snapctl byosnap build $byosnap_sid --tag $image_tag --path $code_root_path

4. byosnap push

Push your snap image to Snapser

# Help for the byosnap command
snapctl byosnap push --help

# Publish a new image
# $byosnap_sid = Snap ID for your snap
# $image_tag = An image tag for your snap
# Example:
# snapctl byosnap push byosnap-jinks-flask --tag my-first-image
snapctl byosnap push $byosnap_sid --tag $image_tag

5. byosnap upload-docs

Upload swagger.json and README.md for you Snap

# Help for the byogs command
snapctl byosnap upload-docs --help

# Publish a new image
# $byogs_sid = Game server ID for your snap
# $image_tag = An image tag for your snap
# $code_root_path = Local code path where your swagger.json and README.md files are present
# Example:
# snapctl byosnap upload-docs byosnap-jinks-flask --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
snapctl byosnap upload-docs $byogs_sid --tag $image_tag --path $code_root_path

6. byosnap publish-image

Publish a custom snap code image. This command executes, build, push and upload-docs one after the other.

# Help for the byosnap command
snapctl byosnap publish-image --help

# Publish a new image
# $byosnap_sid = Snap ID for your snap
# $image_tag = An image tag for your snap
# $code_root_path = Local code path where your Dockerfile is present
# Example:
# snapctl byosnap publish-image byosnap-jinks-flask --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
snapctl byosnap publish-image $byosnap_sid --tag $image_tag --path $code_root_path

7. byosnap publish-version

Publish a new version for your Snap. Only after your Snap version is published, you will be able to use your snap in your Snapend. This command should be run after push or publish-image commands.

# Help for the byosnap command
snapctl byosnap publish-version --help

# Publish a new image
# $byosnap_sid = Snap ID for your snap
# $image_tag = An image tag for your snap
# $prefix = Prefix for your snap Eg: /v1
# $version = Semantic version for your snap Eg: v0.0.1
# $ingress_port = Ingress port for your snap Eg: 5003
# Example:
# snapctl byosnap publish-image byosnap-jinks-flask --tag my-first-image --prefix /v1 --version v0.0.1 --http-port 5003
snapctl byosnap publish-version $byosnap_sid --tag $image_tag --prefix $prefix --version $version --http-port $ingress_port

BYO Game Server - Bring your own Game Server

1. byogs help

See all the supported commands

# Help for the byogs command
snapctl byogs --help

2. byogs create

Create a custom game server. Note that you will have to build, push and publish your game server image, for it to be useable in a Snapend fleet.

# Help for the byosnap command
snapctl byogs create --help

# Create a new snap
# $byogs_sid = Game server ID for your snap. Should start with `byogs-`
# $name = User friendly name for your BYOGs
# $desc = User friendly description
# $platform = Currently only supported platform is linux/amd64
# $language = One of go, python, ruby, c#, c++, rust, java, node

# Example:
# snapctl byogs create byosnap-jinks-gs --name "Jinks Flask Microservice" --desc "Custom Microservice" --platform "linux/arm64" --language "go"
snapctl byogs create $byogs_sid --name "$name" --desc "$desc" --platform "$platform" --language "$language"

3. byogs build

Build your custom game server image.

# Help for the byogs command
snapctl byogs build --help

# Publish a new image
# $byogs_sid = Game server ID for your snap
# $image_tag = An image tag for your snap
# $code_root_path = Local code path where your Dockerfile is present
# Example:
# snapctl byogs build byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
snapctl byogs build $byogs_sid --tag $image_tag --path $code_root_path

4. byogs push

Push your custom game server image.

# Help for the byogs command
snapctl byogs push --help

# Publish a new image
# $byogs_sid = Game server ID for your snap
# $image_tag = An image tag for your snap
# Example:
# snapctl byogs push byosnap-jinks-gs --tag my-first-image
snapctl byogs push $byogs_sid --tag $image_tag

5. byogs publish-image

Publish your custom game server image. This command executes, build and push one after the other.

# Help for the byogs command
snapctl byogs publish-image --help

# Publish a new image
# $byogs_sid = Game server ID for your snap
# $image_tag = An image tag for your snap
# $code_root_path = Local code path where your Dockerfile is present
# Example:
# snapctl byogs publish-image byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
snapctl byogs publish-image $byogs_sid --tag $image_tag --path $code_root_path

6. byogs publish-version

Publish a new version for your game server. Only after your game server version is published, you will be able to use it in your Snapend fleet. This command should be run after you push or publish-image commands.

# Help for the byogs command
snapctl byogs publish-version --help

# Publish a new image
# $byogs_sid = Snap ID for your snap
# $image_tag = Any image tag for your snap
# $prefix = Prefix for your snap Eg: /v1
# $version = Semantic version for your snap Eg: v0.0.1
# $ingress_port = Ingress port for your snap Eg: 5003
# Example:
# snapctl byogs publish-image byosnap-jinks-gs --tag my-first-image --prefix /v1 --version v0.0.1 --http-port 5003
snapctl byogs publish-version $byogs_sid --tag $image_tag --prefix $prefix --version $version --http-port $ingress_port

Snapend

1. snapend help

See all the supported commands

# Help for the byogs command
snapctl snapend --help

2. Snapend Downloads

Download SDKs and Protos for your Snapend

# Help for the byogs command
snapctl snapend download --help

# Download your Snapend SDK and Protos
# $snapend_id = Cluster Id
# $category = client-sdk, server-sdk, protos, admin-settings
# $sdk_type = One of the supported SDK names:
# client-sdk(unity, unreal, roblox, godot, cocos, ios-objc, ios-swift, android-java, android-kotlin, web-ts, web-js),
# server-sdk(csharp, cpp, lua, ts, go, python, kotlin, java, c, node, js, perl, php, closure, ruby, rust),
# protos(go)
# Example:
# snapctl snapend download gx5x6bc0 --category client-sdk --type unity
snapctl snapend download $snapend_id --category $category --type $sdk_type

3. Update Snapend BYOSnap or BYOGs versions

Update your BYOSnap or BYOGs versions for the Snapend

# Help for the byogs command
snapctl snapend update --help

# Update your Snapend with new BYOSnaps and BYOGs
# $snapend_id = Cluster Id
# $byosnaps = Comma separated list of BYOSnap ids and version.
# $byogs = Comma separated list of BYOGs fleet name, id and version.
# --blocking = (Optional) This makes sure the CLI waits till your Snapend is live.
# Note at least one of the two needs to be present
# Example:
# snapctl snapend update gx5x6bc0 --byosnaps byosnap-service-1:v1.0.0,byosnap-service--2:v1.0.0 --byogs byogs-fleet-one:gs-1:v0.0.1,my-fleet-two:gs-2:v0.0.4
# snapctl snapend update gx5x6bc0 --byosnaps byosnap-service-1:v1.0.0,byosnap-service--2:v1.0.0 --byogs byogs-fleet-one:gs-1:v0.0.1,my-fleet-two:gs-2:v0.0.4 --blocking
snapctl snapend update $snapend_id --byosnaps $byosnaps --byogs $byogs --blocking

4. Get the Snapend state

Get the Snapend state

# Help for the byogs command
snapctl snapend state --help

# Get the Snapend state
# $snapend_id = Cluster Id
# Example:
# snapctl snapend state gx5x6bc0
snapctl snapend state $snapend_id

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snapctl-0.22.2.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snapctl-0.22.2-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file snapctl-0.22.2.tar.gz.

File metadata

  • Download URL: snapctl-0.22.2.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Darwin/22.6.0

File hashes

Hashes for snapctl-0.22.2.tar.gz
Algorithm Hash digest
SHA256 1f0db32ce0a9272c4f84087063c83fc6c45bf759818c74690decde6a608bb529
MD5 b91e2b1e6dacb5cf1be077ff730a4f2c
BLAKE2b-256 436061d86bc9a52cf0a4968a96b41fbca2095d6d7ce973fc7c1276ba1fccb62f

See more details on using hashes here.

File details

Details for the file snapctl-0.22.2-py3-none-any.whl.

File metadata

  • Download URL: snapctl-0.22.2-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Darwin/22.6.0

File hashes

Hashes for snapctl-0.22.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f0ab11cf6da1e49656317ea52cd4be459aefc06b326a8aca9436d5bd09ae043
MD5 586b38e618bd86a84db9a29927d784d4
BLAKE2b-256 ab115551e9ff18699342edf65abe62b9af69ca482b263f45b14d5fe176b8a036

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page