-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from stephanwilliams/aqlfunctions
Add AQL function requests
- Loading branch information
Showing
2 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package requests | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
// CreateAQLFunction creates a new AQL user function. | ||
type CreateAQLFunction struct { | ||
Name string `json:"name"` | ||
Code string `json:"code"` | ||
IsDeterministic bool `json:"isDeterministic"` | ||
} | ||
|
||
func (r *CreateAQLFunction) Path() string { | ||
return "/_api/aqlfunction" | ||
} | ||
|
||
func (r *CreateAQLFunction) Method() string { | ||
return "POST" | ||
} | ||
|
||
func (r *CreateAQLFunction) Generate() []byte { | ||
m, _ := json.Marshal(r) | ||
return m | ||
} | ||
|
||
// DeleteAQLFunction removes an existing AQL user function. | ||
type DeleteAQLFunction struct { | ||
Name string | ||
Group bool | ||
} | ||
|
||
func (r *DeleteAQLFunction) Path() string { | ||
path := "/_api/aqlfunction/" + r.Name | ||
|
||
if r.Group { | ||
path += "?group=true" | ||
} | ||
|
||
return path | ||
} | ||
|
||
func (r *DeleteAQLFunction) Method() string { | ||
return "DELETE" | ||
} | ||
|
||
func (r *DeleteAQLFunction) Generate() []byte { | ||
return nil | ||
} | ||
|
||
// GetAQLFunctions gets all registered AQL functions. | ||
type GetAQLFunctions struct { | ||
Namespace string | ||
} | ||
|
||
func (r *GetAQLFunctions) Path() string { | ||
path := "/_api/aqlfunction" | ||
|
||
if r.Namespace != "" { | ||
path += "?namespace=" + r.Namespace | ||
} | ||
|
||
return path | ||
} | ||
|
||
func (r *GetAQLFunctions) Method() string { | ||
return "GET" | ||
} | ||
|
||
func (r *GetAQLFunctions) Generate() []byte { | ||
return nil | ||
} | ||
|
||
type AQLFunction struct { | ||
Name string `json:"name"` | ||
Code string `json:"code"` | ||
} | ||
|
||
type GetAQLFunctionsResult []AQLFunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters