-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HLRC: Deactivate Watch API #34192
Merged
not-napoleon
merged 24 commits into
elastic:master
from
not-napoleon:feature/hlrc-deactivate-watch
Oct 24, 2018
Merged
HLRC: Deactivate Watch API #34192
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
6a6df68
Lay out protocol classes
not-napoleon cb92865
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon 22ebecb
Serialization for protocol side response class
not-napoleon f52c5fa
fixed paths & packages to new standard
not-napoleon be75157
request parsing
not-napoleon 590ae61
Response parsing & basic test
not-napoleon e829881
Request validation & tests
not-napoleon 6efaed5
Top level client methods
not-napoleon 476dc7b
Fix license notices
not-napoleon b0c977a
Fixed license & import style
not-napoleon b616452
Integration tests
not-napoleon 8c3d516
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon 0214d1b
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon eb1be97
response to PR feedback
not-napoleon 3d1b605
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon 2076f94
Docs & doc tests
not-napoleon 4bc9bcb
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon 5cdb181
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon 707434a
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon e441b66
response to PR feedback
not-napoleon febaee0
Revised validation logic
not-napoleon 61a9388
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon f7b7b16
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon 345cecc
Merge branch 'master' into feature/hlrc-deactivate-watch
not-napoleon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
43 changes: 43 additions & 0 deletions
43
...est-high-level/src/main/java/org/elasticsearch/client/watcher/DeactivateWatchRequest.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,43 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.client.watcher; | ||
|
||
import org.elasticsearch.client.Validatable; | ||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest; | ||
|
||
import java.util.Objects; | ||
|
||
public class DeactivateWatchRequest implements Validatable { | ||
private final String watchId; | ||
|
||
public DeactivateWatchRequest(String watchId) { | ||
|
||
Objects.requireNonNull(watchId, "watch id is missing"); | ||
if (PutWatchRequest.isValidId(watchId) == false) { | ||
throw new IllegalArgumentException("watch id contains whitespace"); | ||
} | ||
|
||
this.watchId = watchId; | ||
} | ||
|
||
public String getWatchId() { | ||
return watchId; | ||
} | ||
} | ||
|
65 changes: 65 additions & 0 deletions
65
...st-high-level/src/main/java/org/elasticsearch/client/watcher/DeactivateWatchResponse.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,65 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.client.watcher; | ||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class DeactivateWatchResponse { | ||
private WatchStatus status; | ||
|
||
private static final ParseField STATUS_FIELD = new ParseField("status"); | ||
private static final ConstructingObjectParser<DeactivateWatchResponse, Void> PARSER | ||
= new ConstructingObjectParser<>("x_pack_deactivate_watch_response", true, | ||
(fields) -> new DeactivateWatchResponse((WatchStatus) fields[0])); | ||
static { | ||
PARSER.declareObject(ConstructingObjectParser.constructorArg(), | ||
(parser, context) -> WatchStatus.parse(parser), | ||
STATUS_FIELD); | ||
} | ||
|
||
public static DeactivateWatchResponse fromXContent(XContentParser parser) throws IOException { | ||
return PARSER.parse(parser, null); | ||
} | ||
|
||
public DeactivateWatchResponse(WatchStatus status) { | ||
this.status = status; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DeactivateWatchResponse that = (DeactivateWatchResponse) o; | ||
return Objects.equals(status, that.status); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(status); | ||
} | ||
|
||
public WatchStatus getStatus() { | ||
return status; | ||
} | ||
} |
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
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
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
41 changes: 41 additions & 0 deletions
41
...igh-level/src/test/java/org/elasticsearch/client/watcher/DeactivateWatchRequestTests.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,41 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.client.watcher; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
public class DeactivateWatchRequestTests extends ESTestCase { | ||
|
||
public void testNullId() { | ||
NullPointerException actual = expectThrows(NullPointerException.class, () -> new DeactivateWatchRequest(null)); | ||
assertNotNull(actual); | ||
assertThat(actual.getMessage(), is("watch id is missing")); | ||
} | ||
|
||
public void testInvalidId() { | ||
IllegalArgumentException actual = expectThrows(IllegalArgumentException.class, | ||
() -> new DeactivateWatchRequest("Watch id has spaces")); | ||
assertNotNull(actual); | ||
assertThat(actual.getMessage(), is("watch id contains whitespace")); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth adding a second test case for imho