Create a Fleet using the API
Overviewβ
In this tutorial, we will walk through the steps needed to create a Fleet using an API call. The tutorial will provide an example YAML for the Fleet, however the steps will work with any YAML.
By the end of this tutorial, you'll be able to:
- Call the Shipyard API to create a Fleet
Setupβ
First, download the YAML configuration file named tutorial.yaml
. This configuration file contains all of the details for a Fleet in Shipyard.
Feel free to peruse this YAML beforehand so you understand everything that it's doing. The YAML creates three Vessels in a Fleet:
- Execute Fivetran Sync
- Execute dbt Cloud Job
- Trigger Tableau Datasource Refresh
The YAML as created does not have any inputs filled out. If you have inputs for the three services in the example, feel free to replace <your_value>
with actual values for the Blueprints.
The API call that we will use in this tutorial requires that you have the following:
Once we have those two values, we are ready to get started.
Stepsβ
- Copy and paste the following code into your development environment:
import requests
headers = {
'X-Shipyard-API-Key': '<Your-API-Key>',
'Content-Type': 'application/x-www-form-urlencoded',
}
with open('tutorial.yaml', 'rb') as f:
data = f.read()
response = requests.put(
'https://api.app.shipyardapp.com/orgs/<Your-Org-ID>/projects/<Your-Project-ID>/fleets',
headers=headers,
data=data,
)
print(response.text)
Ensure that the
requests
package is installed by runningpip install requests
orpip3 install requests
.Insert your Shipyard API Key, Organization ID, and Project ID into the code that you pasted. You can find your Project ID in the URL in Shipyard: app.shipyardapp.com/Shipyard%20Tutorials/projects/
d93de112-5d5a-40a9-b1cd-f329d504ab82
/fleets
- Run the script. If the API call is successful, you will receive the YAML printed back to you with the print statement at the end of the script.
- Head into Shipyard and the specific Project whose ID you added into the Python script earlier. You should see the Fleet listed in the Project now.
- Click the Fleet name to open the Fleet Builder where you can enter any inputs that you left blank from the initial YAML.
You've successfully created a Fleet using a Shipyard API call.