forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_attachment_operation.go
71 lines (57 loc) · 1.87 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
64
65
66
67
68
69
70
71
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 *DocumentStore, conventions *DocumentConventions, cache *httpCache) (RavenCommand, error) {
var err error
o.Command, err = NewDeleteAttachmentCommand(o._documentID, o._name, o._changeVector)
return o.Command, err
}
var _ RavenCommand = &DeleteAttachmentCommand{}
type DeleteAttachmentCommand struct {
RavenCommandBase
_documentID string
_name string
_changeVector *string
}
func NewDeleteAttachmentCommand(documentID string, name string, changeVector *string) (*DeleteAttachmentCommand, error) {
if stringIsBlank(documentID) {
return nil, newIllegalArgumentError("documentId cannot be null")
}
if stringIsBlank(name) {
return nil, newIllegalArgumentError("name cannot be null")
}
cmd := &DeleteAttachmentCommand{
RavenCommandBase: NewRavenCommandBase(),
_documentID: documentID,
_name: name,
_changeVector: changeVector,
}
cmd.RavenCommandBase.ResponseType = RavenCommandResponseTypeEmpty
return cmd, nil
}
func (c *DeleteAttachmentCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := node.URL + "/databases/" + node.Database + "/attachments?id=" + urlUtilsEscapeDataString(c._documentID) + "&name=" + urlUtilsEscapeDataString(c._name)
request, err := newHttpDelete(url, nil)
if err != nil {
return nil, err
}
addChangeVectorIfNotNull(c._changeVector, request)
return request, err
}