-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: add new bucket notification APIs. (#551)
Below methods are added * public NotificationConfiguration getBucketNotification(String bucketName) * public void setBucketNotification(String bucketName, NotificationConfiguration notificationConfiguration) * public void removeAllBucketNotification(String bucketName) Fixes #437
- Loading branch information
1 parent
c93f11b
commit 755099a
Showing
13 changed files
with
1,149 additions
and
0 deletions.
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
111 changes: 111 additions & 0 deletions
111
api/src/main/java/io/minio/messages/CloudFunctionConfiguration.java
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,111 @@ | ||
/* | ||
* Minio Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2017 Minio, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.minio.messages; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
import com.google.api.client.util.Key; | ||
|
||
import io.minio.errors.InvalidArgumentException; | ||
|
||
|
||
/** | ||
* Helper class to parse Amazon AWS S3 response XML containing cloud function configuration. | ||
*/ | ||
public class CloudFunctionConfiguration extends XmlEntity { | ||
@Key("Id") | ||
private String id; | ||
@Key("CloudFunction") | ||
private String cloudFunction; | ||
@Key("Event") | ||
private List<String> events = new LinkedList<>(); | ||
@Key("Filter") | ||
private Filter filter; | ||
|
||
|
||
public CloudFunctionConfiguration() throws XmlPullParserException { | ||
super(); | ||
super.name = "CloudFunctionConfiguration"; | ||
} | ||
|
||
|
||
/** | ||
* Returns id. | ||
*/ | ||
public String id() { | ||
return id; | ||
} | ||
|
||
|
||
/** | ||
* Sets id. | ||
*/ | ||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
|
||
/** | ||
* Returns cloudFunction. | ||
*/ | ||
public String cloudFunction() { | ||
return cloudFunction; | ||
} | ||
|
||
|
||
/** | ||
* Sets cloudFunction. | ||
*/ | ||
public void setCloudFunction(String cloudFunction) { | ||
this.cloudFunction = cloudFunction; | ||
} | ||
|
||
|
||
/** | ||
* Returns events. | ||
*/ | ||
public List<EventType> events() throws InvalidArgumentException { | ||
return EventType.fromStringList(events); | ||
} | ||
|
||
|
||
/** | ||
* Sets event. | ||
*/ | ||
public void setEvents(List<EventType> events) { | ||
this.events = EventType.toStringList(events); | ||
} | ||
|
||
|
||
/** | ||
* Returns filter. | ||
*/ | ||
public Filter filter() { | ||
return filter; | ||
} | ||
|
||
|
||
/** | ||
* Sets filter. | ||
*/ | ||
public void setFilter(Filter filter) { | ||
this.filter = filter; | ||
} | ||
} |
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,91 @@ | ||
/* | ||
* Minio Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2017 Minio, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.minio.messages; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import io.minio.errors.InvalidArgumentException; | ||
|
||
|
||
/** | ||
* Amazon AWS S3 event types for notifications. | ||
*/ | ||
public enum EventType { | ||
OBJECT_CREATED_ANY("s3:ObjectCreated:*"), | ||
OBJECT_CREATED_PUT("s3:ObjectCreated:Put"), | ||
OBJECT_CREATED_POST("s3:ObjectCreated:Post"), | ||
OBJECT_CREATED_COPY("s3:ObjectCreated:Copy"), | ||
OBJECT_CREATED_COMPLETE_MULTIPART_UPLOAD("s3:ObjectCreated:CompleteMultipartUpload"), | ||
OBJECT_REMOVED_ANY("s3:ObjectRemoved:*"), | ||
OBJECT_REMOVED_DELETE("s3:ObjectRemoved:Delete"), | ||
OBJECT_REMOVED_DELETED_MARKER_CREATED("s3:ObjectRemoved:DeleteMarkerCreated"), | ||
REDUCED_REDUNDANCY_LOST_OBJECT("s3:ReducedRedundancyLostObject"); | ||
|
||
private final String value; | ||
|
||
|
||
private EventType(String value) { | ||
this.value = value; | ||
} | ||
|
||
|
||
public String toString() { | ||
return this.value; | ||
} | ||
|
||
|
||
/** | ||
* Returns EventType of given string. | ||
*/ | ||
public static EventType fromString(String eventTypeString) throws InvalidArgumentException { | ||
for (EventType et : EventType.values()) { | ||
if (eventTypeString.equals(et.value)) { | ||
return et; | ||
} | ||
} | ||
|
||
|
||
throw new InvalidArgumentException("unknown event '" + eventTypeString + "'"); | ||
} | ||
|
||
|
||
/** | ||
* Returns List<EventType> of given List<String>. | ||
*/ | ||
public static List<EventType> fromStringList(List<String> eventList) throws InvalidArgumentException { | ||
List<EventType> eventTypeList = new LinkedList<EventType>(); | ||
for (String event: eventList) { | ||
eventTypeList.add(EventType.fromString(event)); | ||
} | ||
|
||
return eventTypeList; | ||
} | ||
|
||
|
||
/** | ||
* Returns List<String> of given List<EventType>. | ||
*/ | ||
public static List<String> toStringList(List<EventType> eventTypeList) { | ||
List<String> events = new LinkedList<String>(); | ||
for (EventType eventType: eventTypeList) { | ||
events.add(eventType.toString()); | ||
} | ||
|
||
return events; | ||
} | ||
} |
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,65 @@ | ||
/* | ||
* Minio Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2017 Minio, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.minio.messages; | ||
|
||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
import com.google.api.client.util.Key; | ||
|
||
import io.minio.errors.InvalidArgumentException; | ||
|
||
|
||
/** | ||
* Helper class to parse Amazon AWS S3 response XML containing Filter. | ||
*/ | ||
@SuppressWarnings("WeakerAccess") | ||
public class Filter extends XmlEntity { | ||
@Key("S3Key") | ||
private S3Key s3Key = new S3Key(); | ||
|
||
|
||
public Filter() throws XmlPullParserException { | ||
super(); | ||
super.name = "Filter"; | ||
} | ||
|
||
|
||
/** | ||
* Returns S3 Key. | ||
*/ | ||
public S3Key s3Key() { | ||
return s3Key; | ||
} | ||
|
||
|
||
/** | ||
* Sets S3 Key. | ||
*/ | ||
public void setS3Key(S3Key s3Key) { | ||
this.s3Key = s3Key; | ||
} | ||
|
||
|
||
public void setPrefixRule(String value) throws InvalidArgumentException, XmlPullParserException { | ||
s3Key.setPrefixRule(value); | ||
} | ||
|
||
|
||
public void setSuffixRule(String value) throws InvalidArgumentException, XmlPullParserException { | ||
s3Key.setSuffixRule(value); | ||
} | ||
} |
Oops, something went wrong.