info.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * MinIO Go Library for Amazon S3 Compatible Cloud Storage
  3. * Copyright 2017-2020 MinIO, Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package notification
  18. // Indentity represents the user id, this is a compliance field.
  19. type identity struct {
  20. PrincipalID string `json:"principalId"`
  21. }
  22. // event bucket metadata.
  23. type bucketMeta struct {
  24. Name string `json:"name"`
  25. OwnerIdentity identity `json:"ownerIdentity"`
  26. ARN string `json:"arn"`
  27. }
  28. // event object metadata.
  29. type objectMeta struct {
  30. Key string `json:"key"`
  31. Size int64 `json:"size,omitempty"`
  32. ETag string `json:"eTag,omitempty"`
  33. ContentType string `json:"contentType,omitempty"`
  34. UserMetadata map[string]string `json:"userMetadata,omitempty"`
  35. VersionID string `json:"versionId,omitempty"`
  36. Sequencer string `json:"sequencer"`
  37. }
  38. // event server specific metadata.
  39. type eventMeta struct {
  40. SchemaVersion string `json:"s3SchemaVersion"`
  41. ConfigurationID string `json:"configurationId"`
  42. Bucket bucketMeta `json:"bucket"`
  43. Object objectMeta `json:"object"`
  44. }
  45. // sourceInfo represents information on the client that
  46. // triggered the event notification.
  47. type sourceInfo struct {
  48. Host string `json:"host"`
  49. Port string `json:"port"`
  50. UserAgent string `json:"userAgent"`
  51. }
  52. // Event represents an Amazon an S3 bucket notification event.
  53. type Event struct {
  54. EventVersion string `json:"eventVersion"`
  55. EventSource string `json:"eventSource"`
  56. AwsRegion string `json:"awsRegion"`
  57. EventTime string `json:"eventTime"`
  58. EventName string `json:"eventName"`
  59. UserIdentity identity `json:"userIdentity"`
  60. RequestParameters map[string]string `json:"requestParameters"`
  61. ResponseElements map[string]string `json:"responseElements"`
  62. S3 eventMeta `json:"s3"`
  63. Source sourceInfo `json:"source"`
  64. }
  65. // Info - represents the collection of notification events, additionally
  66. // also reports errors if any while listening on bucket notifications.
  67. type Info struct {
  68. Records []Event
  69. Err error
  70. }