-
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
Add PUT Repository High Level REST API #30501
Conversation
This commit adds PUT Repository, the associated docs and tests for the high level REST API client. A few small changes to the PutRepository Request and Response went into the commit as well. Relates elastic#27205
Pinging @elastic/es-core-infra |
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.
I like it!
* API on elastic.co</a> | ||
*/ | ||
public void putRepositoryAsync(PutRepositoryRequest putRepositoryRequest, | ||
ActionListener<PutRepositoryResponse> listener, Header... headers){ |
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.
Add a space after )
and before {
please!
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.
thanks @hub-cap I left some comments!
parameters.withMasterTimeout(putRepositoryRequest.masterNodeTimeout()); | ||
parameters.withTimeout(putRepositoryRequest.timeout()); | ||
|
||
request.setEntity(createEntity(putRepositoryRequest, REQUEST_BODY_CONTENT_TYPE)); |
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.
I see in the corresponding REST action that we also support the verify
parameter. I guess we should support it here too?
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.
yea definitely, ty for pointing it out. Cant believe i missed it!
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore | ||
* API on elastic.co</a> | ||
*/ | ||
|
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.
remove this empty line?
String repository = "repo"; | ||
PutRepositoryRequest putRepositoryRequest = new PutRepositoryRequest(repository); | ||
putRepositoryRequest.type(FsRepository.TYPE); | ||
putRepositoryRequest.settings("{\"location\": \".\"}", XContentType.JSON); |
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.
would it be possible to randomize the values that the request holds like in other tests?
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.
wrt this, should i be putting different types of plugins as well? Or just use the FS plugin? The other plugins would have to be loaded in gradle (which im sure is super easy), but I just want to make sure I have the scope here correctly. Also, putting other values for the location that are not approved by the config will result in exceptions, this is why i chose that generic thing. Just trying to test that its accepted and comes back w what i want.
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.
I assumed that there is no problem setting values and checking that the output of the conversion from high-level request to low-level request is the expected one. We don't validate etc. I would do only what is straight-forward.
@@ -49,4 +58,8 @@ public void writeTo(StreamOutput out) throws IOException { | |||
writeAcknowledged(out); | |||
} | |||
|
|||
public static PutRepositoryResponse fromXContent(XContentParser parser) { | |||
return PARSER.apply(parser, null); | |||
} |
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.
can you add a test for this class although very simple?
builder.endObject(); | ||
|
||
builder.endObject(); | ||
return builder; |
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.
can you add a unit test for this method?
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore | ||
* API on elastic.co</a> | ||
*/ | ||
public void putRepositoryAsync(PutRepositoryRequest putRepositoryRequest, |
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.
in the spec we call this "snapshot.create_repository" . Could you rename the methods to createRepository please?
@@ -1448,6 +1451,18 @@ public void testGetRepositories() { | |||
assertThat(expectedParams, equalTo(request.getParameters())); | |||
} | |||
|
|||
public void testPutRepository() throws IOException { |
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.
testCreateRepository?
private static final String testRepository = "test_repository"; | ||
private static final String repositoryName = "test_repository"; | ||
|
||
public void testSnapshotPutRepository() throws IOException { |
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.
testSnapshotCreateRepository?
assertTrue(acknowledged); | ||
} | ||
|
||
public void testSnapshotPutRepositoryAsync() throws InterruptedException { |
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.
testSnapshotCreateRepositoryAsync
@@ -0,0 +1,139 @@ | |||
[[java-rest-high-snapshot-put-repository]] | |||
=== Snapshot Put Repository API |
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.
in the docs as well, can you rename put repository to create repository. We leave requests and responses as they are as we reuse them from the transport client, but for the rest we should follow the spec naming like other language clients already do.
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.
I went ahead and changed it in all the headings and links (eg, [[java-rest-high-snapshot-create-repository]]
)
rename put to create add verify cleanup spacing
@javanna ive addressed comments, pls review. I have also added repository request/response tests so i can cover most of the new things im adding to these request/responses in this and subsequent PRs. |
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class RepositoryResponseTests extends ESTestCase { |
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.
could this extend AbstractXContentTestCase or AbstractStreamableXContentTestCase ?
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.
indeed it can, and it makes it much simple. TYVM for showing me this test class!!!
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.
thanks @hub-cap left one comment on testing, LGTM otherwise. feel free to push once addressed
I think the docs/java-rest/high-level/snapshot/create_repository.asciidoc is missing from the 6.x branch. Is that intentional? It's causing some documentation build issues. |
This commit adds Create Repository, the associated docs and tests for the high level REST API client. A few small changes to the PutRepository Request and Response went into the commit as well.
@lcawl I had not yet pushed it. I was in backport hell for a while today. I pushed it just now. |
* es/6.x: (44 commits) SQL: Remove dependency for server's version from JDBC driver (#30631) Make xpack modules instead of a meta plugin (#30589) Security: Remove SecurityLifecycleService (#30526) Build: Add task interdependencies for ssl configuration (#30633) Mute ShrinkIndexIT [ML] DeleteExpiredDataAction should use client with origin (#30646) Reindex: Fixed typo in assertion failure message (#30619) [DOCS] Fixes list of unconverted snippets in build.gradle Use readFully() to read bytes from CipherInputStream (#30640) Add Create Repository High Level REST API (#30501) [DOCS] Reorganizes RBAC documentation Test: increase search logging for LicensingTests Delay _uid field data deprecation warning (#30651) Deprecate Empty Templates (#30194) Remove unused DirectoryUtils class. (#30582) Mitigate date histogram slowdowns with non-fixed timezones. (#30534) [TEST] Remove AwaitsFix in IndicesOptionsTests#testSerialization S3 repo plugin populates SettingsFilter (#30652) Rest High Level client: Add List Tasks (#29546) Fixes IndiceOptionsTests to serialise correctly (#30644) ...
This commit adds PUT Repository, the associated docs and tests for the
high level REST API client. A few small changes to the PutRepository
Request and Response went into the commit as well.
Relates #27205