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 |
| * API on elastic.co</a> | ||
| */ | ||
| public void putRepositoryAsync(PutRepositoryRequest putRepositoryRequest, | ||
| ActionListener<PutRepositoryResponse> listener, Header... headers){ |
There was a problem hiding this comment.
Add a space after ) and before { please!
| parameters.withMasterTimeout(putRepositoryRequest.masterNodeTimeout()); | ||
| parameters.withTimeout(putRepositoryRequest.timeout()); | ||
|
|
||
| request.setEntity(createEntity(putRepositoryRequest, REQUEST_BODY_CONTENT_TYPE)); |
There was a problem hiding this comment.
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.
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> | ||
| */ | ||
|
|
| String repository = "repo"; | ||
| PutRepositoryRequest putRepositoryRequest = new PutRepositoryRequest(repository); | ||
| putRepositoryRequest.type(FsRepository.TYPE); | ||
| putRepositoryRequest.settings("{\"location\": \".\"}", XContentType.JSON); |
There was a problem hiding this comment.
would it be possible to randomize the values that the request holds like in other tests?
There was a problem hiding this comment.
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.
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.
|
|
||
| public static PutRepositoryResponse fromXContent(XContentParser parser) { | ||
| return PARSER.apply(parser, null); | ||
| } |
There was a problem hiding this comment.
can you add a test for this class although very simple?
| builder.endObject(); | ||
|
|
||
| builder.endObject(); | ||
| return builder; |
There was a problem hiding this comment.
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.
in the spec we call this "snapshot.create_repository" . Could you rename the methods to createRepository please?
| assertThat(expectedParams, equalTo(request.getParameters())); | ||
| } | ||
|
|
||
| public void testPutRepository() throws IOException { |
| 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.
testSnapshotCreateRepository?
| assertTrue(acknowledged); | ||
| } | ||
|
|
||
| public void testSnapshotPutRepositoryAsync() throws InterruptedException { |
There was a problem hiding this comment.
testSnapshotCreateRepositoryAsync
| @@ -0,0 +1,139 @@ | |||
| [[java-rest-high-snapshot-put-repository]] | |||
| === Snapshot Put Repository API | |||
There was a problem hiding this comment.
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.
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.
could this extend AbstractXContentTestCase or AbstractStreamableXContentTestCase ?
There was a problem hiding this comment.
indeed it can, and it makes it much simple. TYVM for showing me this test class!!!
|
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