github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/event/event.go (about) 1 // Copyright (c) 2015-2021 MinIO, Inc. 2 // 3 // This file is part of MinIO Object Storage stack 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package event 19 20 import ( 21 "github.com/minio/madmin-go/v3" 22 ) 23 24 const ( 25 // NamespaceFormat - namespace log format used in some event targets. 26 NamespaceFormat = "namespace" 27 28 // AccessFormat - access log format used in some event targets. 29 AccessFormat = "access" 30 31 // AMZTimeFormat - event time format. 32 AMZTimeFormat = "2006-01-02T15:04:05.000Z" 33 34 // StoreExtension - file extension of an event file in store 35 StoreExtension = ".event" 36 ) 37 38 // Identity represents access key who caused the event. 39 type Identity struct { 40 PrincipalID string `json:"principalId"` 41 } 42 43 // Bucket represents bucket metadata of the event. 44 type Bucket struct { 45 Name string `json:"name"` 46 OwnerIdentity Identity `json:"ownerIdentity"` 47 ARN string `json:"arn"` 48 } 49 50 // Object represents object metadata of the event. 51 type Object struct { 52 Key string `json:"key"` 53 Size int64 `json:"size,omitempty"` 54 ETag string `json:"eTag,omitempty"` 55 ContentType string `json:"contentType,omitempty"` 56 UserMetadata map[string]string `json:"userMetadata,omitempty"` 57 VersionID string `json:"versionId,omitempty"` 58 Sequencer string `json:"sequencer"` 59 } 60 61 // Metadata represents event metadata. 62 type Metadata struct { 63 SchemaVersion string `json:"s3SchemaVersion"` 64 ConfigurationID string `json:"configurationId"` 65 Bucket Bucket `json:"bucket"` 66 Object Object `json:"object"` 67 } 68 69 // Source represents client information who triggered the event. 70 type Source struct { 71 Host string `json:"host"` 72 Port string `json:"port"` 73 UserAgent string `json:"userAgent"` 74 } 75 76 // Event represents event notification information defined in 77 // http://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html. 78 type Event struct { 79 EventVersion string `json:"eventVersion"` 80 EventSource string `json:"eventSource"` 81 AwsRegion string `json:"awsRegion"` 82 EventTime string `json:"eventTime"` 83 EventName Name `json:"eventName"` 84 UserIdentity Identity `json:"userIdentity"` 85 RequestParameters map[string]string `json:"requestParameters"` 86 ResponseElements map[string]string `json:"responseElements"` 87 S3 Metadata `json:"s3"` 88 Source Source `json:"source"` 89 Type madmin.TraceType `json:"-"` 90 } 91 92 // Mask returns the type as mask. 93 func (e Event) Mask() uint64 { 94 return e.EventName.Mask() 95 } 96 97 // Log represents event information for some event targets. 98 type Log struct { 99 EventName Name 100 Key string 101 Records []Event 102 }