Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,4 @@ src/main/resources/
.vscode/settings.json
.vscode/
/.vscode/
.env
50 changes: 50 additions & 0 deletions src/main/java/com/contentstack/cms/stack/GlobalField.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ public GlobalField addHeader(@NotNull String key, @NotNull String value) {
return this;
}

/**
* @param key The key parameter is a string that represents the name or
* identifier of the header.
* It is used to specify the type of information being sent in the
* header.
* @return instance of the GlobalField object
*/
public GlobalField removeHeader(@NotNull String key) {
this.headers.remove(key);
return this;
}

/**
* @param params The "params" parameter is a HashMap that maps String keys to
* Object values. It is
Expand Down Expand Up @@ -155,6 +167,7 @@ protected GlobalField clearParams() {
* </a>
* @see #addHeader(String, String) to add headers
* @see #addParam(String, Object) to add query parameters
* @see #removeHeader(String) to remove header
* @since 0.1.0
*/
public Call<ResponseBody> find() {
Expand Down Expand Up @@ -184,6 +197,7 @@ public Call<ResponseBody> find() {
* </a>
* @see #addHeader(String, String) to add headers
* @see #addParam(String, Object) to add query parameters
* @see #removeHeader(String) to remove header
* @since 0.1.0
*/
public Call<ResponseBody> fetch() {
Expand Down Expand Up @@ -216,6 +230,7 @@ public Call<ResponseBody> fetch() {
*
* </a>
* @see #addHeader(String, String) to add headers
* @see #removeHeader(String) to remove header
* @since 0.1.0
*/
public Call<ResponseBody> create(@NotNull JSONObject requestBody) {
Expand Down Expand Up @@ -245,6 +260,7 @@ public Call<ResponseBody> create(@NotNull JSONObject requestBody) {
*
* </a>
* @see #addHeader(String, String) to add headers
* @see #removeHeader(String) to remove header
* @since 0.1.0
*/
public Call<ResponseBody> update(@NotNull JSONObject requestBody) {
Expand All @@ -270,6 +286,7 @@ public Call<ResponseBody> update(@NotNull JSONObject requestBody) {
* field
* </a>
* @see #addHeader(String, String) to add headers
* @see #removeHeader(String) to remove header
* @since 0.1.0
*/
public Call<ResponseBody> delete() {
Expand Down Expand Up @@ -298,6 +315,7 @@ public Call<ResponseBody> delete() {
*
* </a>
* @see #addHeader(String, String) to add headers
* @see #removeHeader(String) to remove header
* @since 0.1.0
*/
public Call<ResponseBody> imports(@NotNull JSONObject body) {
Expand All @@ -318,10 +336,42 @@ public Call<ResponseBody> imports(@NotNull JSONObject body) {
*
* </a>
* @see #addHeader(String, String) to add headers
* @see #removeHeader(String) to remove header
* @since 0.1.0
*/
public Call<ResponseBody> export() {
validate();
return this.service.export(this.headers, this.globalFiledUid);
}

/**
* <b>Restore a global field </b>
* <p>
* The <b>Restore a global field</b> request allows you to restore the schema of
* a deleted global field.
* <p>
* When executing the API call, in the <b>URI Parameters</b> section, provide
* the unique ID of your global field.
*
* <b>Note:</b> You need to use either the stack's Management Token or the user
* Authtoken (any one is mandatory), along with the stack API key, to make a
* valid Content Management API request.
* Read more about authentication.
*
* @param requestBody the request body
* @return Call
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#restore-a-global-field">Restore
* a global
* field
*
* </a>
* @see #addHeader(String, String) to add headers
* @see #removeHeader(String) to remove header
* @since 0.1.0
*/
public Call<ResponseBody> restore(@NotNull JSONObject requestBody) {
validate();
return this.service.restore(this.headers, this.globalFiledUid, requestBody);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ Call<ResponseBody> imports(
Call<ResponseBody> export(
@HeaderMap Map<String, Object> headers,
@Path("global_field_uid") String globalFieldUid);

@PUT("global_fields/{global_field_uid}/restore")
Call<ResponseBody> restore(
@HeaderMap Map<String, Object> headers,
@Path("global_field_uid") String globalFieldUid,
@Body JSONObject body);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
RoleAPITest.class,
StackAPITest.class,
TokenAPITest.class,
OrgApiTests.class
OrgApiTests.class,
GlobalFieldAPITest.class

})
public class APISanityTestSuite {
Expand Down
Loading