forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_attachment_operation.go
63 lines (51 loc) · 1.66 KB
/
delete_attachment_operation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package ravendb
import (
"net/http"
)
var (
_ IOperation = &DeleteAttachmentOperation{}
)
type DeleteAttachmentOperation struct {
Command *DeleteAttachmentCommand
_documentId string
_name string
_changeVector *string
}
func NewDeleteAttachmentOperation(documentId string, name string, changeVector *string) *DeleteAttachmentOperation {
return &DeleteAttachmentOperation{
_documentId: documentId,
_name: name,
_changeVector: changeVector,
}
}
func (o *DeleteAttachmentOperation) GetCommand(store *IDocumentStore, conventions *DocumentConventions, cache *HttpCache) RavenCommand {
o.Command = NewDeleteAttachmentCommand(o._documentId, o._name, o._changeVector)
return o.Command
}
var _ RavenCommand = &DeleteAttachmentCommand{}
type DeleteAttachmentCommand struct {
RavenCommandBase
_documentId string
_name string
_changeVector *string
}
func NewDeleteAttachmentCommand(documentId string, name string, changeVector *string) *DeleteAttachmentCommand {
// TODO: validation
cmd := &DeleteAttachmentCommand{
RavenCommandBase: NewRavenCommandBase(),
_documentId: documentId,
_name: name,
_changeVector: changeVector,
}
cmd.RavenCommandBase.ResponseType = RavenCommandResponseType_EMPTY
return cmd
}
func (c *DeleteAttachmentCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := node.GetUrl() + "/databases/" + node.GetDatabase() + "/attachments?id=" + UrlUtils_escapeDataString(c._documentId) + "&name=" + UrlUtils_escapeDataString(c._name)
request, err := NewHttpDelete(url, nil)
if err != nil {
return nil, err
}
addChangeVectorIfNotNull(c._changeVector, request)
return request, err
}