diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b1bd623 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM heroku/heroku:18-build as build + +COPY . /app +WORKDIR /app + +# Setup buildpack +RUN mkdir -p /tmp/buildpack/heroku/go /tmp/build_cache /tmp/env +RUN curl https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/go.tgz | tar xz -C /tmp/buildpack/heroku/go + +#Execute Buildpack +RUN STACK=heroku-18 /tmp/buildpack/heroku/go/bin/compile /app /tmp/build_cache /tmp/env + +# Prepare final, minimal image +FROM heroku/heroku:18 + +COPY --from=build /app /app +ENV HOME /app +WORKDIR /app +RUN useradd -m heroku +USER heroku +CMD /app/bin/openterps \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5fd8c17 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +GO_BUILD_ENV := CGO_ENABLED=0 GOOS=linux GOARCH=amd64 +DOCKER_BUILD=$(shell pwd)/.docker_build +DOCKER_CMD=$(DOCKER_BUILD)/go-getting-started + +$(DOCKER_CMD): clean + mkdir -p $(DOCKER_BUILD) + $(GO_BUILD_ENV) go build -v -o $(DOCKER_CMD) . + +clean: + rm -rf $(DOCKER_BUILD) + +heroku: $(DOCKER_CMD) + heroku container:push web + +build: + export GO111MODULE=on + env GOOS=linux GOARCH=amd64 go build -o bin/openterps -v . \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..8880600 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bin/openterps \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d165afd --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# OpenTerps 🍁 + +An open source API to categorize cannabis and it's terpenes/effects/tastes/smells. + +[docs](https://app.swaggerhub.com/apis-docs/CountryFriedCoders/OpenTerps/0.0.2) + +``` + | + |.| + |\./| + |\./| +. |\./| . +\^.\ |\\.//| /.^/ + \--.|\ |\\.//| /|.--/ + \--.| \ |\\.//| / |.--/ + \---.|\ |\./| /|.---/ + \--.|\ |\./| /|.--/ + \ .\ |.| /. / +_ -_^_^_^_- \ \\ // / -_^_^_^_- _ + - -/_/_/- ^ ^ | ^ ^ -\_\_\- - + /-./ | \.-\ + /-/ | \-\ + ;|' '|; +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + .---. ,---. ,---. .-. .-. _______ ,---. ,---. ,---. .---. ,--, ,-. ,-. +/ .-. ) | .-.\ | .-' | \| ||__ __|| .-' | .-.\ | .-.\ ( .-._) .' .') | | |(| +| | |(_)| |-' )| `-. | | | )| | | `-. | `-'/ | |-' )(_) \ | |(_) | | (_) +| | | | | |--' | .-' | |\ | (_) | | .-' | ( | |--' _ \ \ \ \ | | | | +\ `-' / | | | `--.| | |)| | | | `--.| |\ \ | | ( `-' ) \ `-. | `--. | | + )---' /( /( __.'/( (_) `-' /( __.'|_| \)\ /( `----' \____\|( __.'`-' +(_) (__) (__) (__) (__) (__)(__) (_) +``` diff --git a/bin/openterps b/bin/openterps new file mode 100755 index 0000000..927d476 Binary files /dev/null and b/bin/openterps differ diff --git a/categories/main.go b/categories/main.go new file mode 100644 index 0000000..e84384c --- /dev/null +++ b/categories/main.go @@ -0,0 +1,77 @@ +package categories + +import ( + "net/http" + + "openterps/dbconnector" + "openterps/models" + + "github.com/gin-gonic/gin" +) + +// GET /categories +// Get all categories +func GetCategories(c *gin.Context) { + var categories []models.Category + dbconnector.DB.Find(&categories) + + c.JSON(http.StatusOK, gin.H{"data": categories}) +} + +type categoriesInput struct { + Name string `json:"name" binding:"required"` +} + +// POST /categories +// Create a categories +func CreateCategories(c *gin.Context) { + // Validate input + var input categoriesInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + // Create categories + categories := models.Category{ + Name: input.Name, + } + dbconnector.DB.Create(&categories) + + c.JSON(http.StatusOK, gin.H{"data": categories}) +} + +// PATCH /categories/:id +// Update a categories +func UpdateCategories(c *gin.Context) { + var categories models.Category + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&categories).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Category not found!"}) + return + } + + // Validate input + var input categoriesInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + dbconnector.DB.Model(&categories).Updates(input) + + c.JSON(http.StatusOK, gin.H{"data": categories}) +} + +// DELETE /categories/:id +// Delete a categories +func DeleteCategories(c *gin.Context) { + var categories models.Category + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&categories).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Category not found!"}) + return + } + + dbconnector.DB.Delete(&categories) + + c.JSON(http.StatusOK, gin.H{"data": true}) +} diff --git a/dbConnector/main.go b/dbConnector/main.go new file mode 100644 index 0000000..d4e25ab --- /dev/null +++ b/dbConnector/main.go @@ -0,0 +1,28 @@ +package dbconnector + +import ( + "fmt" + + "gorm.io/driver/postgres" + "gorm.io/gorm" +) + +// TODO turn this stuff into env vars + +var DB *gorm.DB + +// ConnectDatabase - connects to database +// returns gorm DB instance, error +func ConnectDatabase(Host, Port, User, Password, Name string) *gorm.DB { + fmt.Println("Host", Host) + dsn := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", Host, Port, User, Password, Name) + db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{}) + + if err != nil { + fmt.Println("Error connecting to databse: ", dsn) + } + + DB = db + + return DB +} diff --git a/effects/main.go b/effects/main.go new file mode 100644 index 0000000..023936e --- /dev/null +++ b/effects/main.go @@ -0,0 +1,90 @@ +package effects + +import ( + "net/http" + + "openterps/dbconnector" + "openterps/models" + "openterps/simpleauth" + + "github.com/gin-gonic/gin" +) + +// GET /effects +// Get all effects +func GetEffects(c *gin.Context) { + var effects []models.Effect + dbconnector.DB.Find(&effects) + + c.JSON(http.StatusOK, gin.H{"data": effects}) +} + +type effectInput struct { + Name string `json:"name" binding:"required"` +} + +// POST /effect +// Create a effect +func CreateEffect(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + // Validate input + var input effectInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + // Create effect + effect := models.Effect{ + Name: input.Name, + } + dbconnector.DB.Create(&effect) + + c.JSON(http.StatusOK, gin.H{"data": effect}) + } +} + +// PATCH /effects/:id +// Update a effect +func UpdateEffect(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var effect models.Effect + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&effect).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Effect not found!"}) + return + } + + // Validate input + var input effectInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + dbconnector.DB.Model(&effect).Updates(input) + + c.JSON(http.StatusOK, gin.H{"data": effect}) + } +} + +// DELETE /effects/:id +// Delete a effects +func DeleteEffect(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var effect models.Effect + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&effect).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Effect not found!"}) + return + } + + dbconnector.DB.Delete(&effect) + + c.JSON(http.StatusOK, gin.H{"data": true}) + } +} diff --git a/go-server/.swagger-codegen-ignore b/go-server/.swagger-codegen-ignore deleted file mode 100644 index c5fa491..0000000 --- a/go-server/.swagger-codegen-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/go-server/.swagger-codegen/VERSION b/go-server/.swagger-codegen/VERSION deleted file mode 100644 index 812aaaf..0000000 --- a/go-server/.swagger-codegen/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.0.22 \ No newline at end of file diff --git a/go-server/api/swagger.yaml b/go-server/api/swagger.yaml deleted file mode 100644 index 0f865ce..0000000 --- a/go-server/api/swagger.yaml +++ /dev/null @@ -1,823 +0,0 @@ -openapi: 3.0.0 -info: - title: OpenTerps - description: An Open API that contains information about terpenes, the effects, - and the cannabis varieties that contain them. - termsOfService: https://wayhigh.we.bs - contact: - email: benjamminredden@gmail.com - license: - name: Apache 2.0 - url: http://www.apache.org/licenses/LICENSE-2.0.html - version: 0.0.2 -externalDocs: - description: Find out more about OpenTerps - url: https://wayhigh.we.bs -servers: -- url: https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1 -tags: -- name: cannabis - description: The plant. -- name: terpene - description: One of the most important parts of the cannabis plant. -- name: effect - description: The effect of said terpenes. -- name: user - description: The people who love the plant and contribute to this API. -paths: - /terpene: - put: - tags: - - terpene - summary: Update an existing terpene - description: Update terpene in the api - operationId: updateTerpene - requestBody: - $ref: '#/components/requestBodies/Terpene' - responses: - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - "405": - description: Validation exception - post: - tags: - - terpene - summary: Add a new terpene to the api - description: Add new terpene to the api - operationId: addTerpene - requestBody: - $ref: '#/components/requestBodies/Terpene' - responses: - "405": - description: Invalid input - /terpene/findByEffect: - get: - tags: - - terpene - summary: Finds Terpenes by effect - description: Multiple status values can be provided with comma separated strings - operationId: findTerpenesByEffect - parameters: - - name: effect - in: query - description: Effect values that need to be considered for filter - required: true - style: form - explode: true - schema: - type: array - items: - type: string - responses: - "200": - description: successful operation - content: - application/xml: - schema: - type: array - items: - $ref: '#/components/schemas/Terpene' - x-content-type: application/xml - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Terpene' - "400": - description: Invalid effect value - /terpene/{terpeneId}: - get: - tags: - - terpene - summary: Find terpene by ID - description: Returns a single terpene - operationId: getTerpeneById - parameters: - - name: terpeneId - in: path - description: ID of terpene to return - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "200": - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/Terpene' - application/json: - schema: - $ref: '#/components/schemas/Terpene' - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - post: - tags: - - terpene - summary: Updates a terpene in the api - description: Update a single terpene in the API - operationId: updateTerpeneByID - parameters: - - name: terpeneId - in: path - description: ID of terpene that needs to be updated - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - requestBody: - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/body' - responses: - "405": - description: Invalid input - delete: - tags: - - terpene - summary: Deletes a terpene - description: Deletes a terpene from the API - operationId: deleteTerpene - parameters: - - name: api_key - in: header - required: true - style: simple - explode: false - schema: - type: string - - name: terpeneId - in: path - description: Terpene id to delete - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - /cannabis: - put: - tags: - - cannabis - summary: Update an existing cannabis strain - description: Update cannabis strain in the api - operationId: updateCannabisStrain - requestBody: - $ref: '#/components/requestBodies/Cannabis' - responses: - "400": - description: Invalid ID supplied - "404": - description: Cannabis strain not found - "405": - description: Validation exception - post: - tags: - - cannabis - summary: Add a new cannabis strains to the api - description: Add new cannabis strains to the api - operationId: addCannabisStrain - requestBody: - $ref: '#/components/requestBodies/Cannabis' - responses: - "405": - description: Invalid input - /cannabis/findByTerpene: - get: - tags: - - cannabis - summary: Finds cannabis strains by terpene - description: Multiple status values can be provided with comma separated strings - operationId: findCannabisStrainsByTerpene - parameters: - - name: terpene - in: query - description: Terpene values that need to be considered for filter - required: true - style: form - explode: true - schema: - type: array - items: - type: string - responses: - "200": - description: successful operation - content: - application/xml: - schema: - type: array - items: - $ref: '#/components/schemas/Cannabis' - x-content-type: application/xml - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Cannabis' - "400": - description: Invalid terpene value - /cannabis/{cannabisId}: - get: - tags: - - cannabis - summary: Find cannabis strain by ID - description: Returns a single cannabis strain - operationId: getCannabisStrainById - parameters: - - name: cannabisId - in: path - description: ID of cannabis strain to return - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "200": - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/Cannabis' - application/json: - schema: - $ref: '#/components/schemas/Cannabis' - "400": - description: Invalid ID supplied - "404": - description: Cannabis strain not found - post: - tags: - - cannabis - summary: Updates a cannabis strain in the api - description: Update a single cannabis strain in the API - operationId: updateCannabisStrainByID - parameters: - - name: cannabisId - in: path - description: ID of cannabis strain that needs to be updated - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - requestBody: - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/body_1' - responses: - "405": - description: Invalid input - delete: - tags: - - cannabis - summary: Deletes a cannabis strain - description: Deletes a cannabis strain from the API - operationId: deleteCannabisStrain - parameters: - - name: api_key - in: header - required: true - style: simple - explode: false - schema: - type: string - - name: cannabisId - in: path - description: Cannabis strain id to delete - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "400": - description: Invalid ID supplied - "404": - description: Cannabis strain not found - /effect: - put: - tags: - - effect - summary: Update an existing effect - description: Update effect in the api - operationId: updateEffect - requestBody: - $ref: '#/components/requestBodies/Effect' - responses: - "400": - description: Invalid ID supplied - "404": - description: Effect not found - "405": - description: Validation exception - post: - tags: - - effect - summary: Add a new effect to the api - description: Add new effect to the api - operationId: addEffect - requestBody: - $ref: '#/components/requestBodies/Effect' - responses: - "405": - description: Invalid input - /effect/{effectId}: - get: - tags: - - effect - summary: Find effect by ID - description: Returns a single effect - operationId: getEffectById - parameters: - - name: effectId - in: path - description: ID of effect to return - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "200": - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/Effect' - application/json: - schema: - $ref: '#/components/schemas/Effect' - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - post: - tags: - - effect - summary: Updates a effect in the api - description: Update a single effect in the API - operationId: updateEffectByID - parameters: - - name: effectId - in: path - description: ID of effect that needs to be updated - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - requestBody: - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/body_2' - responses: - "405": - description: Invalid input - delete: - tags: - - effect - summary: Deletes an effect - description: Deletes an effect from the API - operationId: deleteEffect - parameters: - - name: api_key - in: header - required: true - style: simple - explode: false - schema: - type: string - - name: effectId - in: path - description: Effect id to delete - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "400": - description: Invalid ID supplied - "404": - description: Effect not found - /user: - post: - tags: - - user - summary: Create user - description: This can only be done by the logged in user. - operationId: createUser - requestBody: - description: Created user object - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - responses: - default: - description: successful operation - /user/createWithArray: - post: - tags: - - user - summary: Creates list of users with given input array - operationId: createUsersWithArrayInput - requestBody: - $ref: '#/components/requestBodies/UserArray' - responses: - default: - description: successful operation -components: - schemas: - User: - type: object - properties: - id: - type: integer - format: int64 - username: - type: string - firstName: - type: string - lastName: - type: string - email: - type: string - password: - type: string - apiKey: - type: string - xml: - name: User - Category: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 6 - xml: - name: Category - Cannabis: - type: object - properties: - id: - type: integer - format: int64 - strain: - type: string - terpenes: - type: array - xml: - name: terpene - wrapped: true - items: - $ref: '#/components/schemas/Terpene' - example: - strain: strain - terpenes: - - effects: - - name: name - id: 7 - - name: name - id: 7 - tastes: - - name: name - id: 5 - - name: name - id: 5 - smells: - - name: name - id: 5 - - name: name - id: 5 - name: myrcene - id: 0 - category: - name: name - id: 6 - strains: - - name: name - id: 2 - - name: name - id: 2 - tags: - - name: name - id: 1 - - name: name - id: 1 - - effects: - - name: name - id: 7 - - name: name - id: 7 - tastes: - - name: name - id: 5 - - name: name - id: 5 - smells: - - name: name - id: 5 - - name: name - id: 5 - name: myrcene - id: 0 - category: - name: name - id: 6 - strains: - - name: name - id: 2 - - name: name - id: 2 - tags: - - name: name - id: 1 - - name: name - id: 1 - id: 0 - xml: - name: Cannabis - Tag: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 1 - xml: - name: Tag - Effect: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 7 - xml: - name: Effect - Strain: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 2 - xml: - name: Strain - Taste: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 5 - xml: - name: Taste - Smell: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 5 - xml: - name: Smell - Terpene: - required: - - name - type: object - properties: - id: - type: integer - format: int64 - category: - $ref: '#/components/schemas/Category' - name: - type: string - example: myrcene - tags: - type: array - xml: - name: tag - wrapped: true - items: - $ref: '#/components/schemas/Tag' - tastes: - type: array - xml: - name: taste - wrapped: true - items: - $ref: '#/components/schemas/Taste' - smells: - type: array - xml: - name: smell - wrapped: true - items: - $ref: '#/components/schemas/Smell' - strains: - type: array - xml: - name: strain - wrapped: true - items: - $ref: '#/components/schemas/Strain' - effects: - type: array - xml: - name: effect - wrapped: true - items: - $ref: '#/components/schemas/Effect' - example: - effects: - - name: name - id: 7 - - name: name - id: 7 - tastes: - - name: name - id: 5 - - name: name - id: 5 - smells: - - name: name - id: 5 - - name: name - id: 5 - name: myrcene - id: 0 - category: - name: name - id: 6 - strains: - - name: name - id: 2 - - name: name - id: 2 - tags: - - name: name - id: 1 - - name: name - id: 1 - xml: - name: Terpene - body: - type: object - properties: - effects: - type: string - description: Updated effects of the terpene - body_1: - type: object - properties: - terpenes: - type: array - description: Updated terpenes of the cannabis strain - items: - $ref: '#/components/schemas/Terpene' - body_2: - type: object - properties: - effects: - type: string - description: Updated effect - requestBodies: - UserArray: - description: List of user object - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true - Terpene: - description: Terpene object - content: - application/json: - schema: - $ref: '#/components/schemas/Terpene' - application/xml: - schema: - $ref: '#/components/schemas/Terpene' - required: true - Cannabis: - description: Cannabis object - content: - application/json: - schema: - $ref: '#/components/schemas/Cannabis' - application/xml: - schema: - $ref: '#/components/schemas/Cannabis' - required: true - Effect: - description: Effect object - content: - application/json: - schema: - $ref: '#/components/schemas/Effect' - application/xml: - schema: - $ref: '#/components/schemas/Effect' - required: true - Smell: - description: Smell object - content: - application/json: - schema: - $ref: '#/components/schemas/Smell' - application/xml: - schema: - $ref: '#/components/schemas/Smell' - required: true - Taste: - description: Taste object - content: - application/json: - schema: - $ref: '#/components/schemas/Taste' - application/xml: - schema: - $ref: '#/components/schemas/Taste' - Strain: - description: Strain object - content: - application/json: - schema: - $ref: '#/components/schemas/Strain' - application/xml: - schema: - $ref: '#/components/schemas/Strain' - Category: - description: Category object - content: - application/json: - schema: - $ref: '#/components/schemas/Category' - application/xml: - schema: - $ref: '#/components/schemas/Category' - Tag: - description: Tag object - content: - application/json: - schema: - $ref: '#/components/schemas/Tag' - application/xml: - schema: - $ref: '#/components/schemas/Tag' diff --git a/go-server/go/README.md b/go-server/go/README.md deleted file mode 100644 index 8887922..0000000 --- a/go-server/go/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Go API Server for swagger - -An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - -## Overview -This server was generated by the [swagger-codegen] -(https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub. -- - -To see how to make this your own, look here: - -[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) - -- API version: 0.0.2 -- Build date: 2020-11-05T01:28:48.247Z[GMT] - - -### Running the server -To run the server, follow these simple steps: - -``` -go run main.go -``` - diff --git a/go-server/go/api_cannabis.go b/go-server/go/api_cannabis.go deleted file mode 100644 index 04b9a4c..0000000 --- a/go-server/go/api_cannabis.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "net/http" -) - -func AddCannabisStrain(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func DeleteCannabisStrain(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func FindCannabisStrainsByTerpene(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func GetCannabisStrainById(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func UpdateCannabisStrain(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func UpdateCannabisStrainByID(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} diff --git a/go-server/go/api_effect.go b/go-server/go/api_effect.go deleted file mode 100644 index 5e4a5f7..0000000 --- a/go-server/go/api_effect.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "net/http" -) - -func AddEffect(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func DeleteEffect(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func GetEffectById(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func UpdateEffect(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func UpdateEffectByID(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} diff --git a/go-server/go/api_terpene.go b/go-server/go/api_terpene.go deleted file mode 100644 index 8d261e3..0000000 --- a/go-server/go/api_terpene.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "net/http" -) - -func AddTerpene(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func DeleteTerpene(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func FindTerpenesByEffect(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func GetTerpeneById(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func UpdateTerpene(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func UpdateTerpeneByID(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} diff --git a/go-server/go/api_user.go b/go-server/go/api_user.go deleted file mode 100644 index 29fd5cb..0000000 --- a/go-server/go/api_user.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "net/http" -) - -func CreateUser(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} - -func CreateUsersWithArrayInput(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=UTF-8") - w.WriteHeader(http.StatusOK) -} diff --git a/go-server/go/logger.go b/go-server/go/logger.go deleted file mode 100644 index d269599..0000000 --- a/go-server/go/logger.go +++ /dev/null @@ -1,32 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "log" - "net/http" - "time" -) - -func Logger(inner http.Handler, name string) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - start := time.Now() - - inner.ServeHTTP(w, r) - - log.Printf( - "%s %s %s %s", - r.Method, - r.RequestURI, - name, - time.Since(start), - ) - }) -} diff --git a/go-server/go/model_body.go b/go-server/go/model_body.go deleted file mode 100644 index c6894e5..0000000 --- a/go-server/go/model_body.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Body struct { - // Updated effects of the terpene - Effects string `json:"effects,omitempty"` -} diff --git a/go-server/go/model_body_1.go b/go-server/go/model_body_1.go deleted file mode 100644 index 91c6578..0000000 --- a/go-server/go/model_body_1.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Body1 struct { - // Updated terpenes of the cannabis strain - Terpenes []Terpene `json:"terpenes,omitempty"` -} diff --git a/go-server/go/model_body_2.go b/go-server/go/model_body_2.go deleted file mode 100644 index b4320b0..0000000 --- a/go-server/go/model_body_2.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Body2 struct { - // Updated effect - Effects string `json:"effects,omitempty"` -} diff --git a/go-server/go/model_cannabis.go b/go-server/go/model_cannabis.go deleted file mode 100644 index 81d1063..0000000 --- a/go-server/go/model_cannabis.go +++ /dev/null @@ -1,19 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Cannabis struct { - - Id int64 `json:"id,omitempty"` - - Strain string `json:"strain,omitempty"` - - Terpenes []Terpene `json:"terpenes,omitempty"` -} diff --git a/go-server/go/model_category.go b/go-server/go/model_category.go deleted file mode 100644 index 98c861b..0000000 --- a/go-server/go/model_category.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Category struct { - - Id int64 `json:"id,omitempty"` - - Name string `json:"name,omitempty"` -} diff --git a/go-server/go/model_effect.go b/go-server/go/model_effect.go deleted file mode 100644 index 3a9cc79..0000000 --- a/go-server/go/model_effect.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Effect struct { - - Id int64 `json:"id,omitempty"` - - Name string `json:"name,omitempty"` -} diff --git a/go-server/go/model_smell.go b/go-server/go/model_smell.go deleted file mode 100644 index 19d2dc4..0000000 --- a/go-server/go/model_smell.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Smell struct { - - Id int64 `json:"id,omitempty"` - - Name string `json:"name,omitempty"` -} diff --git a/go-server/go/model_strain.go b/go-server/go/model_strain.go deleted file mode 100644 index 934c9d8..0000000 --- a/go-server/go/model_strain.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Strain struct { - - Id int64 `json:"id,omitempty"` - - Name string `json:"name,omitempty"` -} diff --git a/go-server/go/model_tag.go b/go-server/go/model_tag.go deleted file mode 100644 index 582b7f7..0000000 --- a/go-server/go/model_tag.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Tag struct { - - Id int64 `json:"id,omitempty"` - - Name string `json:"name,omitempty"` -} diff --git a/go-server/go/model_taste.go b/go-server/go/model_taste.go deleted file mode 100644 index a9fd434..0000000 --- a/go-server/go/model_taste.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Taste struct { - - Id int64 `json:"id,omitempty"` - - Name string `json:"name,omitempty"` -} diff --git a/go-server/go/model_terpene.go b/go-server/go/model_terpene.go deleted file mode 100644 index 797220d..0000000 --- a/go-server/go/model_terpene.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Terpene struct { - - Id int64 `json:"id,omitempty"` - - Category *Category `json:"category,omitempty"` - - Name string `json:"name"` - - Tags []Tag `json:"tags,omitempty"` - - Tastes []Taste `json:"tastes,omitempty"` - - Smells []Smell `json:"smells,omitempty"` - - Strains []Strain `json:"strains,omitempty"` - - Effects []Effect `json:"effects,omitempty"` -} diff --git a/go-server/go/model_user.go b/go-server/go/model_user.go deleted file mode 100644 index 3516cd2..0000000 --- a/go-server/go/model_user.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type User struct { - - Id int64 `json:"id,omitempty"` - - Username string `json:"username,omitempty"` - - FirstName string `json:"firstName,omitempty"` - - LastName string `json:"lastName,omitempty"` - - Email string `json:"email,omitempty"` - - Password string `json:"password,omitempty"` - - ApiKey string `json:"apiKey,omitempty"` -} diff --git a/go-server/go/routers.go b/go-server/go/routers.go deleted file mode 100644 index 255e52e..0000000 --- a/go-server/go/routers.go +++ /dev/null @@ -1,190 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "fmt" - "net/http" - "strings" - - "github.com/gorilla/mux" -) - -type Route struct { - Name string - Method string - Pattern string - HandlerFunc http.HandlerFunc -} - -type Routes []Route - -func NewRouter() *mux.Router { - router := mux.NewRouter().StrictSlash(true) - for _, route := range routes { - var handler http.Handler - handler = route.HandlerFunc - handler = Logger(handler, route.Name) - - router. - Methods(route.Method). - Path(route.Pattern). - Name(route.Name). - Handler(handler) - } - - return router -} - -func Index(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Hello World!") -} - -var routes = Routes{ - Route{ - "Index", - "GET", - "/CountryFriedCoders/OpenTerps/0.0.1/", - Index, - }, - - Route{ - "AddCannabisStrain", - strings.ToUpper("Post"), - "/CountryFriedCoders/OpenTerps/0.0.1/cannabis", - AddCannabisStrain, - }, - - Route{ - "DeleteCannabisStrain", - strings.ToUpper("Delete"), - "/CountryFriedCoders/OpenTerps/0.0.1/cannabis/{cannabisId}", - DeleteCannabisStrain, - }, - - Route{ - "FindCannabisStrainsByTerpene", - strings.ToUpper("Get"), - "/CountryFriedCoders/OpenTerps/0.0.1/cannabis/findByTerpene", - FindCannabisStrainsByTerpene, - }, - - Route{ - "GetCannabisStrainById", - strings.ToUpper("Get"), - "/CountryFriedCoders/OpenTerps/0.0.1/cannabis/{cannabisId}", - GetCannabisStrainById, - }, - - Route{ - "UpdateCannabisStrain", - strings.ToUpper("Put"), - "/CountryFriedCoders/OpenTerps/0.0.1/cannabis", - UpdateCannabisStrain, - }, - - Route{ - "UpdateCannabisStrainByID", - strings.ToUpper("Post"), - "/CountryFriedCoders/OpenTerps/0.0.1/cannabis/{cannabisId}", - UpdateCannabisStrainByID, - }, - - Route{ - "AddEffect", - strings.ToUpper("Post"), - "/CountryFriedCoders/OpenTerps/0.0.1/effect", - AddEffect, - }, - - Route{ - "DeleteEffect", - strings.ToUpper("Delete"), - "/CountryFriedCoders/OpenTerps/0.0.1/effect/{effectId}", - DeleteEffect, - }, - - Route{ - "GetEffectById", - strings.ToUpper("Get"), - "/CountryFriedCoders/OpenTerps/0.0.1/effect/{effectId}", - GetEffectById, - }, - - Route{ - "UpdateEffect", - strings.ToUpper("Put"), - "/CountryFriedCoders/OpenTerps/0.0.1/effect", - UpdateEffect, - }, - - Route{ - "UpdateEffectByID", - strings.ToUpper("Post"), - "/CountryFriedCoders/OpenTerps/0.0.1/effect/{effectId}", - UpdateEffectByID, - }, - - Route{ - "AddTerpene", - strings.ToUpper("Post"), - "/CountryFriedCoders/OpenTerps/0.0.1/terpene", - AddTerpene, - }, - - Route{ - "DeleteTerpene", - strings.ToUpper("Delete"), - "/CountryFriedCoders/OpenTerps/0.0.1/terpene/{terpeneId}", - DeleteTerpene, - }, - - Route{ - "FindTerpenesByEffect", - strings.ToUpper("Get"), - "/CountryFriedCoders/OpenTerps/0.0.1/terpene/findByEffect", - FindTerpenesByEffect, - }, - - Route{ - "GetTerpeneById", - strings.ToUpper("Get"), - "/CountryFriedCoders/OpenTerps/0.0.1/terpene/{terpeneId}", - GetTerpeneById, - }, - - Route{ - "UpdateTerpene", - strings.ToUpper("Put"), - "/CountryFriedCoders/OpenTerps/0.0.1/terpene", - UpdateTerpene, - }, - - Route{ - "UpdateTerpeneByID", - strings.ToUpper("Post"), - "/CountryFriedCoders/OpenTerps/0.0.1/terpene/{terpeneId}", - UpdateTerpeneByID, - }, - - Route{ - "CreateUser", - strings.ToUpper("Post"), - "/CountryFriedCoders/OpenTerps/0.0.1/user", - CreateUser, - }, - - Route{ - "CreateUsersWithArrayInput", - strings.ToUpper("Post"), - "/CountryFriedCoders/OpenTerps/0.0.1/user/createWithArray", - CreateUsersWithArrayInput, - }, -} diff --git a/go-server/main.go b/go-server/main.go deleted file mode 100644 index ab2c490..0000000 --- a/go-server/main.go +++ /dev/null @@ -1,32 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.2 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package main - -import ( - "log" - "net/http" - - // WARNING! - // Change this to a fully-qualified import path - // once you place this file into your project. - // For example, - // - // sw "github.com/myname/myrepo/go" - // - sw "./go" -) - -func main() { - log.Printf("Server started") - - router := sw.NewRouter() - - log.Fatal(http.ListenAndServe(":8080", router)) -} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8ac1795 --- /dev/null +++ b/go.mod @@ -0,0 +1,14 @@ +module openterps + +go 1.15 + +require ( + github.com/gin-gonic/gin v1.6.3 + github.com/go-gormigrate/gormigrate/v2 v2.0.0 + github.com/jinzhu/gorm v1.9.16 + github.com/joho/godotenv v1.3.0 + gorm.io/driver/postgres v1.0.5 + gorm.io/gorm v1.20.6 +) + +// +heroku install github.com/gin-gonic/gin github.com/gin-gonic/gin github.com/jinzhu/gorm github.com/joho/godotenv gorm.io/driver/postgres gorm.io/gorm diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..65a3efd --- /dev/null +++ b/go.sum @@ -0,0 +1,229 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= +github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-gormigrate/gormigrate v1.6.0 h1:JvKpFsbVPLfIPPkIrZq1zq19PLFT4DVSnL5BiyE1P0E= +github.com/go-gormigrate/gormigrate/v2 v2.0.0 h1:e2A3Uznk4viUC4UuemuVgsNnvYZyOA8B3awlYk3UioU= +github.com/go-gormigrate/gormigrate/v2 v2.0.0/go.mod h1:YuVJ+D/dNt4HWrThTBnjgZuRbt7AuwINeg4q52ZE3Jw= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk= +github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= +github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= +github.com/jackc/pgconn v1.6.4/go.mod h1:w2pne1C2tZgP+TvjqLpOigGzNqjBgQW9dUw/4Chex78= +github.com/jackc/pgconn v1.7.0 h1:pwjzcYyfmz/HQOQlENvG1OcDqauTGaqlVahq934F0/U= +github.com/jackc/pgconn v1.7.0/go.mod h1:sF/lPpNEMEOp+IYhyQGdAvrG20gWf6A1tKlr0v7JMeA= +github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= +github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= +github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.0.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.0.5 h1:NUbEWPmCQZbMmYlTjVoNPhc0CfnYyz2bfUAh6A5ZVJM= +github.com/jackc/pgproto3/v2 v2.0.5/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= +github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0= +github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po= +github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ= +github.com/jackc/pgtype v1.4.2/go.mod h1:JCULISAZBFGrHaOXIIFiyfzW5VY0GRitRr8NeJsrdig= +github.com/jackc/pgtype v1.5.0 h1:jzBqRk2HFG2CV4AIwgCI2PwTgm6UUoCAK2ofHHRirtc= +github.com/jackc/pgtype v1.5.0/go.mod h1:JCULISAZBFGrHaOXIIFiyfzW5VY0GRitRr8NeJsrdig= +github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= +github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= +github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXgo+kA= +github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o= +github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg= +github.com/jackc/pgx/v4 v4.8.1/go.mod h1:4HOLxrl8wToZJReD04/yB20GDwf4KBYETvlHciCnwW0= +github.com/jackc/pgx/v4 v4.9.0 h1:6STjDqppM2ROy5p1wNDcsC7zJTjSHeuCsguZmXyzx7c= +github.com/jackc/pgx/v4 v4.9.0/go.mod h1:MNGWmViCgqbZck9ujOOBN63gK9XVGILXWCvKLGKmnms= +github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.2/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o= +github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.1 h1:g39TucaRWyV3dwDO++eEc6qf8TVIQ/Da48WmqjZ3i7E= +github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= +github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gorm.io/driver/mysql v1.0.1/go.mod h1:KtqSthtg55lFp3S5kUXqlGaelnWpKitn4k1xZTnoiPw= +gorm.io/driver/postgres v1.0.0/go.mod h1:wtMFcOzmuA5QigNsgEIb7O5lhvH1tHAF1RbWmLWV4to= +gorm.io/driver/postgres v1.0.5 h1:raX6ezL/ciUmaYTvOq48jq1GE95aMC0CmxQYbxQ4Ufw= +gorm.io/driver/postgres v1.0.5/go.mod h1:qrD92UurYzNctBMVCJ8C3VQEjffEuphycXtxOudXNCA= +gorm.io/driver/sqlite v1.1.1/go.mod h1:hm2olEcl8Tmsc6eZyxYSeznnsDaMqamBvEXLNtBg4cI= +gorm.io/driver/sqlserver v1.0.2/go.mod h1:gb0Y9QePGgqjzrVyTQUZeh9zkd5v0iz71cM1B4ZycEY= +gorm.io/gorm v1.9.19/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= +gorm.io/gorm v1.20.0/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= +gorm.io/gorm v1.20.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= +gorm.io/gorm v1.20.6 h1:qa7tC1WcU+DBI/ZKMxvXy1FcrlGsvxlaKufHrT2qQ08= +gorm.io/gorm v1.20.6/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/go/.gitignore b/go/.gitignore deleted file mode 100644 index daf913b..0000000 --- a/go/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/go/.swagger-codegen-ignore b/go/.swagger-codegen-ignore deleted file mode 100644 index c5fa491..0000000 --- a/go/.swagger-codegen-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/go/.swagger-codegen/VERSION b/go/.swagger-codegen/VERSION deleted file mode 100644 index 402b44e..0000000 --- a/go/.swagger-codegen/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.0.21 \ No newline at end of file diff --git a/go/.travis.yml b/go/.travis.yml deleted file mode 100644 index f5cb2ce..0000000 --- a/go/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go - -install: - - go get -d -v . - -script: - - go build -v ./ - diff --git a/go/README.md b/go/README.md deleted file mode 100644 index 2bba216..0000000 --- a/go/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# Go API client for swagger - -An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - -## Overview -This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client. - -- API version: 0.0.1 -- Package version: 1.0.0 -- Build package: io.swagger.codegen.v3.generators.go.GoClientCodegen - -## Installation -Put the package under your project folder and add the following in import: -```golang -import "./swagger" -``` - -## Documentation for API Endpoints - -All URIs are relative to *https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*TerpeneApi* | [**AddTerpene**](docs/TerpeneApi.md#addterpene) | **Post** /terpene | Add a new terpene to the api -*TerpeneApi* | [**DeleteTerpene**](docs/TerpeneApi.md#deleteterpene) | **Delete** /terpene/{terpeneId} | Deletes a terpene -*TerpeneApi* | [**FindTerpenesByEffect**](docs/TerpeneApi.md#findterpenesbyeffect) | **Get** /terpene/findByEffect | Finds Terpenes by effect -*TerpeneApi* | [**GetTerpeneById**](docs/TerpeneApi.md#getterpenebyid) | **Get** /terpene/{terpeneId} | Find terpene by ID -*TerpeneApi* | [**UpdateTerpene**](docs/TerpeneApi.md#updateterpene) | **Put** /terpene | Update an existing terpene -*TerpeneApi* | [**UpdateTerpeneByID**](docs/TerpeneApi.md#updateterpenebyid) | **Post** /terpene/{terpeneId} | Updates a terpene in the api -*UserApi* | [**CreateUser**](docs/UserApi.md#createuser) | **Post** /user | Create user -*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **Post** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **Post** /user/createWithList | Creates list of users with given input array -*UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **Delete** /user/{username} | Delete user -*UserApi* | [**GetUserByName**](docs/UserApi.md#getuserbyname) | **Get** /user/{username} | Get user by user name -*UserApi* | [**LoginUser**](docs/UserApi.md#loginuser) | **Get** /user/login | Logs user into the system -*UserApi* | [**LogoutUser**](docs/UserApi.md#logoutuser) | **Get** /user/logout | Logs out current logged in user session -*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **Put** /user/{username} | Updated user - -## Documentation For Models - - - [Body](docs/Body.md) - - [Category](docs/Category.md) - - [Effect](docs/Effect.md) - - [ModelApiResponse](docs/ModelApiResponse.md) - - [Smell](docs/Smell.md) - - [Strain](docs/Strain.md) - - [Tag](docs/Tag.md) - - [Taste](docs/Taste.md) - - [Terpene](docs/Terpene.md) - - [User](docs/User.md) - -## Documentation For Authorization - Endpoints do not require authorization. - - -## Author - -benjamminredden@gmail.com diff --git a/go/api/swagger.yaml b/go/api/swagger.yaml deleted file mode 100644 index 00e04c5..0000000 --- a/go/api/swagger.yaml +++ /dev/null @@ -1,560 +0,0 @@ -openapi: 3.0.0 -info: - title: OpenTerps - description: An Open API that contains information about terpenes, the effects, - and the cannabis varieties that contain them. - termsOfService: https://wayhigh.we.bs - contact: - email: benjamminredden@gmail.com - license: - name: Apache 2.0 - url: http://www.apache.org/licenses/LICENSE-2.0.html - version: 0.0.1 -externalDocs: - description: Find out more about OpenTerps - url: https://wayhigh.we.bs -servers: -- url: https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1 -tags: -- name: cannabis - description: The plant. -- name: terpene - description: One of the most important parts of the cannabis plant. -- name: effects - description: The effect of said terpenes. -paths: - /terpene: - put: - tags: - - terpene - summary: Update an existing terpene - description: Update terpene in the api - operationId: updateTerpene - requestBody: - $ref: '#/components/requestBodies/Terpene' - responses: - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - "405": - description: Validation exception - post: - tags: - - terpene - summary: Add a new terpene to the api - description: Add new terpene to the api - operationId: addTerpene - requestBody: - $ref: '#/components/requestBodies/Terpene' - responses: - "405": - description: Invalid input - /terpene/findByEffect: - get: - tags: - - terpene - summary: Finds Terpenes by effect - description: Multiple status values can be provided with comma separated strings - operationId: findTerpenesByEffect - parameters: - - name: effect - in: query - description: Effect values that need to be considered for filter - required: true - style: form - explode: true - schema: - type: array - items: - type: string - responses: - "200": - description: successful operation - content: - application/xml: - schema: - type: array - items: - $ref: '#/components/schemas/Terpene' - x-content-type: application/xml - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Terpene' - "400": - description: Invalid effect value - /terpene/{terpeneId}: - get: - tags: - - terpene - summary: Find terpene by ID - description: Returns a single terpene - operationId: getTerpeneById - parameters: - - name: terpeneId - in: path - description: ID of terpene to return - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "200": - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/Terpene' - application/json: - schema: - $ref: '#/components/schemas/Terpene' - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - post: - tags: - - terpene - summary: Updates a terpene in the api - description: Update a single terpene in the API - operationId: updateTerpeneByID - parameters: - - name: terpeneId - in: path - description: ID of terpene that needs to be updated - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - requestBody: - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/body' - responses: - "405": - description: Invalid input - delete: - tags: - - terpene - summary: Deletes a terpene - description: Deletes a terpene from the API - operationId: deleteTerpene - parameters: - - name: api_key - in: header - required: true - style: simple - explode: false - schema: - type: string - - name: terpeneId - in: path - description: Terpene id to delete - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - /user: - post: - tags: - - user - summary: Create user - description: This can only be done by the logged in user. - operationId: createUser - requestBody: - description: Created user object - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - responses: - default: - description: successful operation - /user/createWithArray: - post: - tags: - - user - summary: Creates list of users with given input array - operationId: createUsersWithArrayInput - requestBody: - $ref: '#/components/requestBodies/UserArray' - responses: - default: - description: successful operation - /user/createWithList: - post: - tags: - - user - summary: Creates list of users with given input array - operationId: createUsersWithListInput - requestBody: - $ref: '#/components/requestBodies/UserArray' - responses: - default: - description: successful operation - /user/login: - get: - tags: - - user - summary: Logs user into the system - operationId: loginUser - parameters: - - name: username - in: query - description: The user name for login - required: true - style: form - explode: true - schema: - type: string - - name: password - in: query - description: The password for login in clear text - required: true - style: form - explode: true - schema: - type: string - responses: - "200": - description: successful operation - headers: - X-Rate-Limit: - description: calls per hour allowed by the user - style: simple - explode: false - schema: - type: integer - format: int32 - X-Expires-After: - description: date in UTC when token expires - style: simple - explode: false - schema: - type: string - format: date-time - content: - application/xml: - schema: - type: string - x-content-type: application/xml - application/json: - schema: - type: string - "400": - description: Invalid username/password supplied - /user/logout: - get: - tags: - - user - summary: Logs out current logged in user session - operationId: logoutUser - responses: - default: - description: successful operation - /user/{username}: - get: - tags: - - user - summary: Get user by user name - operationId: getUserByName - parameters: - - name: username - in: path - description: 'The name that needs to be fetched. Use user1 for testing. ' - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/User' - application/json: - schema: - $ref: '#/components/schemas/User' - "400": - description: Invalid username supplied - "404": - description: User not found - put: - tags: - - user - summary: Updated user - description: This can only be done by the logged in user. - operationId: updateUser - parameters: - - name: username - in: path - description: name that need to be updated - required: true - style: simple - explode: false - schema: - type: string - requestBody: - description: Updated user object - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - responses: - "400": - description: Invalid user supplied - "404": - description: User not found - delete: - tags: - - user - summary: Delete user - description: This can only be done by the logged in user. - operationId: deleteUser - parameters: - - name: username - in: path - description: The name that needs to be deleted - required: true - style: simple - explode: false - schema: - type: string - responses: - "400": - description: Invalid username supplied - "404": - description: User not found -components: - schemas: - User: - type: object - properties: - id: - type: integer - format: int64 - username: - type: string - firstName: - type: string - lastName: - type: string - email: - type: string - password: - type: string - phone: - type: string - userStatus: - type: integer - description: User Status - format: int32 - example: - firstName: firstName - lastName: lastName - password: password - userStatus: 6 - phone: phone - id: 0 - email: email - username: username - xml: - name: User - Category: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 6 - xml: - name: Category - Tag: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 1 - xml: - name: Tag - Effect: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - xml: - name: Effect - Strain: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 2 - xml: - name: Strain - Taste: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 5 - xml: - name: Taste - Smell: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 5 - xml: - name: Smell - Terpene: - required: - - name - type: object - properties: - id: - type: integer - format: int64 - category: - $ref: '#/components/schemas/Category' - name: - type: string - example: myrcene - tags: - type: array - xml: - name: tag - wrapped: true - items: - $ref: '#/components/schemas/Tag' - tastes: - type: array - xml: - name: taste - wrapped: true - items: - $ref: '#/components/schemas/Taste' - smells: - type: array - xml: - name: smell - wrapped: true - items: - $ref: '#/components/schemas/Smell' - strains: - type: array - xml: - name: strain - wrapped: true - items: - $ref: '#/components/schemas/Strain' - example: - tastes: - - name: name - id: 5 - - name: name - id: 5 - smells: - - name: name - id: 5 - - name: name - id: 5 - name: myrcene - id: 0 - category: - name: name - id: 6 - strains: - - name: name - id: 2 - - name: name - id: 2 - tags: - - name: name - id: 1 - - name: name - id: 1 - xml: - name: Terpene - ApiResponse: - type: object - properties: - code: - type: integer - format: int32 - type: - type: string - message: - type: string - body: - type: object - properties: - effects: - type: string - description: Updated effects of the pet - requestBodies: - UserArray: - description: List of user object - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true - Terpene: - description: Terpene object - content: - application/json: - schema: - $ref: '#/components/schemas/Terpene' - application/xml: - schema: - $ref: '#/components/schemas/Terpene' - required: true diff --git a/go/api_terpene.go b/go/api_terpene.go deleted file mode 100644 index a76817c..0000000 --- a/go/api_terpene.go +++ /dev/null @@ -1,484 +0,0 @@ - -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "context" - "io/ioutil" - "net/http" - "net/url" - "strings" - "fmt" - "github.com/antihax/optional" -) - -// Linger please -var ( - _ context.Context -) - -type TerpeneApiService service -/* -TerpeneApiService Add a new terpene to the api -Add new terpene to the api - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body Terpene object - -*/ -func (a *TerpeneApiService) AddTerpene(ctx context.Context, body Terpene) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/terpene" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json", "application/xml"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} -/* -TerpeneApiService Deletes a terpene -Deletes a terpene from the API - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param apiKey - * @param terpeneId Terpene id to delete - -*/ -func (a *TerpeneApiService) DeleteTerpene(ctx context.Context, apiKey string, terpeneId int64) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Delete") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/terpene/{terpeneId}" - localVarPath = strings.Replace(localVarPath, "{"+"terpeneId"+"}", fmt.Sprintf("%v", terpeneId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - localVarHeaderParams["api_key"] = parameterToString(apiKey, "") - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} -/* -TerpeneApiService Finds Terpenes by effect -Multiple status values can be provided with comma separated strings - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param effect Effect values that need to be considered for filter -@return []Terpene -*/ -func (a *TerpeneApiService) FindTerpenesByEffect(ctx context.Context, effect []string) ([]Terpene, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue []Terpene - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/terpene/findByEffect" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - localVarQueryParams.Add("effect", parameterToString(effect, "multi")) - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - if localVarHttpResponse.StatusCode == 200 { - var v []Terpene - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} -/* -TerpeneApiService Find terpene by ID -Returns a single terpene - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param terpeneId ID of terpene to return -@return Terpene -*/ -func (a *TerpeneApiService) GetTerpeneById(ctx context.Context, terpeneId int64) (Terpene, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue Terpene - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/terpene/{terpeneId}" - localVarPath = strings.Replace(localVarPath, "{"+"terpeneId"+"}", fmt.Sprintf("%v", terpeneId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - if localVarHttpResponse.StatusCode == 200 { - var v Terpene - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} -/* -TerpeneApiService Update an existing terpene -Update terpene in the api - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body Terpene object - -*/ -func (a *TerpeneApiService) UpdateTerpene(ctx context.Context, body Terpene) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/terpene" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json", "application/xml"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} -/* -TerpeneApiService Updates a terpene in the api -Update a single terpene in the API - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param terpeneId ID of terpene that needs to be updated - * @param optional nil or *TerpeneApiUpdateTerpeneByIDOpts - Optional Parameters: - * @param "Effects" (optional.String) - - -*/ - -type TerpeneApiUpdateTerpeneByIDOpts struct { - Effects optional.String -} - -func (a *TerpeneApiService) UpdateTerpeneByID(ctx context.Context, terpeneId int64, localVarOptionals *TerpeneApiUpdateTerpeneByIDOpts) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/terpene/{terpeneId}" - localVarPath = strings.Replace(localVarPath, "{"+"terpeneId"+"}", fmt.Sprintf("%v", terpeneId), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - if localVarOptionals != nil && localVarOptionals.Effects.IsSet() { - localVarFormParams.Add("effects", parameterToString(localVarOptionals.Effects.Value(), "")) - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} diff --git a/go/api_user.go b/go/api_user.go deleted file mode 100644 index 6f46934..0000000 --- a/go/api_user.go +++ /dev/null @@ -1,606 +0,0 @@ - -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "context" - "io/ioutil" - "net/http" - "net/url" - "strings" - "fmt" -) - -// Linger please -var ( - _ context.Context -) - -type UserApiService service -/* -UserApiService Create user -This can only be done by the logged in user. - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body Created user object - -*/ -func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} -/* -UserApiService Creates list of users with given input array - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body List of user object - -*/ -func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []User) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/createWithArray" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} -/* -UserApiService Creates list of users with given input array - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body List of user object - -*/ -func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []User) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/createWithList" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} -/* -UserApiService Delete user -This can only be done by the logged in user. - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param username The name that needs to be deleted - -*/ -func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Delete") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/{username}" - localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} -/* -UserApiService Get user by user name - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param username The name that needs to be fetched. Use user1 for testing. -@return User -*/ -func (a *UserApiService) GetUserByName(ctx context.Context, username string) (User, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue User - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/{username}" - localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - if localVarHttpResponse.StatusCode == 200 { - var v User - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} -/* -UserApiService Logs user into the system - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param username The user name for login - * @param password The password for login in clear text -@return string -*/ -func (a *UserApiService) LoginUser(ctx context.Context, username string, password string) (string, *http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - localVarReturnValue string - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/login" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - localVarQueryParams.Add("username", parameterToString(username, "")) - localVarQueryParams.Add("password", parameterToString(password, "")) - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarReturnValue, localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarReturnValue, localVarHttpResponse, err - } - - if localVarHttpResponse.StatusCode < 300 { - // If we succeed, return the data, otherwise pass on to decode error. - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err == nil { - return localVarReturnValue, localVarHttpResponse, err - } - } - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - if localVarHttpResponse.StatusCode == 200 { - var v string - err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHttpResponse, newErr - } - newErr.model = v - return localVarReturnValue, localVarHttpResponse, newErr - } - return localVarReturnValue, localVarHttpResponse, newErr - } - - return localVarReturnValue, localVarHttpResponse, nil -} -/* -UserApiService Logs out current logged in user session - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - -*/ -func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/logout" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} -/* -UserApiService Updated user -This can only be done by the logged in user. - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param body Updated user object - * @param username name that need to be updated - -*/ -func (a *UserApiService) UpdateUser(ctx context.Context, body User, username string) (*http.Response, error) { - var ( - localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - - ) - - // create path and map variables - localVarPath := a.client.cfg.BasePath + "/user/{username}" - localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHttpContentType - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string{} - - // set Accept header - localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHttpHeaderAccept - } - // body params - localVarPostBody = &body - r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) - if err != nil { - return nil, err - } - - localVarHttpResponse, err := a.client.callAPI(r) - if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err - } - - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - localVarHttpResponse.Body.Close() - if err != nil { - return localVarHttpResponse, err - } - - - if localVarHttpResponse.StatusCode >= 300 { - newErr := GenericSwaggerError{ - body: localVarBody, - error: localVarHttpResponse.Status, - } - return localVarHttpResponse, newErr - } - - return localVarHttpResponse, nil -} diff --git a/go/client.go b/go/client.go deleted file mode 100644 index befda75..0000000 --- a/go/client.go +++ /dev/null @@ -1,477 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "bytes" - "context" - "encoding/json" - "encoding/xml" - "errors" - "fmt" - "io" - "mime/multipart" - "net/http" - "net/url" - "os" - "path/filepath" - "reflect" - "regexp" - "strconv" - "strings" - "time" - "unicode/utf8" - - "golang.org/x/oauth2" -) - -var ( - jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") - xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") -) - -// APIClient manages communication with the OpenTerps API v0.0.1 -// In most cases there should be only one, shared, APIClient. -type APIClient struct { - cfg *Configuration - common service // Reuse a single struct instead of allocating one for each service on the heap. - - // API Services - - TerpeneApi *TerpeneApiService - - UserApi *UserApiService -} - -type service struct { - client *APIClient -} - -// NewAPIClient creates a new API client. Requires a userAgent string describing your application. -// optionally a custom http.Client to allow for advanced features such as caching. -func NewAPIClient(cfg *Configuration) *APIClient { - if cfg.HTTPClient == nil { - cfg.HTTPClient = http.DefaultClient - } - - c := &APIClient{} - c.cfg = cfg - c.common.client = c - - // API Services - c.TerpeneApi = (*TerpeneApiService)(&c.common) - c.UserApi = (*UserApiService)(&c.common) - - return c -} - -func atoi(in string) (int, error) { - return strconv.Atoi(in) -} - -// selectHeaderContentType select a content type from the available list. -func selectHeaderContentType(contentTypes []string) string { - if len(contentTypes) == 0 { - return "" - } - if contains(contentTypes, "application/json") { - return "application/json" - } - return contentTypes[0] // use the first content type specified in 'consumes' -} - -// selectHeaderAccept join all accept types and return -func selectHeaderAccept(accepts []string) string { - if len(accepts) == 0 { - return "" - } - - if contains(accepts, "application/json") { - return "application/json" - } - - return strings.Join(accepts, ",") -} - -// contains is a case insenstive match, finding needle in a haystack -func contains(haystack []string, needle string) bool { - for _, a := range haystack { - if strings.ToLower(a) == strings.ToLower(needle) { - return true - } - } - return false -} - -// Verify optional parameters are of the correct type. -func typeCheckParameter(obj interface{}, expected string, name string) error { - // Make sure there is an object. - if obj == nil { - return nil - } - - // Check the type is as expected. - if reflect.TypeOf(obj).String() != expected { - return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) - } - return nil -} - -// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. -func parameterToString(obj interface{}, collectionFormat string) string { - var delimiter string - - switch collectionFormat { - case "pipes": - delimiter = "|" - case "ssv": - delimiter = " " - case "tsv": - delimiter = "\t" - case "csv": - delimiter = "," - } - - if reflect.TypeOf(obj).Kind() == reflect.Slice { - return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") - } - - return fmt.Sprintf("%v", obj) -} - -// callAPI do the request. -func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { - return c.cfg.HTTPClient.Do(request) -} - -// Change base path to allow switching to mocks -func (c *APIClient) ChangeBasePath(path string) { - c.cfg.BasePath = path -} - -// prepareRequest build the request -func (c *APIClient) prepareRequest( - ctx context.Context, - path string, method string, - postBody interface{}, - headerParams map[string]string, - queryParams url.Values, - formParams url.Values, - fileName string, - fileBytes []byte) (localVarRequest *http.Request, err error) { - - var body *bytes.Buffer - - // Detect postBody type and post. - if postBody != nil { - contentType := headerParams["Content-Type"] - if contentType == "" { - contentType = detectContentType(postBody) - headerParams["Content-Type"] = contentType - } - - body, err = setBody(postBody, contentType) - if err != nil { - return nil, err - } - } - - // add form parameters and file if available. - if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { - if body != nil { - return nil, errors.New("Cannot specify postBody and multipart form at the same time.") - } - body = &bytes.Buffer{} - w := multipart.NewWriter(body) - - for k, v := range formParams { - for _, iv := range v { - if strings.HasPrefix(k, "@") { // file - err = addFile(w, k[1:], iv) - if err != nil { - return nil, err - } - } else { // form value - w.WriteField(k, iv) - } - } - } - if len(fileBytes) > 0 && fileName != "" { - w.Boundary() - //_, fileNm := filepath.Split(fileName) - part, err := w.CreateFormFile("file", filepath.Base(fileName)) - if err != nil { - return nil, err - } - _, err = part.Write(fileBytes) - if err != nil { - return nil, err - } - // Set the Boundary in the Content-Type - headerParams["Content-Type"] = w.FormDataContentType() - } - - // Set Content-Length - headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) - w.Close() - } - - if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { - if body != nil { - return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") - } - body = &bytes.Buffer{} - body.WriteString(formParams.Encode()) - // Set Content-Length - headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) - } - - // Setup path and query parameters - url, err := url.Parse(path) - if err != nil { - return nil, err - } - - // Adding Query Param - query := url.Query() - for k, v := range queryParams { - for _, iv := range v { - query.Add(k, iv) - } - } - - // Encode the parameters. - url.RawQuery = query.Encode() - - // Generate a new request - if body != nil { - localVarRequest, err = http.NewRequest(method, url.String(), body) - } else { - localVarRequest, err = http.NewRequest(method, url.String(), nil) - } - if err != nil { - return nil, err - } - - // add header parameters, if any - if len(headerParams) > 0 { - headers := http.Header{} - for h, v := range headerParams { - headers.Set(h, v) - } - localVarRequest.Header = headers - } - - // Override request host, if applicable - if c.cfg.Host != "" { - localVarRequest.Host = c.cfg.Host - } - - // Add the user agent to the request. - localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) - - if ctx != nil { - // add context to the request - localVarRequest = localVarRequest.WithContext(ctx) - - // Walk through any authentication. - - // OAuth2 authentication - if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { - // We were able to grab an oauth2 token from the context - var latestToken *oauth2.Token - if latestToken, err = tok.Token(); err != nil { - return nil, err - } - - latestToken.SetAuthHeader(localVarRequest) - } - - // Basic HTTP Authentication - if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { - localVarRequest.SetBasicAuth(auth.UserName, auth.Password) - } - - // AccessToken Authentication - if auth, ok := ctx.Value(ContextAccessToken).(string); ok { - localVarRequest.Header.Add("Authorization", "Bearer "+auth) - } - } - - for header, value := range c.cfg.DefaultHeader { - localVarRequest.Header.Add(header, value) - } - - return localVarRequest, nil -} - -func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { - if strings.Contains(contentType, "application/xml") { - if err = xml.Unmarshal(b, v); err != nil { - return err - } - return nil - } else if strings.Contains(contentType, "application/json") { - if err = json.Unmarshal(b, v); err != nil { - return err - } - return nil - } - return errors.New("undefined response type") -} - -// Add a file to the multipart request -func addFile(w *multipart.Writer, fieldName, path string) error { - file, err := os.Open(path) - if err != nil { - return err - } - defer file.Close() - - part, err := w.CreateFormFile(fieldName, filepath.Base(path)) - if err != nil { - return err - } - _, err = io.Copy(part, file) - - return err -} - -// Prevent trying to import "fmt" -func reportError(format string, a ...interface{}) error { - return fmt.Errorf(format, a...) -} - -// Set request body from an interface{} -func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { - if bodyBuf == nil { - bodyBuf = &bytes.Buffer{} - } - - if reader, ok := body.(io.Reader); ok { - _, err = bodyBuf.ReadFrom(reader) - } else if b, ok := body.([]byte); ok { - _, err = bodyBuf.Write(b) - } else if s, ok := body.(string); ok { - _, err = bodyBuf.WriteString(s) - } else if s, ok := body.(*string); ok { - _, err = bodyBuf.WriteString(*s) - } else if jsonCheck.MatchString(contentType) { - err = json.NewEncoder(bodyBuf).Encode(body) - } else if xmlCheck.MatchString(contentType) { - xml.NewEncoder(bodyBuf).Encode(body) - } - - if err != nil { - return nil, err - } - - if bodyBuf.Len() == 0 { - err = fmt.Errorf("Invalid body type %s\n", contentType) - return nil, err - } - return bodyBuf, nil -} - -// detectContentType method is used to figure out `Request.Body` content type for request header -func detectContentType(body interface{}) string { - contentType := "text/plain; charset=utf-8" - kind := reflect.TypeOf(body).Kind() - - switch kind { - case reflect.Struct, reflect.Map, reflect.Ptr: - contentType = "application/json; charset=utf-8" - case reflect.String: - contentType = "text/plain; charset=utf-8" - default: - if b, ok := body.([]byte); ok { - contentType = http.DetectContentType(b) - } else if kind == reflect.Slice { - contentType = "application/json; charset=utf-8" - } - } - - return contentType -} - -// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go -type cacheControl map[string]string - -func parseCacheControl(headers http.Header) cacheControl { - cc := cacheControl{} - ccHeader := headers.Get("Cache-Control") - for _, part := range strings.Split(ccHeader, ",") { - part = strings.Trim(part, " ") - if part == "" { - continue - } - if strings.ContainsRune(part, '=') { - keyval := strings.Split(part, "=") - cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") - } else { - cc[part] = "" - } - } - return cc -} - -// CacheExpires helper function to determine remaining time before repeating a request. -func CacheExpires(r *http.Response) time.Time { - // Figure out when the cache expires. - var expires time.Time - now, err := time.Parse(time.RFC1123, r.Header.Get("date")) - if err != nil { - return time.Now() - } - respCacheControl := parseCacheControl(r.Header) - - if maxAge, ok := respCacheControl["max-age"]; ok { - lifetime, err := time.ParseDuration(maxAge + "s") - if err != nil { - expires = now - } - expires = now.Add(lifetime) - } else { - expiresHeader := r.Header.Get("Expires") - if expiresHeader != "" { - expires, err = time.Parse(time.RFC1123, expiresHeader) - if err != nil { - expires = now - } - } - } - return expires -} - -func strlen(s string) int { - return utf8.RuneCountInString(s) -} - -// GenericSwaggerError Provides access to the body, error and model on returned errors. -type GenericSwaggerError struct { - body []byte - error string - model interface{} -} - -// Error returns non-empty string if there was an error. -func (e GenericSwaggerError) Error() string { - return e.error -} - -// Body returns the raw bytes of the response -func (e GenericSwaggerError) Body() []byte { - return e.body -} - -// Model returns the unpacked model of the error -func (e GenericSwaggerError) Model() interface{} { - return e.model -} diff --git a/go/configuration.go b/go/configuration.go deleted file mode 100644 index eeea99e..0000000 --- a/go/configuration.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "net/http" -) - -// contextKeys are used to identify the type of value in the context. -// Since these are string, it is possible to get a short description of the -// context key for logging and debugging using key.String(). - -type contextKey string - -func (c contextKey) String() string { - return "auth " + string(c) -} - -var ( - // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. - ContextOAuth2 = contextKey("token") - - // ContextBasicAuth takes BasicAuth as authentication for the request. - ContextBasicAuth = contextKey("basic") - - // ContextAccessToken takes a string oauth2 access token as authentication for the request. - ContextAccessToken = contextKey("accesstoken") - - // ContextAPIKey takes an APIKey as authentication for the request - ContextAPIKey = contextKey("apikey") -) - -// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth -type BasicAuth struct { - UserName string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` -} - -// APIKey provides API key based authentication to a request passed via context using ContextAPIKey -type APIKey struct { - Key string - Prefix string -} - -type Configuration struct { - BasePath string `json:"basePath,omitempty"` - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - HTTPClient *http.Client -} - -func NewConfiguration() *Configuration { - cfg := &Configuration{ - BasePath: "https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1", - DefaultHeader: make(map[string]string), - UserAgent: "Swagger-Codegen/1.0.0/go", - } - return cfg -} - -func (c *Configuration) AddDefaultHeader(key string, value string) { - c.DefaultHeader[key] = value -} diff --git a/go/docs/Body.md b/go/docs/Body.md deleted file mode 100644 index 62bf0fa..0000000 --- a/go/docs/Body.md +++ /dev/null @@ -1,9 +0,0 @@ -# Body - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Effects** | **string** | Updated effects of the pet | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/Category.md b/go/docs/Category.md deleted file mode 100644 index f1f3708..0000000 --- a/go/docs/Category.md +++ /dev/null @@ -1,10 +0,0 @@ -# Category - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Id** | **int64** | | [optional] [default to null] -**Name** | **string** | | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/Effect.md b/go/docs/Effect.md deleted file mode 100644 index f794bf6..0000000 --- a/go/docs/Effect.md +++ /dev/null @@ -1,10 +0,0 @@ -# Effect - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Id** | **int64** | | [optional] [default to null] -**Name** | **string** | | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/ModelApiResponse.md b/go/docs/ModelApiResponse.md deleted file mode 100644 index 3599bb0..0000000 --- a/go/docs/ModelApiResponse.md +++ /dev/null @@ -1,11 +0,0 @@ -# ModelApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Code** | **int32** | | [optional] [default to null] -**Type_** | **string** | | [optional] [default to null] -**Message** | **string** | | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/Smell.md b/go/docs/Smell.md deleted file mode 100644 index adcba60..0000000 --- a/go/docs/Smell.md +++ /dev/null @@ -1,10 +0,0 @@ -# Smell - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Id** | **int64** | | [optional] [default to null] -**Name** | **string** | | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/Strain.md b/go/docs/Strain.md deleted file mode 100644 index 1547a7b..0000000 --- a/go/docs/Strain.md +++ /dev/null @@ -1,10 +0,0 @@ -# Strain - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Id** | **int64** | | [optional] [default to null] -**Name** | **string** | | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/Tag.md b/go/docs/Tag.md deleted file mode 100644 index c14ae62..0000000 --- a/go/docs/Tag.md +++ /dev/null @@ -1,10 +0,0 @@ -# Tag - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Id** | **int64** | | [optional] [default to null] -**Name** | **string** | | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/Taste.md b/go/docs/Taste.md deleted file mode 100644 index cf3b5db..0000000 --- a/go/docs/Taste.md +++ /dev/null @@ -1,10 +0,0 @@ -# Taste - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Id** | **int64** | | [optional] [default to null] -**Name** | **string** | | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/Terpene.md b/go/docs/Terpene.md deleted file mode 100644 index 5b8c98f..0000000 --- a/go/docs/Terpene.md +++ /dev/null @@ -1,15 +0,0 @@ -# Terpene - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Id** | **int64** | | [optional] [default to null] -**Category** | [***Category**](Category.md) | | [optional] [default to null] -**Name** | **string** | | [default to null] -**Tags** | [**[]Tag**](Tag.md) | | [optional] [default to null] -**Tastes** | [**[]Taste**](Taste.md) | | [optional] [default to null] -**Smells** | [**[]Smell**](Smell.md) | | [optional] [default to null] -**Strains** | [**[]Strain**](Strain.md) | | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/TerpeneApi.md b/go/docs/TerpeneApi.md deleted file mode 100644 index 9824556..0000000 --- a/go/docs/TerpeneApi.md +++ /dev/null @@ -1,190 +0,0 @@ -# {{classname}} - -All URIs are relative to *https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**AddTerpene**](TerpeneApi.md#AddTerpene) | **Post** /terpene | Add a new terpene to the api -[**DeleteTerpene**](TerpeneApi.md#DeleteTerpene) | **Delete** /terpene/{terpeneId} | Deletes a terpene -[**FindTerpenesByEffect**](TerpeneApi.md#FindTerpenesByEffect) | **Get** /terpene/findByEffect | Finds Terpenes by effect -[**GetTerpeneById**](TerpeneApi.md#GetTerpeneById) | **Get** /terpene/{terpeneId} | Find terpene by ID -[**UpdateTerpene**](TerpeneApi.md#UpdateTerpene) | **Put** /terpene | Update an existing terpene -[**UpdateTerpeneByID**](TerpeneApi.md#UpdateTerpeneByID) | **Post** /terpene/{terpeneId} | Updates a terpene in the api - -# **AddTerpene** -> AddTerpene(ctx, body) -Add a new terpene to the api - -Add new terpene to the api - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **body** | [**Terpene**](Terpene.md)| Terpene object | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **DeleteTerpene** -> DeleteTerpene(ctx, apiKey, terpeneId) -Deletes a terpene - -Deletes a terpene from the API - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **apiKey** | **string**| | - **terpeneId** | **int64**| Terpene id to delete | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **FindTerpenesByEffect** -> []Terpene FindTerpenesByEffect(ctx, effect) -Finds Terpenes by effect - -Multiple status values can be provided with comma separated strings - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **effect** | [**[]string**](string.md)| Effect values that need to be considered for filter | - -### Return type - -[**[]Terpene**](Terpene.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **GetTerpeneById** -> Terpene GetTerpeneById(ctx, terpeneId) -Find terpene by ID - -Returns a single terpene - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **terpeneId** | **int64**| ID of terpene to return | - -### Return type - -[**Terpene**](Terpene.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **UpdateTerpene** -> UpdateTerpene(ctx, body) -Update an existing terpene - -Update terpene in the api - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **body** | [**Terpene**](Terpene.md)| Terpene object | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **UpdateTerpeneByID** -> UpdateTerpeneByID(ctx, terpeneId, optional) -Updates a terpene in the api - -Update a single terpene in the API - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **terpeneId** | **int64**| ID of terpene that needs to be updated | - **optional** | ***TerpeneApiUpdateTerpeneByIDOpts** | optional parameters | nil if no parameters - -### Optional Parameters -Optional parameters are passed through a pointer to a TerpeneApiUpdateTerpeneByIDOpts struct -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - - **effects** | **optional.**| | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/go/docs/User.md b/go/docs/User.md deleted file mode 100644 index 79f38b6..0000000 --- a/go/docs/User.md +++ /dev/null @@ -1,16 +0,0 @@ -# User - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Id** | **int64** | | [optional] [default to null] -**Username** | **string** | | [optional] [default to null] -**FirstName** | **string** | | [optional] [default to null] -**LastName** | **string** | | [optional] [default to null] -**Email** | **string** | | [optional] [default to null] -**Password** | **string** | | [optional] [default to null] -**Phone** | **string** | | [optional] [default to null] -**UserStatus** | **int32** | User Status | [optional] [default to null] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/go/docs/UserApi.md b/go/docs/UserApi.md deleted file mode 100644 index d7f72c3..0000000 --- a/go/docs/UserApi.md +++ /dev/null @@ -1,227 +0,0 @@ -# {{classname}} - -All URIs are relative to *https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**CreateUser**](UserApi.md#CreateUser) | **Post** /user | Create user -[**CreateUsersWithArrayInput**](UserApi.md#CreateUsersWithArrayInput) | **Post** /user/createWithArray | Creates list of users with given input array -[**CreateUsersWithListInput**](UserApi.md#CreateUsersWithListInput) | **Post** /user/createWithList | Creates list of users with given input array -[**DeleteUser**](UserApi.md#DeleteUser) | **Delete** /user/{username} | Delete user -[**GetUserByName**](UserApi.md#GetUserByName) | **Get** /user/{username} | Get user by user name -[**LoginUser**](UserApi.md#LoginUser) | **Get** /user/login | Logs user into the system -[**LogoutUser**](UserApi.md#LogoutUser) | **Get** /user/logout | Logs out current logged in user session -[**UpdateUser**](UserApi.md#UpdateUser) | **Put** /user/{username} | Updated user - -# **CreateUser** -> CreateUser(ctx, body) -Create user - -This can only be done by the logged in user. - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **body** | [**User**](User.md)| Created user object | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **CreateUsersWithArrayInput** -> CreateUsersWithArrayInput(ctx, body) -Creates list of users with given input array - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **body** | [**[]User**](User.md)| List of user object | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **CreateUsersWithListInput** -> CreateUsersWithListInput(ctx, body) -Creates list of users with given input array - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **body** | [**[]User**](User.md)| List of user object | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **DeleteUser** -> DeleteUser(ctx, username) -Delete user - -This can only be done by the logged in user. - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **username** | **string**| The name that needs to be deleted | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **GetUserByName** -> User GetUserByName(ctx, username) -Get user by user name - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **username** | **string**| The name that needs to be fetched. Use user1 for testing. | - -### Return type - -[**User**](User.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **LoginUser** -> string LoginUser(ctx, username, password) -Logs user into the system - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **username** | **string**| The user name for login | - **password** | **string**| The password for login in clear text | - -### Return type - -**string** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **LogoutUser** -> LogoutUser(ctx, ) -Logs out current logged in user session - -### Required Parameters -This endpoint does not need any parameter. - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **UpdateUser** -> UpdateUser(ctx, body, username) -Updated user - -This can only be done by the logged in user. - -### Required Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. - **body** | [**User**](User.md)| Updated user object | - **username** | **string**| name that need to be updated | - -### Return type - - (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/go/git_push.sh b/go/git_push.sh deleted file mode 100644 index ae01b18..0000000 --- a/go/git_push.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 - -if [ "$git_user_id" = "" ]; then - git_user_id="GIT_USER_ID" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="GIT_REPO_ID" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="Minor update" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=`git remote` -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' - diff --git a/go/model_api_response.go b/go/model_api_response.go deleted file mode 100644 index 6b1e550..0000000 --- a/go/model_api_response.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type ModelApiResponse struct { - Code int32 `json:"code,omitempty"` - Type_ string `json:"type,omitempty"` - Message string `json:"message,omitempty"` -} diff --git a/go/model_body.go b/go/model_body.go deleted file mode 100644 index 8fed0f6..0000000 --- a/go/model_body.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Body struct { - // Updated effects of the pet - Effects string `json:"effects,omitempty"` -} diff --git a/go/model_category.go b/go/model_category.go deleted file mode 100644 index a64f95b..0000000 --- a/go/model_category.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Category struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/go/model_effect.go b/go/model_effect.go deleted file mode 100644 index 0a86f6a..0000000 --- a/go/model_effect.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Effect struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/go/model_smell.go b/go/model_smell.go deleted file mode 100644 index 6e8982c..0000000 --- a/go/model_smell.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Smell struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/go/model_strain.go b/go/model_strain.go deleted file mode 100644 index 2764563..0000000 --- a/go/model_strain.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Strain struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/go/model_tag.go b/go/model_tag.go deleted file mode 100644 index c1e8f06..0000000 --- a/go/model_tag.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Tag struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/go/model_taste.go b/go/model_taste.go deleted file mode 100644 index f3e90b2..0000000 --- a/go/model_taste.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Taste struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} diff --git a/go/model_terpene.go b/go/model_terpene.go deleted file mode 100644 index 6519128..0000000 --- a/go/model_terpene.go +++ /dev/null @@ -1,20 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type Terpene struct { - Id int64 `json:"id,omitempty"` - Category *Category `json:"category,omitempty"` - Name string `json:"name"` - Tags []Tag `json:"tags,omitempty"` - Tastes []Taste `json:"tastes,omitempty"` - Smells []Smell `json:"smells,omitempty"` - Strains []Strain `json:"strains,omitempty"` -} diff --git a/go/model_user.go b/go/model_user.go deleted file mode 100644 index 86c79d6..0000000 --- a/go/model_user.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -type User struct { - Id int64 `json:"id,omitempty"` - Username string `json:"username,omitempty"` - FirstName string `json:"firstName,omitempty"` - LastName string `json:"lastName,omitempty"` - Email string `json:"email,omitempty"` - Password string `json:"password,omitempty"` - Phone string `json:"phone,omitempty"` - // User Status - UserStatus int32 `json:"userStatus,omitempty"` -} diff --git a/go/response.go b/go/response.go deleted file mode 100644 index 2ac1f8e..0000000 --- a/go/response.go +++ /dev/null @@ -1,43 +0,0 @@ -/* - * OpenTerps - * - * An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them. - * - * API version: 0.0.1 - * Contact: benjamminredden@gmail.com - * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) - */ -package swagger - -import ( - "net/http" -) - -type APIResponse struct { - *http.Response `json:"-"` - Message string `json:"message,omitempty"` - // Operation is the name of the swagger operation. - Operation string `json:"operation,omitempty"` - // RequestURL is the request URL. This value is always available, even if the - // embedded *http.Response is nil. - RequestURL string `json:"url,omitempty"` - // Method is the HTTP method used for the request. This value is always - // available, even if the embedded *http.Response is nil. - Method string `json:"method,omitempty"` - // Payload holds the contents of the response body (which may be nil or empty). - // This is provided here as the raw response.Body() reader will have already - // been drained. - Payload []byte `json:"-"` -} - -func NewAPIResponse(r *http.Response) *APIResponse { - - response := &APIResponse{Response: r} - return response -} - -func NewAPIResponseWithError(errorMessage string) *APIResponse { - - response := &APIResponse{Message: errorMessage} - return response -} diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..70377d6 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,8 @@ +# https://devcenter.heroku.com/articles/heroku-yml-build-manifest +# Officially unsupported, but works. +build: + languages: + - go + +run: + web: openterps diff --git a/json-resolved/.swagger-codegen-ignore b/json-resolved/.swagger-codegen-ignore deleted file mode 100644 index c5fa491..0000000 --- a/json-resolved/.swagger-codegen-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/json-resolved/.swagger-codegen/VERSION b/json-resolved/.swagger-codegen/VERSION deleted file mode 100644 index 402b44e..0000000 --- a/json-resolved/.swagger-codegen/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.0.21 \ No newline at end of file diff --git a/json-resolved/README.md b/json-resolved/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/json-resolved/swagger.json b/json-resolved/swagger.json deleted file mode 100644 index 5c2ebf0..0000000 --- a/json-resolved/swagger.json +++ /dev/null @@ -1,710 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "title" : "OpenTerps", - "description" : "An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them.", - "termsOfService" : "https://wayhigh.we.bs", - "contact" : { - "email" : "benjamminredden@gmail.com" - }, - "license" : { - "name" : "Apache 2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version" : "0.0.1" - }, - "externalDocs" : { - "description" : "Find out more about OpenTerps", - "url" : "https://wayhigh.we.bs" - }, - "servers" : [ { - "url" : "https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1" - } ], - "tags" : [ { - "name" : "cannabis", - "description" : "The plant." - }, { - "name" : "terpene", - "description" : "One of the most important parts of the cannabis plant." - }, { - "name" : "effects", - "description" : "The effect of said terpenes." - } ], - "paths" : { - "/terpene" : { - "put" : { - "tags" : [ "terpene" ], - "summary" : "Update an existing terpene", - "description" : "Update terpene in the api", - "operationId" : "updateTerpene", - "requestBody" : { - "$ref" : "#/components/requestBodies/Terpene" - }, - "responses" : { - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Terpene not found" - }, - "405" : { - "description" : "Validation exception" - } - } - }, - "post" : { - "tags" : [ "terpene" ], - "summary" : "Add a new terpene to the api", - "description" : "Add new terpene to the api", - "operationId" : "addTerpene", - "requestBody" : { - "$ref" : "#/components/requestBodies/Terpene" - }, - "responses" : { - "405" : { - "description" : "Invalid input" - } - } - } - }, - "/terpene/findByEffect" : { - "get" : { - "tags" : [ "terpene" ], - "summary" : "Finds Terpenes by effect", - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findTerpenesByEffect", - "parameters" : [ { - "name" : "effect", - "in" : "query", - "description" : "Effect values that need to be considered for filter", - "required" : true, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Terpene" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Terpene" - } - } - } - } - }, - "400" : { - "description" : "Invalid effect value" - } - } - } - }, - "/terpene/{terpeneId}" : { - "get" : { - "tags" : [ "terpene" ], - "summary" : "Find terpene by ID", - "description" : "Returns a single terpene", - "operationId" : "getTerpeneById", - "parameters" : [ { - "name" : "terpeneId", - "in" : "path", - "description" : "ID of terpene to return", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Terpene" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Terpene" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Terpene not found" - } - } - }, - "post" : { - "tags" : [ "terpene" ], - "summary" : "Updates a terpene in the api", - "description" : "Update a single terpene in the API", - "operationId" : "updateTerpeneByID", - "parameters" : [ { - "name" : "terpeneId", - "in" : "path", - "description" : "ID of terpene that needs to be updated", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "$ref" : "#/components/schemas/body" - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input" - } - } - }, - "delete" : { - "tags" : [ "terpene" ], - "summary" : "Deletes a terpene", - "description" : "Deletes a terpene from the API", - "operationId" : "deleteTerpene", - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - }, { - "name" : "terpeneId", - "in" : "path", - "description" : "Terpene id to delete", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Terpene not found" - } - } - } - }, - "/user" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Create user", - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "description" : "Created user object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/createWithArray" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/createWithList" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/login" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", - "operationId" : "loginUser", - "parameters" : [ { - "name" : "username", - "in" : "query", - "description" : "The user name for login", - "required" : true, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "password", - "in" : "query", - "description" : "The password for login in clear text", - "required" : true, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, - "X-Expires-After" : { - "description" : "date in UTC when token expires", - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - } - }, - "400" : { - "description" : "Invalid username/password supplied" - } - } - } - }, - "/user/logout" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/{username}" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", - "operationId" : "getUserByName", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing. ", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - } - }, - "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "name that need to be updated", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "description" : "Updated user object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied" - }, - "404" : { - "description" : "User not found" - } - } - }, - "delete" : { - "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "style" : "simple", - "explode" : false, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - } - } - } - }, - "components" : { - "schemas" : { - "User" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "type" : "integer", - "description" : "User Status", - "format" : "int32" - } - }, - "xml" : { - "name" : "User" - } - }, - "Category" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Category" - } - }, - "Tag" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Tag" - } - }, - "Effect" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Effect" - } - }, - "Strain" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Strain" - } - }, - "Taste" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Taste" - } - }, - "Smell" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Smell" - } - }, - "Terpene" : { - "required" : [ "name" ], - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "type" : "string", - "example" : "myrcene" - }, - "tags" : { - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Tag" - } - }, - "tastes" : { - "type" : "array", - "xml" : { - "name" : "taste", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Taste" - } - }, - "smells" : { - "type" : "array", - "xml" : { - "name" : "smell", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Smell" - } - }, - "strains" : { - "type" : "array", - "xml" : { - "name" : "strain", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Strain" - } - } - }, - "xml" : { - "name" : "Terpene" - } - }, - "ApiResponse" : { - "type" : "object", - "properties" : { - "code" : { - "type" : "integer", - "format" : "int32" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - } - }, - "body" : { - "type" : "object", - "properties" : { - "effects" : { - "type" : "string", - "description" : "Updated effects of the pet" - } - } - } - }, - "requestBodies" : { - "UserArray" : { - "description" : "List of user object", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "required" : true - }, - "Terpene" : { - "description" : "Terpene object", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Terpene" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Terpene" - } - } - }, - "required" : true - } - } - } -} \ No newline at end of file diff --git a/json-unresolved/swagger.json b/json-unresolved/swagger.json deleted file mode 100644 index 34bdd6a..0000000 --- a/json-unresolved/swagger.json +++ /dev/null @@ -1,689 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "description" : "An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them.", - "version" : "0.0.1", - "title" : "OpenTerps", - "termsOfService" : "https://wayhigh.we.bs", - "contact" : { - "email" : "benjamminredden@gmail.com" - }, - "license" : { - "name" : "Apache 2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "tags" : [ { - "name" : "cannabis", - "description" : "The plant." - }, { - "name" : "terpene", - "description" : "One of the most important parts of the cannabis plant." - }, { - "name" : "effects", - "description" : "The effect of said terpenes." - } ], - "paths" : { - "/terpene" : { - "post" : { - "tags" : [ "terpene" ], - "summary" : "Add a new terpene to the api", - "description" : "Add new terpene to the api", - "operationId" : "addTerpene", - "requestBody" : { - "$ref" : "#/components/requestBodies/Terpene" - }, - "responses" : { - "405" : { - "description" : "Invalid input" - } - } - }, - "put" : { - "tags" : [ "terpene" ], - "summary" : "Update an existing terpene", - "description" : "Update terpene in the api", - "operationId" : "updateTerpene", - "requestBody" : { - "$ref" : "#/components/requestBodies/Terpene" - }, - "responses" : { - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Terpene not found" - }, - "405" : { - "description" : "Validation exception" - } - } - } - }, - "/terpene/findByEffect" : { - "get" : { - "tags" : [ "terpene" ], - "summary" : "Finds Terpenes by effect", - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findTerpenesByEffect", - "parameters" : [ { - "name" : "effect", - "in" : "query", - "description" : "Effect values that need to be considered for filter", - "required" : true, - "explode" : true, - "schema" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Terpene" - } - } - }, - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Terpene" - } - } - } - } - }, - "400" : { - "description" : "Invalid effect value" - } - } - } - }, - "/terpene/{terpeneId}" : { - "get" : { - "tags" : [ "terpene" ], - "summary" : "Find terpene by ID", - "description" : "Returns a single terpene", - "operationId" : "getTerpeneById", - "parameters" : [ { - "name" : "terpeneId", - "in" : "path", - "description" : "ID of terpene to return", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Terpene" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Terpene" - } - } - } - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Terpene not found" - } - } - }, - "post" : { - "tags" : [ "terpene" ], - "summary" : "Updates a terpene in the api", - "description" : "Update a single terpene in the API", - "operationId" : "updateTerpeneByID", - "parameters" : [ { - "name" : "terpeneId", - "in" : "path", - "description" : "ID of terpene that needs to be updated", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "type" : "object", - "properties" : { - "effects" : { - "description" : "Updated effects of the pet", - "type" : "string" - } - } - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input" - } - } - }, - "delete" : { - "tags" : [ "terpene" ], - "summary" : "Deletes a terpene", - "description" : "Deletes a terpene from the API", - "operationId" : "deleteTerpene", - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "required" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "terpeneId", - "in" : "path", - "description" : "Terpene id to delete", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Terpene not found" - } - } - } - }, - "/user" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Create user", - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Created user object", - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/createWithArray" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "description" : "", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/createWithList" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "description" : "", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/login" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", - "description" : "", - "operationId" : "loginUser", - "parameters" : [ { - "name" : "username", - "in" : "query", - "description" : "The user name for login", - "required" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "password", - "in" : "query", - "description" : "The password for login in clear text", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, - "X-Expires-After" : { - "description" : "date in UTC when token expires", - "schema" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - } - }, - "400" : { - "description" : "Invalid username/password supplied" - } - } - } - }, - "/user/logout" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", - "description" : "", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/{username}" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", - "description" : "", - "operationId" : "getUserByName", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing. ", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - } - }, - "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "name that need to be updated", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Updated user object", - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied" - }, - "404" : { - "description" : "User not found" - } - } - }, - "delete" : { - "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - } - } - } - }, - "externalDocs" : { - "description" : "Find out more about OpenTerps", - "url" : "https://wayhigh.we.bs" - }, - "servers" : [ { - "url" : "https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1" - } ], - "components" : { - "requestBodies" : { - "UserArray" : { - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/User" - } - } - } - }, - "description" : "List of user object", - "required" : true - }, - "Terpene" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Terpene" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Terpene" - } - } - }, - "description" : "Terpene object", - "required" : true - } - }, - "schemas" : { - "User" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "type" : "integer", - "format" : "int32", - "description" : "User Status" - } - }, - "xml" : { - "name" : "User" - } - }, - "Category" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Category" - } - }, - "Tag" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Tag" - } - }, - "Effect" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Effect" - } - }, - "Strain" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Strain" - } - }, - "Taste" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Taste" - } - }, - "Smell" : { - "type" : "object", - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Smell" - } - }, - "Terpene" : { - "type" : "object", - "required" : [ "name" ], - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "type" : "string", - "example" : "myrcene" - }, - "tags" : { - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Tag" - } - }, - "tastes" : { - "type" : "array", - "xml" : { - "name" : "taste", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Taste" - } - }, - "smells" : { - "type" : "array", - "xml" : { - "name" : "smell", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Smell" - } - }, - "strains" : { - "type" : "array", - "xml" : { - "name" : "strain", - "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Strain" - } - } - }, - "xml" : { - "name" : "Terpene" - } - }, - "ApiResponse" : { - "type" : "object", - "properties" : { - "code" : { - "type" : "integer", - "format" : "int32" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - } - } - } - } -} \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..97f6510 --- /dev/null +++ b/main.go @@ -0,0 +1,112 @@ +package main + +import ( + "log" + "net/http" + "os" + + "openterps/categories" + "openterps/dbconnector" + "openterps/effects" + "openterps/migrations" + "openterps/smells" + "openterps/strains" + "openterps/tastes" + "openterps/terpenes" + + "github.com/gin-gonic/gin" + "github.com/joho/godotenv" +) + +func main() { + err := godotenv.Load() + if err != nil { + log.Print("Error loading .env file. Hopefully this isn't local") + } + + r := gin.Default() + + dbconnector.ConnectDatabase(os.Getenv("Host"), os.Getenv("Port"), os.Getenv("User"), os.Getenv("Password"), os.Getenv("Name")) + + // GET / - home/info + r.GET("/", func(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"data": "Welcome to OpenTerps 0.0.1!"}) + }) + + // GET /terpenes + r.GET("/terpenes", terpenes.GetTerpenes) + + // POST /terpenes + r.POST("/terpenes", terpenes.CreateTerpene) + + // PUT /terpenes + r.PATCH("/terpenes/:id", terpenes.UpdateTerpene) + + // Delete /terpenes + r.DELETE("/terpenes/:id", terpenes.DeleteTerpene) + + // GET /effects + r.GET("/effects", effects.GetEffects) + + // POST /effects + r.POST("/effects", effects.CreateEffect) + + // PUT /effects + r.PATCH("/effects/:id", effects.UpdateEffect) + + // Delete /effects + r.DELETE("/effects/:id", effects.DeleteEffect) + + // GET /tastes + r.GET("/tastes", tastes.GetTastes) + + // POST /tastes + r.POST("/tastes", tastes.CreateTastes) + + // PUT /tastes + r.PATCH("/tastes/:id", tastes.UpdateTastes) + + // Delete /tastes + r.DELETE("/tastes/:id", tastes.DeleteTastes) + + // GET /smells + r.GET("/smells", smells.GetSmells) + + // POST /smells + r.POST("/smells", smells.CreateSmells) + + // PUT /smells + r.PATCH("/smells/:id", smells.UpdateSmells) + + // Delete /smells + r.DELETE("/smells/:id", smells.DeleteSmells) + + // GET /strains + r.GET("/strains", strains.GetStrains) + + // POST /strains + r.POST("/strains", strains.CreateStrains) + + // PUT /strains + r.PATCH("/strains/:id", strains.UpdateStrains) + + // Delete /strains + r.DELETE("/strains/:id", strains.DeleteStrains) + + // GET /categories + r.GET("/categories", categories.GetCategories) + + // POST /categories + r.POST("/categories", categories.CreateCategories) + + // PUT /categories + r.PATCH("/categories/:id", categories.UpdateCategories) + + // Delete /categories + r.DELETE("/categories/:id", categories.DeleteCategories) + + // POST /migrations + r.POST("/migrations", migrations.RunMigration) + + r.Run(":" + os.Getenv("PORT")) +} diff --git a/migrations/main.go b/migrations/main.go new file mode 100644 index 0000000..57aac39 --- /dev/null +++ b/migrations/main.go @@ -0,0 +1,54 @@ +package migrations + +import ( + "log" + "net/http" + "os" + + "openterps/dbconnector" + "openterps/models" + + "github.com/gin-gonic/gin" + "github.com/go-gormigrate/gormigrate/v2" + _ "github.com/jinzhu/gorm/dialects/postgres" + "gorm.io/gorm" +) + +func RunMigration(c *gin.Context) { + db := dbconnector.ConnectDatabase(os.Getenv("Host"), os.Getenv("Port"), os.Getenv("User"), os.Getenv("Password"), os.Getenv("Name")) + + m := gormigrate.New(db, gormigrate.DefaultOptions, []*gormigrate.Migration{ + { + ID: "initial-migration", + Migrate: func(tx *gorm.DB) error { + db.AutoMigrate(&models.Terpene{}) + db.AutoMigrate(&models.Category{}) + db.AutoMigrate(&models.Effect{}) + db.AutoMigrate(&models.Strain{}) + db.AutoMigrate(&models.Smell{}) + db.AutoMigrate(&models.Taste{}) + return nil + }, + Rollback: func(tx *gorm.DB) error { + tx.Migrator().DropTable("terpenes") + tx.Migrator().DropTable("categories") + tx.Migrator().DropTable("effects") + tx.Migrator().DropTable("strains") + tx.Migrator().DropTable("smells") + tx.Migrator().DropTable("tastes") + tx.Migrator().DropTable("terpene_categories") + tx.Migrator().DropTable("terpene_effects") + tx.Migrator().DropTable("terpene_strains") + tx.Migrator().DropTable("terpene_smells") + tx.Migrator().DropTable("terpene_tastes") + return nil + }, + }, + }) + + if err := m.Migrate(); err != nil { + log.Fatalf("Could not migrate: %v", err) + } + + c.JSON(http.StatusOK, gin.H{"data": "Migration ran successfully"}) +} diff --git a/models/main.go b/models/main.go new file mode 100644 index 0000000..f954a23 --- /dev/null +++ b/models/main.go @@ -0,0 +1,75 @@ +package models + +import ( + "gorm.io/gorm" +) + +type Category struct { + gorm.Model + Name string `json:"name,omitempty"` +} + +type Effect struct { + gorm.Model + Name string `json:"name,omitempty"` +} + +type Strain struct { + gorm.Model + Name string `json:"name,omitempty"` +} + +type Smell struct { + gorm.Model + Name string `json:"name,omitempty"` +} + +type Taste struct { + gorm.Model + Name string `json:"name,omitempty"` +} + +type Terpene struct { + gorm.Model + Name string `json:"name"` + Categories []Category `json:"category,omitempty" gorm:"many2many:terpene_categories;"` + Tastes []Taste `json:"tastes,omitempty" gorm:"many2many:terpene_tastes;"` + Smells []Smell `json:"smells,omitempty" gorm:"many2many:terpene_smells;"` + Strains []Strain `json:"strains,omitempty" gorm:"many2many:terpene_strains;"` + Effects []Effect `json:"effects,omitempty" gorm:"many2many:terpene_effects;"` +} + +type TerpeneResponse struct { + gorm.Model + Name string `json:"name"` + Categories []CategoryResponse `json:"category,omitempty" gorm:"many2many:terpene_categories;"` + Tastes []TasteResponse `json:"tastes,omitempty" gorm:"many2many:terpene_tastes;"` + Smells []SmellResponse `json:"smells,omitempty" gorm:"many2many:terpene_smells;"` + Strains []StrainResponse `json:"strains,omitempty" gorm:"many2many:terpene_strains;"` + Effects []EffectResponse `json:"effects,omitempty" gorm:"many2many:terpene_effects;"` +} + +type CategoryResponse struct { + Name string `json:"name,omitempty"` +} + +type EffectResponse struct { + Name string `json:"name,omitempty"` +} + +type StrainResponse struct { + Name string `json:"name,omitempty"` +} + +type SmellResponse struct { + Name string `json:"name,omitempty"` +} + +type TasteResponse struct { + Name string `json:"name,omitempty"` +} + +type AuthHeader struct { + APIUser string `json:"apiuser"` + APIKey string `json:"apikey"` +} diff --git a/nodejs-server/.swagger-codegen-ignore b/nodejs-server/.swagger-codegen-ignore deleted file mode 100644 index c5fa491..0000000 --- a/nodejs-server/.swagger-codegen-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/nodejs-server/.swagger-codegen/VERSION b/nodejs-server/.swagger-codegen/VERSION deleted file mode 100644 index 402b44e..0000000 --- a/nodejs-server/.swagger-codegen/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.0.21 \ No newline at end of file diff --git a/nodejs-server/README.md b/nodejs-server/README.md deleted file mode 100644 index 2110558..0000000 --- a/nodejs-server/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Swagger generated server - -## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub. - -### Running the server -To run the server, run: - -``` -npm start -``` - -To view the Swagger UI interface: - -``` -open http://localhost:8080/docs -``` - -This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work. diff --git a/nodejs-server/api/openapi.yaml b/nodejs-server/api/openapi.yaml deleted file mode 100644 index b3ac178..0000000 --- a/nodejs-server/api/openapi.yaml +++ /dev/null @@ -1,574 +0,0 @@ -openapi: 3.0.0 -info: - title: OpenTerps - description: An Open API that contains information about terpenes, the effects, - and the cannabis varieties that contain them. - termsOfService: https://wayhigh.we.bs - contact: - email: benjamminredden@gmail.com - license: - name: Apache 2.0 - url: http://www.apache.org/licenses/LICENSE-2.0.html - version: 0.0.1 -externalDocs: - description: Find out more about OpenTerps - url: https://wayhigh.we.bs -servers: -- url: https://virtserver.swaggerhub.com/CountryFriedCoders/OpenTerps/0.0.1 -tags: -- name: cannabis - description: The plant. -- name: terpene - description: One of the most important parts of the cannabis plant. -- name: effects - description: The effect of said terpenes. -paths: - /terpene: - put: - tags: - - terpene - summary: Update an existing terpene - description: Update terpene in the api - operationId: updateTerpene - requestBody: - $ref: '#/components/requestBodies/Terpene' - responses: - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - "405": - description: Validation exception - x-swagger-router-controller: Terpene - post: - tags: - - terpene - summary: Add a new terpene to the api - description: Add new terpene to the api - operationId: addTerpene - requestBody: - $ref: '#/components/requestBodies/Terpene' - responses: - "405": - description: Invalid input - x-swagger-router-controller: Terpene - /terpene/findByEffect: - get: - tags: - - terpene - summary: Finds Terpenes by effect - description: Multiple status values can be provided with comma separated strings - operationId: findTerpenesByEffect - parameters: - - name: effect - in: query - description: Effect values that need to be considered for filter - required: true - style: form - explode: true - schema: - type: array - items: - type: string - responses: - "200": - description: successful operation - content: - application/xml: - schema: - type: array - items: - $ref: '#/components/schemas/Terpene' - x-content-type: application/xml - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Terpene' - "400": - description: Invalid effect value - x-swagger-router-controller: Terpene - /terpene/{terpeneId}: - get: - tags: - - terpene - summary: Find terpene by ID - description: Returns a single terpene - operationId: getTerpeneById - parameters: - - name: terpeneId - in: path - description: ID of terpene to return - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "200": - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/Terpene' - application/json: - schema: - $ref: '#/components/schemas/Terpene' - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - x-swagger-router-controller: Terpene - post: - tags: - - terpene - summary: Updates a terpene in the api - description: Update a single terpene in the API - operationId: updateTerpeneByID - parameters: - - name: terpeneId - in: path - description: ID of terpene that needs to be updated - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - requestBody: - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/body' - responses: - "405": - description: Invalid input - x-swagger-router-controller: Terpene - delete: - tags: - - terpene - summary: Deletes a terpene - description: Deletes a terpene from the API - operationId: deleteTerpene - parameters: - - name: api_key - in: header - required: true - style: simple - explode: false - schema: - type: string - - name: terpeneId - in: path - description: Terpene id to delete - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - "400": - description: Invalid ID supplied - "404": - description: Terpene not found - x-swagger-router-controller: Terpene - /user: - post: - tags: - - user - summary: Create user - description: This can only be done by the logged in user. - operationId: createUser - requestBody: - description: Created user object - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - responses: - default: - description: successful operation - x-swagger-router-controller: User - /user/createWithArray: - post: - tags: - - user - summary: Creates list of users with given input array - operationId: createUsersWithArrayInput - requestBody: - $ref: '#/components/requestBodies/UserArray' - responses: - default: - description: successful operation - x-swagger-router-controller: User - /user/createWithList: - post: - tags: - - user - summary: Creates list of users with given input array - operationId: createUsersWithListInput - requestBody: - $ref: '#/components/requestBodies/UserArray' - responses: - default: - description: successful operation - x-swagger-router-controller: User - /user/login: - get: - tags: - - user - summary: Logs user into the system - operationId: loginUser - parameters: - - name: username - in: query - description: The user name for login - required: true - style: form - explode: true - schema: - type: string - - name: password - in: query - description: The password for login in clear text - required: true - style: form - explode: true - schema: - type: string - responses: - "200": - description: successful operation - headers: - X-Rate-Limit: - description: calls per hour allowed by the user - style: simple - explode: false - schema: - type: integer - format: int32 - X-Expires-After: - description: date in UTC when token expires - style: simple - explode: false - schema: - type: string - format: date-time - content: - application/xml: - schema: - type: string - x-content-type: application/xml - application/json: - schema: - type: string - "400": - description: Invalid username/password supplied - x-swagger-router-controller: User - /user/logout: - get: - tags: - - user - summary: Logs out current logged in user session - operationId: logoutUser - responses: - default: - description: successful operation - x-swagger-router-controller: User - /user/{username}: - get: - tags: - - user - summary: Get user by user name - operationId: getUserByName - parameters: - - name: username - in: path - description: 'The name that needs to be fetched. Use user1 for testing. ' - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/User' - application/json: - schema: - $ref: '#/components/schemas/User' - "400": - description: Invalid username supplied - "404": - description: User not found - x-swagger-router-controller: User - put: - tags: - - user - summary: Updated user - description: This can only be done by the logged in user. - operationId: updateUser - parameters: - - name: username - in: path - description: name that need to be updated - required: true - style: simple - explode: false - schema: - type: string - requestBody: - description: Updated user object - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - responses: - "400": - description: Invalid user supplied - "404": - description: User not found - x-swagger-router-controller: User - delete: - tags: - - user - summary: Delete user - description: This can only be done by the logged in user. - operationId: deleteUser - parameters: - - name: username - in: path - description: The name that needs to be deleted - required: true - style: simple - explode: false - schema: - type: string - responses: - "400": - description: Invalid username supplied - "404": - description: User not found - x-swagger-router-controller: User -components: - schemas: - User: - type: object - properties: - id: - type: integer - format: int64 - username: - type: string - firstName: - type: string - lastName: - type: string - email: - type: string - password: - type: string - phone: - type: string - userStatus: - type: integer - description: User Status - format: int32 - example: - firstName: firstName - lastName: lastName - password: password - userStatus: 6 - phone: phone - id: 0 - email: email - username: username - xml: - name: User - Category: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 6 - xml: - name: Category - Tag: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 1 - xml: - name: Tag - Effect: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - xml: - name: Effect - Strain: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 2 - xml: - name: Strain - Taste: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 5 - xml: - name: Taste - Smell: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - example: - name: name - id: 5 - xml: - name: Smell - Terpene: - required: - - name - type: object - properties: - id: - type: integer - format: int64 - category: - $ref: '#/components/schemas/Category' - name: - type: string - example: myrcene - tags: - type: array - xml: - name: tag - wrapped: true - items: - $ref: '#/components/schemas/Tag' - tastes: - type: array - xml: - name: taste - wrapped: true - items: - $ref: '#/components/schemas/Taste' - smells: - type: array - xml: - name: smell - wrapped: true - items: - $ref: '#/components/schemas/Smell' - strains: - type: array - xml: - name: strain - wrapped: true - items: - $ref: '#/components/schemas/Strain' - example: - tastes: - - name: name - id: 5 - - name: name - id: 5 - smells: - - name: name - id: 5 - - name: name - id: 5 - name: myrcene - id: 0 - category: - name: name - id: 6 - strains: - - name: name - id: 2 - - name: name - id: 2 - tags: - - name: name - id: 1 - - name: name - id: 1 - xml: - name: Terpene - ApiResponse: - type: object - properties: - code: - type: integer - format: int32 - type: - type: string - message: - type: string - body: - type: object - properties: - effects: - type: string - description: Updated effects of the pet - requestBodies: - UserArray: - description: List of user object - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true - Terpene: - description: Terpene object - content: - application/json: - schema: - $ref: '#/components/schemas/Terpene' - application/xml: - schema: - $ref: '#/components/schemas/Terpene' - required: true diff --git a/nodejs-server/controllers/Terpene.js b/nodejs-server/controllers/Terpene.js deleted file mode 100644 index 3074e18..0000000 --- a/nodejs-server/controllers/Terpene.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -var utils = require('../utils/writer.js'); -var Terpene = require('../service/TerpeneService'); - -module.exports.addTerpene = function addTerpene (req, res, next, body) { - Terpene.addTerpene(body) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.deleteTerpene = function deleteTerpene (req, res, next, api_key, terpeneId) { - Terpene.deleteTerpene(api_key, terpeneId) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.findTerpenesByEffect = function findTerpenesByEffect (req, res, next, effect) { - Terpene.findTerpenesByEffect(effect) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.getTerpeneById = function getTerpeneById (req, res, next, terpeneId) { - Terpene.getTerpeneById(terpeneId) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.updateTerpene = function updateTerpene (req, res, next, body) { - Terpene.updateTerpene(body) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.updateTerpeneByID = function updateTerpeneByID (req, res, next, terpeneId) { - Terpene.updateTerpeneByID(terpeneId) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; diff --git a/nodejs-server/controllers/User.js b/nodejs-server/controllers/User.js deleted file mode 100644 index 1742922..0000000 --- a/nodejs-server/controllers/User.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -var utils = require('../utils/writer.js'); -var User = require('../service/UserService'); - -module.exports.createUser = function createUser (req, res, next, body) { - User.createUser(body) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next, body) { - User.createUsersWithArrayInput(body) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next, body) { - User.createUsersWithListInput(body) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.deleteUser = function deleteUser (req, res, next, username) { - User.deleteUser(username) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.getUserByName = function getUserByName (req, res, next, username) { - User.getUserByName(username) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.loginUser = function loginUser (req, res, next, username, password) { - User.loginUser(username, password) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.logoutUser = function logoutUser (req, res, next) { - User.logoutUser() - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; - -module.exports.updateUser = function updateUser (req, res, next, body, username) { - User.updateUser(body, username) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; diff --git a/nodejs-server/index.js b/nodejs-server/index.js deleted file mode 100644 index ecb8ba1..0000000 --- a/nodejs-server/index.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var path = require('path'); -var http = require('http'); - -var oas3Tools = require('oas3-tools'); -var serverPort = 8080; - -// swaggerRouter configuration -var options = { - controllers: path.join(__dirname, './controllers') -}; - -var expressAppConfig = oas3Tools.expressAppConfig(path.join(__dirname, 'api/openapi.yaml'), options); -expressAppConfig.addValidator(); -var app = expressAppConfig.getApp(); - -// Initialize the Swagger middleware -http.createServer(app).listen(serverPort, function () { - console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort); - console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort); -}); - diff --git a/nodejs-server/package.json b/nodejs-server/package.json deleted file mode 100644 index 4e9a86c..0000000 --- a/nodejs-server/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "openterps", - "version": "0.0.1", - "description": "An Open API that contains information about terpenes, the effects, and the cannabis varieties that contain them.", - "main": "index.js", - "scripts": { - "prestart": "npm install", - "start": "node index.js" - }, - "keywords": [ - "swagger" - ], - "license": "Unlicense", - "private": true, - "dependencies": { - "connect": "^3.2.0", - "js-yaml": "^3.3.0", - "oas3-tools": "^2.0.2" - } -} diff --git a/nodejs-server/service/TerpeneService.js b/nodejs-server/service/TerpeneService.js deleted file mode 100644 index 14d2f04..0000000 --- a/nodejs-server/service/TerpeneService.js +++ /dev/null @@ -1,204 +0,0 @@ -'use strict'; - - -/** - * Add a new terpene to the api - * Add new terpene to the api - * - * body Terpene Terpene object - * no response value expected for this operation - **/ -exports.addTerpene = function(body) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - - -/** - * Deletes a terpene - * Deletes a terpene from the API - * - * api_key String - * terpeneId Long Terpene id to delete - * no response value expected for this operation - **/ -exports.deleteTerpene = function(api_key,terpeneId) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - - -/** - * Finds Terpenes by effect - * Multiple status values can be provided with comma separated strings - * - * effect List Effect values that need to be considered for filter - * returns List - **/ -exports.findTerpenesByEffect = function(effect) { - return new Promise(function(resolve, reject) { - var examples = {}; - examples['application/json'] = [ { - "tastes" : [ { - "name" : "name", - "id" : 5 - }, { - "name" : "name", - "id" : 5 - } ], - "smells" : [ { - "name" : "name", - "id" : 5 - }, { - "name" : "name", - "id" : 5 - } ], - "name" : "myrcene", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "strains" : [ { - "name" : "name", - "id" : 2 - }, { - "name" : "name", - "id" : 2 - } ], - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ] -}, { - "tastes" : [ { - "name" : "name", - "id" : 5 - }, { - "name" : "name", - "id" : 5 - } ], - "smells" : [ { - "name" : "name", - "id" : 5 - }, { - "name" : "name", - "id" : 5 - } ], - "name" : "myrcene", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "strains" : [ { - "name" : "name", - "id" : 2 - }, { - "name" : "name", - "id" : 2 - } ], - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ] -} ]; - if (Object.keys(examples).length > 0) { - resolve(examples[Object.keys(examples)[0]]); - } else { - resolve(); - } - }); -} - - -/** - * Find terpene by ID - * Returns a single terpene - * - * terpeneId Long ID of terpene to return - * returns Terpene - **/ -exports.getTerpeneById = function(terpeneId) { - return new Promise(function(resolve, reject) { - var examples = {}; - examples['application/json'] = { - "tastes" : [ { - "name" : "name", - "id" : 5 - }, { - "name" : "name", - "id" : 5 - } ], - "smells" : [ { - "name" : "name", - "id" : 5 - }, { - "name" : "name", - "id" : 5 - } ], - "name" : "myrcene", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "strains" : [ { - "name" : "name", - "id" : 2 - }, { - "name" : "name", - "id" : 2 - } ], - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ] -}; - if (Object.keys(examples).length > 0) { - resolve(examples[Object.keys(examples)[0]]); - } else { - resolve(); - } - }); -} - - -/** - * Update an existing terpene - * Update terpene in the api - * - * body Terpene Terpene object - * no response value expected for this operation - **/ -exports.updateTerpene = function(body) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - - -/** - * Updates a terpene in the api - * Update a single terpene in the API - * - * terpeneId Long ID of terpene that needs to be updated - * no response value expected for this operation - **/ -exports.updateTerpeneByID = function(terpeneId) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - diff --git a/nodejs-server/service/UserService.js b/nodejs-server/service/UserService.js deleted file mode 100644 index 8a27190..0000000 --- a/nodejs-server/service/UserService.js +++ /dev/null @@ -1,131 +0,0 @@ -'use strict'; - - -/** - * Create user - * This can only be done by the logged in user. - * - * body User Created user object - * no response value expected for this operation - **/ -exports.createUser = function(body) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - - -/** - * Creates list of users with given input array - * - * body List List of user object - * no response value expected for this operation - **/ -exports.createUsersWithArrayInput = function(body) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - - -/** - * Creates list of users with given input array - * - * body List List of user object - * no response value expected for this operation - **/ -exports.createUsersWithListInput = function(body) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - - -/** - * Delete user - * This can only be done by the logged in user. - * - * username String The name that needs to be deleted - * no response value expected for this operation - **/ -exports.deleteUser = function(username) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - - -/** - * Get user by user name - * - * username String The name that needs to be fetched. Use user1 for testing. - * returns User - **/ -exports.getUserByName = function(username) { - return new Promise(function(resolve, reject) { - var examples = {}; - examples['application/json'] = { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" -}; - if (Object.keys(examples).length > 0) { - resolve(examples[Object.keys(examples)[0]]); - } else { - resolve(); - } - }); -} - - -/** - * Logs user into the system - * - * username String The user name for login - * password String The password for login in clear text - * returns String - **/ -exports.loginUser = function(username,password) { - return new Promise(function(resolve, reject) { - var examples = {}; - examples['application/json'] = ""; - if (Object.keys(examples).length > 0) { - resolve(examples[Object.keys(examples)[0]]); - } else { - resolve(); - } - }); -} - - -/** - * Logs out current logged in user session - * - * no response value expected for this operation - **/ -exports.logoutUser = function() { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - - -/** - * Updated user - * This can only be done by the logged in user. - * - * body User Updated user object - * username String name that need to be updated - * no response value expected for this operation - **/ -exports.updateUser = function(body,username) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - diff --git a/nodejs-server/utils/writer.js b/nodejs-server/utils/writer.js deleted file mode 100644 index d79f6e1..0000000 --- a/nodejs-server/utils/writer.js +++ /dev/null @@ -1,43 +0,0 @@ -var ResponsePayload = function(code, payload) { - this.code = code; - this.payload = payload; -} - -exports.respondWithCode = function(code, payload) { - return new ResponsePayload(code, payload); -} - -var writeJson = exports.writeJson = function(response, arg1, arg2) { - var code; - var payload; - - if(arg1 && arg1 instanceof ResponsePayload) { - writeJson(response, arg1.payload, arg1.code); - return; - } - - if(arg2 && Number.isInteger(arg2)) { - code = arg2; - } - else { - if(arg1 && Number.isInteger(arg1)) { - code = arg1; - } - } - if(code && arg1) { - payload = arg1; - } - else if(arg1) { - payload = arg1; - } - - if(!code) { - // if no response code given, we default to 200 - code = 200; - } - if(typeof payload === 'object') { - payload = JSON.stringify(payload, null, 2); - } - response.writeHead(code, {'Content-Type': 'application/json'}); - response.end(payload); -} diff --git a/simpleauth/main.go b/simpleauth/main.go new file mode 100644 index 0000000..0046d68 --- /dev/null +++ b/simpleauth/main.go @@ -0,0 +1,25 @@ +package simpleauth + +import ( + "net/http" + "openterps/models" + "os" + + "github.com/gin-gonic/gin" +) + +func ValidateRequest(c *gin.Context) bool { + // validate auth header + var authHeader models.AuthHeader + if err := c.ShouldBindHeader(&authHeader); err != nil { + c.JSON(200, err) + return false + } + + if authHeader.APIUser != os.Getenv("APIUser") || authHeader.APIKey != os.Getenv("APIKey") { + c.JSON(http.StatusBadRequest, gin.H{"error": "You must be authenticated to do that."}) + return false + } + + return true +} diff --git a/smells/main.go b/smells/main.go new file mode 100644 index 0000000..719d5f6 --- /dev/null +++ b/smells/main.go @@ -0,0 +1,90 @@ +package smells + +import ( + "net/http" + + "openterps/dbconnector" + "openterps/models" + "openterps/simpleauth" + + "github.com/gin-gonic/gin" +) + +// GET /smells +// Get all smells +func GetSmells(c *gin.Context) { + var smells []models.Smell + dbconnector.DB.Find(&smells) + + c.JSON(http.StatusOK, gin.H{"data": smells}) +} + +type smellsInput struct { + Name string `json:"name" binding:"required"` +} + +// POST /smells +// Create a smells +func CreateSmells(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + // Validate input + var input smellsInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + // Create smells + smells := models.Smell{ + Name: input.Name, + } + dbconnector.DB.Create(&smells) + + c.JSON(http.StatusOK, gin.H{"data": smells}) + } +} + +// PATCH /smells/:id +// Update a smells +func UpdateSmells(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var smells models.Smell + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&smells).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Smell not found!"}) + return + } + + // Validate input + var input smellsInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + dbconnector.DB.Model(&smells).Updates(input) + + c.JSON(http.StatusOK, gin.H{"data": smells}) + } +} + +// DELETE /smells/:id +// Delete a smells +func DeleteSmells(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var smells models.Smell + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&smells).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Smells not found!"}) + return + } + + dbconnector.DB.Delete(&smells) + + c.JSON(http.StatusOK, gin.H{"data": true}) + } +} diff --git a/strains/main.go b/strains/main.go new file mode 100644 index 0000000..4aa66a4 --- /dev/null +++ b/strains/main.go @@ -0,0 +1,90 @@ +package strains + +import ( + "net/http" + + "openterps/dbconnector" + "openterps/models" + "openterps/simpleauth" + + "github.com/gin-gonic/gin" +) + +// GET /strains +// Get all strains +func GetStrains(c *gin.Context) { + var strains []models.Strain + dbconnector.DB.Find(&strains) + + c.JSON(http.StatusOK, gin.H{"data": strains}) +} + +type strainsInput struct { + Name string `json:"name" binding:"required"` +} + +// POST /strains +// Create a strains +func CreateStrains(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + // Validate input + var input strainsInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + // Create strains + strains := models.Strain{ + Name: input.Name, + } + dbconnector.DB.Create(&strains) + + c.JSON(http.StatusOK, gin.H{"data": strains}) + } +} + +// PATCH /strains/:id +// Update a strains +func UpdateStrains(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var strains models.Strain + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&strains).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Strain not found!"}) + return + } + + // Validate input + var input strainsInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + dbconnector.DB.Model(&strains).Updates(input) + + c.JSON(http.StatusOK, gin.H{"data": strains}) + } +} + +// DELETE /strains/:id +// Delete a strains +func DeleteStrains(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var strains models.Strain + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&strains).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Strains not found!"}) + return + } + + dbconnector.DB.Delete(&strains) + + c.JSON(http.StatusOK, gin.H{"data": true}) + } +} diff --git a/tastes/main.go b/tastes/main.go new file mode 100644 index 0000000..0dfa68c --- /dev/null +++ b/tastes/main.go @@ -0,0 +1,90 @@ +package tastes + +import ( + "net/http" + + "openterps/dbconnector" + "openterps/models" + "openterps/simpleauth" + + "github.com/gin-gonic/gin" +) + +// GET /tastes +// Get all tastes +func GetTastes(c *gin.Context) { + var tastes []models.Taste + dbconnector.DB.Find(&tastes) + + c.JSON(http.StatusOK, gin.H{"data": tastes}) +} + +type tastesInput struct { + Name string `json:"name" binding:"required"` +} + +// POST /tastes +// Create a tastes +func CreateTastes(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + // Validate input + var input tastesInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + // Create tastes + tastes := models.Taste{ + Name: input.Name, + } + dbconnector.DB.Create(&tastes) + + c.JSON(http.StatusOK, gin.H{"data": tastes}) + } +} + +// PATCH /tastes/:id +// Update a tastes +func UpdateTastes(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var tastes models.Taste + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&tastes).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Taste not found!"}) + return + } + + // Validate input + var input tastesInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + dbconnector.DB.Model(&tastes).Updates(input) + + c.JSON(http.StatusOK, gin.H{"data": tastes}) + } +} + +// DELETE /tastes/:id +// Delete a tastes +func DeleteTastes(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var tastes models.Taste + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&tastes).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Tastes not found!"}) + return + } + + dbconnector.DB.Delete(&tastes) + + c.JSON(http.StatusOK, gin.H{"data": true}) + } +} diff --git a/terpenes/main.go b/terpenes/main.go new file mode 100644 index 0000000..19dc776 --- /dev/null +++ b/terpenes/main.go @@ -0,0 +1,112 @@ +package terpenes + +import ( + "encoding/json" + "net/http" + + "openterps/dbconnector" + "openterps/models" + "openterps/simpleauth" + + "github.com/gin-gonic/gin" + "gorm.io/gorm" +) + +// GET /terpenes +// Get all terpenes +func GetTerpenes(c *gin.Context) { + var terpenes []models.Terpene + dbconnector.DB.Preload("Smells").Preload("Tastes").Preload("Categories").Preload("Strains").Preload("Effects").Find(&terpenes) + + var terpeneResponse []models.TerpeneResponse + terpeneJSON, _ := json.Marshal(terpenes) + _ = json.Unmarshal(terpeneJSON, &terpeneResponse) + + c.JSON(http.StatusOK, gin.H{"data": terpeneResponse}) +} + +type terpeneInput struct { + Name string `json:"name" binding:"required"` + Category []models.Category `json:"category"` + Taste []models.Taste `json:"taste"` + Smell []models.Smell `json:"smell"` + Strain []models.Strain `json:"strain"` + Effect []models.Effect `json:"effect"` +} + +// POST /terpenes +// Create a terpene +func CreateTerpene(c *gin.Context) { + // Validate input + var input terpeneInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + // Create terpene + terpene := models.Terpene{ + Name: input.Name, + Categories: input.Category, + Tastes: input.Taste, + Smells: input.Smell, + Strains: input.Strain, + Effects: input.Effect, + } + dbconnector.DB.Create(&terpene) + + c.JSON(http.StatusOK, gin.H{"data": terpene}) + } +} + +// PATCH /terpenes/:id +// Update a terpene +func UpdateTerpene(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var terpene models.Terpene + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&terpene).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Terp not found!"}) + return + } + + // Validate input + var input terpeneInput + if err := c.ShouldBindJSON(&input); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + terpene.Categories = append(terpene.Categories, input.Category...) + terpene.Smells = append(terpene.Smells, input.Smell...) + terpene.Tastes = append(terpene.Tastes, input.Taste...) + terpene.Effects = append(terpene.Effects, input.Effect...) + terpene.Strains = append(terpene.Strains, input.Strain...) + + dbconnector.DB.Session(&gorm.Session{FullSaveAssociations: true}).Save(&terpene) + + c.JSON(http.StatusOK, gin.H{"data": &terpene}) + } +} + +// DELETE /terpenes/:id +// Delete a terpene +func DeleteTerpene(c *gin.Context) { + userIsLoggedIn := simpleauth.ValidateRequest(c) + + if userIsLoggedIn { + var terpene models.Terpene + if err := dbconnector.DB.Where("id = ?", c.Param("id")).First(&terpene).Error; err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Terpene not found!"}) + return + } + + dbconnector.DB.Delete(&terpene) + + c.JSON(http.StatusOK, gin.H{"data": true}) + } +}