You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First release of the Flex Net Sim Backend API. Built with Flask, this unofficial API powers the backend of the Flex Net Sim Playground web app.
Between the changes:
- Added networks: Cost239, EuroCore, GermanNet, UKNet.
- Implemented K routes parameter (default 3, max 6).
- Added ExactFit algorithm.
- Created /help endpoint for API documentation.
- Updated README.md with /help endpoint and parameter details.
- Renamed 'bitrate' to "fixed-grid", added 'flex-rate' option.
- Updated .ignore.
- Added versioning.
- Added link to README.
This is a Flask-based backend API that runs the FlexNetSim C++ library. It is an unofficial API that powers the backend for the web app deployed at [www.in-progress.com](www.in-progress.com).
3
+
Flask-based backend API for integrating the FlexNetSim C++ library, powering the web application.
4
4
5
5
## Prerequisites
6
6
7
7
* Python 3.9 or higher
8
8
* g++ (GNU C++ Compiler)
9
9
* Docker (for containerization)
10
-
* Google Cloud SDK (for deployment to GKE) -> In progress.
11
-
* A Google Cloud Project with Google Kubernetes Engine (GKE) and Google Container Registry (GCR) enabled -> In progress.
10
+
* Google Cloud SDK (for deployment to Cloud Run)
11
+
* A Google Cloud Project with Cloud Run API enabled.
**Example `curl`request with all parameters specified:**
66
+
```bash
47
67
curl -X POST -H "Content-Type: application/json" \
48
68
-d '{
49
69
"algorithm": "FirstFit",
@@ -56,7 +76,27 @@ This is a Flask-based backend API that runs the FlexNetSim C++ library. It is an
56
76
"bitrate": "bitrate" -> (filename in the ./bitrates folder)
57
77
}' \
58
78
http://127.0.0.1:5000/run_simulation
79
+
```
80
+
81
+
**Response**:
82
+
- 200 OK: Simulation executed successfully. The response body will be a JSON object with the following structure:
83
+
```JSON
84
+
{
85
+
"output": "string", // Simulation output results
86
+
"error": "string" // Empty string if no errors
87
+
}
59
88
```
89
+
- 400 Bad Request: Indicates an error in the request, such as missing or invalid parameters. The response body will be a JSON object with an `"error"` field describing the issue.
90
+
- 500 Internal Server Error: Indicates a server-side error, either during compilation or simulation execution. The response body will be a JSON object with `"error"` and "details" fields providing more information about the error.
91
+
92
+
### `/help` (GET)
93
+
94
+
This endpoint provides detailed information about the `/run_simulation` endpoint, including the expected request structure, parameters, allowed values, and response formats.
95
+
96
+
**Request**:
97
+
```bash
98
+
curl http://127.0.0.1:5000/help
99
+
```
60
100
61
101
## Dockerization
62
102
@@ -72,4 +112,56 @@ docker run -p 8080:8080 fns-api
72
112
To stop:
73
113
```bash
74
114
docker stop fns-api
75
-
```
115
+
```
116
+
117
+
## GCloud Deployment Configuration
118
+
119
+
As a prerequisite is mandatory to apply the following steps to the GCloud project for the docker image build and upload to artifacts, and also service account creation and IAM policy binding:
120
+
121
+
[GCloud Configuration Video Tutorial](https://www.youtube.com/watch?v=KQUKDiBz3IA)
122
+
123
+
This video will guide you through the necessary configurations in the Google Cloud Console to prepare your project for Cloud Run deployments using GitHub Actions.
124
+
125
+
**Key Reminders from the Video &for Successful Deployment:**
126
+
127
+
***Keep Track of Docker Image Name, Project ID:** Note these down during the video configuration, as you will need them in subsequent steps and for your GitHub Actions workflow.
128
+
***Service Account Email:** Ensure you create a Service Account as shown in the video and securely download and store the JSON key file. You'll also need to note the Service Account's email address.
129
+
130
+
**Post-Configuration Steps (using `gcloud` and `cloud-run`):**
131
+
132
+
1. Activate necessary apis:
133
+
134
+
*`gcloud services enable run.googleapis.com`
135
+
136
+
2. Create cloud run service:
137
+
* Navigate to the Cloud Run section in your Google Cloud Console.
138
+
* Create a **Service**.
139
+
* Select *Use an inline editor to create a function*.
140
+
* Set a name, in this case*fns-api-cloud-run* will be used.
141
+
* Note down the Endpoint URL, because it will the defaul url for the API.
142
+
* Select the authetification preferences.
143
+
* Create.
144
+
145
+
3. Update access of service accounts to cloud run resources:
gcloud iam service-accounts add-iam-policy-binding "<YOUR_PROJECT_NUMBER>-compute@developer.gserviceaccount.com" --member="serviceAccount:<SERVICE_ACCOUNT_EMAIL>" --role="roles/iam.serviceAccountActor"
155
+
```
156
+
157
+
4. **Test the Deployed API (using `curl`):**
158
+
159
+
Use the `curl`command with the `ENDPOINT-URL` you obtained from the previous steps to test your deployed API. Replace `YOUR-ENDPOINT-URL` with the actual `ENDPOINT-URL`.
Remember that depending on the authetification preferences you might need to authetificate to send request to the Endpoint just created.
166
+
167
+
**Remember**: These GCloud configurations, along with the repository's `gke-cd.yml` GitHub Actions workflow and correctly configured GitHub secrets, are essential for successful automated deployment of your FlexNetSim-API application to Google Cloud Run.
0 commit comments