diff --git a/java/enunciate.xml b/java/enunciate.xml index d129009b..55a08604 100644 --- a/java/enunciate.xml +++ b/java/enunciate.xml @@ -2,18 +2,18 @@ xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.27.xsd"> - + - + com.cloudera.api cloudera-manager-api Cloudera Manager API - 5.8.0 + 5.11.0 2.7.7 @@ -239,7 +239,6 @@ ${javadocOptions} true ${project.build.directory}/javadoc - ${basedir}/src/javadoc/javadoc.css ${basedir}/src/javadoc/overview.html Cloudera Manager API (${project.version}) Cloudera Manager API (${project.version}) @@ -267,6 +266,11 @@ findbugs-exclude.xml + + org.owasp + dependency-check-maven + 1.4.3 + diff --git a/java/src/javadoc/javadoc.css b/java/src/javadoc/javadoc.css deleted file mode 100644 index cdc991dd..00000000 --- a/java/src/javadoc/javadoc.css +++ /dev/null @@ -1,607 +0,0 @@ -/*********************************************************/ -/* Javadoc style sheet --- JDK8 standard */ -/* http://download.java.net/jdk8/docs/api/stylesheet.css */ -/*********************************************************/ - -/* -Overall document style -*/ -body { - background-color:#ffffff; - color:#353833; - font-family:Arial, Helvetica, sans-serif; - font-size:76%; - margin:0; -} -a:link, a:visited { - text-decoration:none; - color:#4c6b87; -} -a:hover, a:focus { - text-decoration:none; - color:#bb7a2a; -} -a:active { - text-decoration:none; - color:#4c6b87; -} -a[name] { - color:#353833; -} -a[name]:hover { - text-decoration:none; - color:#353833; -} -pre { - font-size:1.3em; -} -h1 { - font-size:1.8em; -} -h2 { - font-size:1.5em; -} -h3 { - font-size:1.4em; -} -h4 { - font-size:1.3em; -} -h5 { - font-size:1.2em; -} -h6 { - font-size:1.1em; -} -ul { - list-style-type:disc; -} -code, tt { - font-size:1.2em; -} -dt code { - font-size:1.2em; -} -table tr td dt code { - font-size:1.2em; - vertical-align:top; -} -sup { - font-size:.6em; -} -/* -Document title and Copyright styles -*/ -.clear { - clear:both; - height:0px; - overflow:hidden; -} -.aboutLanguage { - float:right; - padding:0px 21px; - font-size:.8em; - z-index:200; - margin-top:-7px; -} -.legalCopy { - margin-left:.5em; -} -.bar a, .bar a:link, .bar a:visited, .bar a:active { - color:#FFFFFF; - text-decoration:none; -} -.bar a:hover, .bar a:focus { - color:#bb7a2a; -} -.tab { - background-color:#0066FF; - background-image:url(resources/titlebar.gif); - background-position:left top; - background-repeat:no-repeat; - color:#ffffff; - padding:8px; - width:5em; - font-weight:bold; -} -/* -Navigation bar styles -*/ -.bar { - background-image:url(resources/background.gif); - background-repeat:repeat-x; - color:#FFFFFF; - padding:.8em .5em .4em .8em; - height:auto;/*height:1.8em;*/ - font-size:1em; - margin:0; -} -.topNav { - background-image:url(resources/background.gif); - background-repeat:repeat-x; - color:#FFFFFF; - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; -} -.bottomNav { - margin-top:10px; - background-image:url(resources/background.gif); - background-repeat:repeat-x; - color:#FFFFFF; - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; -} -.subNav { - background-color:#dee3e9; - border-bottom:1px solid #9eadc0; - float:left; - width:100%; - overflow:hidden; -} -.subNav div { - clear:left; - float:left; - padding:0 0 5px 6px; -} -ul.navList, ul.subNavList { - float:left; - margin:0 25px 0 0; - padding:0; -} -ul.navList li{ - list-style:none; - float:left; - padding:3px 6px; -} -ul.subNavList li{ - list-style:none; - float:left; - font-size:90%; -} -.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { - color:#FFFFFF; - text-decoration:none; -} -.topNav a:hover, .bottomNav a:hover { - text-decoration:none; - color:#bb7a2a; -} -.navBarCell1Rev { - background-image:url(resources/tab.gif); - background-color:#a88834; - color:#FFFFFF; - margin: auto 5px; - border:1px solid #c9aa44; -} -/* -Page header and footer styles -*/ -.header, .footer { - clear:both; - margin:0 20px; - padding:5px 0 0 0; -} -.indexHeader { - margin:10px; - position:relative; -} -.indexHeader span{ - margin-right:15px; -} -.indexHeader h1 { - font-size:1.3em; -} -.title { - color:#2c4557; - margin:10px 0; -} -.subTitle { - margin:5px 0 0 0; -} -.header ul { - margin:0 0 25px 0; - padding:0; -} -.footer ul { - margin:20px 0 5px 0; -} -.header ul li, .footer ul li { - list-style:none; - /*font-size:1.2em;*/ -} -/* -Heading styles -*/ -div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { - background-color:#dee3e9; - border-top:1px solid #9eadc0; - border-bottom:1px solid #9eadc0; - margin:0 0 6px -8px; - padding:2px 5px; -} -ul.blockList ul.blockList ul.blockList li.blockList h3 { - background-color:#dee3e9; - border-top:1px solid #9eadc0; - border-bottom:1px solid #9eadc0; - margin:0 0 6px -8px; - padding:2px 5px; -} -ul.blockList ul.blockList li.blockList h3 { - padding:0; - margin:15px 0; -} -ul.blockList li.blockList h2 { - padding:0px 0 20px 0; -} -/* -Page layout container styles -*/ -.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { - clear:both; - padding:10px 20px; - position:relative; -} -.indexContainer { - margin:10px; - position:relative; - font-size:1.0em; -} -.indexContainer h2 { - font-size:1.1em; - padding:0 0 3px 0; -} -.indexContainer ul { - margin:0; - padding:0; -} -.indexContainer ul li { - list-style:none; -} -.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { - font-size:1.1em; - font-weight:bold; - margin:10px 0 0 0; - color:#4E4E4E; -} -.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { - margin:10px 0 10px 20px; -} -.serializedFormContainer dl.nameValue dt { - margin-left:1px; - font-size:1.1em; - display:inline; - font-weight:bold; -} -.serializedFormContainer dl.nameValue dd { - margin:0 0 0 1px; - font-size:1.1em; - display:inline; -} -/* -List styles -*/ -ul.horizontal li { - display:inline; - font-size:0.9em; -} -ul.inheritance { - margin:0; - padding:0; -} -ul.inheritance li { - display:inline; - list-style:none; -} -ul.inheritance li ul.inheritance { - margin-left:15px; - padding-left:15px; - padding-top:1px; -} -ul.blockList, ul.blockListLast { - margin:10px 0 10px 0; - padding:0; -} -ul.blockList li.blockList, ul.blockListLast li.blockList { - list-style:none; - margin-bottom:25px; -} -ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { - padding:0px 20px 5px 10px; - border:1px solid #9eadc0; - background-color:#f9f9f9; -} -ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { - padding:0 0 5px 8px; - background-color:#ffffff; - border:1px solid #9eadc0; - border-top:none; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { - margin-left:0; - padding-left:0; - padding-bottom:15px; - border:none; - border-bottom:1px solid #9eadc0; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { - list-style:none; - border-bottom:none; - padding-bottom:0; -} -table tr td dl, table tr td dl dt, table tr td dl dd { - margin-top:0; - margin-bottom:1px; -} -/* -Table styles -*/ -.contentContainer table, .classUseContainer table, .constantValuesContainer table { - border-bottom:1px solid #9eadc0; - width:100%; -} -.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { - width:100%; -} -.contentContainer .description table, .contentContainer .details table { - border-bottom:none; -} -.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ - vertical-align:top; - padding-right:20px; -} -.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, -.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, -.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, -.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { - padding-right:3px; -} -.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { - position:relative; - text-align:left; - background-repeat:no-repeat; - color:#FFFFFF; - font-weight:bold; - clear:none; - overflow:hidden; - padding:0px; - margin:0px; -} -caption a:link, caption a:hover, caption a:active, caption a:visited { - color:#FFFFFF; -} -.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { - white-space:nowrap; - padding-top:8px; - padding-left:8px; - display:block; - float:left; - background-image:url(resources/titlebar.gif); - height:18px; -} -.contentContainer ul.blockList li.blockList caption span.activeTableTab span { - white-space:nowrap; - padding-top:8px; - padding-left:8px; - display:block; - float:left; - background-image:url(resources/activetitlebar.gif); - height:18px; -} -.contentContainer ul.blockList li.blockList caption span.tableTab span { - white-space:nowrap; - padding-top:8px; - padding-left:8px; - display:block; - float:left; - background-image:url(resources/titlebar.gif); - height:18px; -} -.contentContainer ul.blockList li.blockList caption span.tableTab, .contentContainer ul.blockList li.blockList caption span.activeTableTab { - padding-top:0px; - padding-left:0px; - background-image:none; - float:none; - display:inline; -} -.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { - width:10px; - background-image:url(resources/titlebar_end.gif); - background-repeat:no-repeat; - background-position:top right; - position:relative; - float:left; -} -.contentContainer ul.blockList li.blockList .activeTableTab .tabEnd { - width:10px; - margin-right:5px; - background-image:url(resources/activetitlebar_end.gif); - background-repeat:no-repeat; - background-position:top right; - position:relative; - float:left; -} -.contentContainer ul.blockList li.blockList .tableTab .tabEnd { - width:10px; - margin-right:5px; - background-image:url(resources/titlebar_end.gif); - background-repeat:no-repeat; - background-position:top right; - position:relative; - float:left; -} -ul.blockList ul.blockList li.blockList table { - margin:0 0 12px 0px; - width:100%; -} -.tableSubHeadingColor { - background-color: #EEEEFF; -} -.altColor { - background-color:#eeeeef; -} -.rowColor { - background-color:#ffffff; -} -.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { - text-align:left; - padding:3px 3px 3px 7px; -} -th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { - background:#dee3e9; - border-top:1px solid #9eadc0; - border-bottom:1px solid #9eadc0; - text-align:left; - padding:3px 3px 3px 7px; -} -td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { - font-weight:bold; -} -td.colFirst, th.colFirst { - border-left:1px solid #9eadc0; - white-space:nowrap; -} -td.colLast, th.colLast { - border-right:1px solid #9eadc0; -} -td.colOne, th.colOne { - border-right:1px solid #9eadc0; - border-left:1px solid #9eadc0; -} -table.overviewSummary { - padding:0px; - margin-left:0px; -} -table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, -table.overviewSummary td.colOne, table.overviewSummary th.colOne { - width:25%; - vertical-align:middle; -} -table.packageSummary td.colFirst, table.overviewSummary th.colFirst { - width:25%; - vertical-align:middle; -} -/* -Content styles -*/ -.description pre { - margin-top:0; -} -.deprecatedContent { - margin:0; - padding:10px 0; -} -.docSummary { - padding:0; -} -/* -Formatting effect styles -*/ -.sourceLineNo { - color:green; - padding:0 30px 0 0; -} -h1.hidden { - visibility:hidden; - overflow:hidden; - font-size:.9em; -} -.block { - display:block; - margin:3px 0 0 0; -} -.strong { - font-weight:bold; -} - -/************************************************/ -/* Cloudera custom */ -/************************************************/ - -body, th, td { - font-family: 'helvetica', 'arial', 'sans-serif'; - font-size: 13px; -} - -table { - border-collapse: collapse; -} -th, td { - text-align: left; - border: 1px solid #ccd; - padding: 4px 6px; - vertical-align: top; -} -th, td[bgcolor="#eeeeff"] { - background-color: #dde4ee; - color: #236; -} -th font { - font-size: 16px; -} -td { - white-space: nowrap; - background-color: #f4f6fa; -} -td + td { - white-space: normal; -} - -a[name="method_summary"] + table, a[name="method_summary"] + table tbody, -a[name="method_summary"] + table tr, a[name="method_summary"] + table th { - display: block; - border: none; -} -a[name="method_summary"] + table { - border: 1px solid #ccd; -} -a[name="method_summary"] + table th { - border-bottom: 1px solid #ccd; -} -a[name="method_summary"] + table, a[name="method_summary"] + table tr { - background: #f4f6fa; -} -a[name="method_summary"] + table td { - display: block; - padding: 0px 12px; - text-align: left; - border: none; - border-bottom: 1px solid #dde; - background: none; - padding-bottom: 10px; -} -a[name="method_summary"] + table td[align="right"] { - font-size: 6px; - color: #457; - margin-top: 6px; - position: relative; - left: -8px; - border-bottom: none; - padding-bottom: 2px; -} -a[name="method_summary"] + table td code { - font-size: 110%; -} -a[name="method_summary"] + table td code b a { - font-size: 14px; - font-family: 'helvetica', 'arial', 'sans-serif'; -} - -a { - color: #15d; -} -a:hover { - color: #18f; -} -a:active { - text-decoration: none; -} diff --git a/java/src/main/java/com/cloudera/api/ApiRootResource.java b/java/src/main/java/com/cloudera/api/ApiRootResource.java index 5d05e599..3e1f4acf 100644 --- a/java/src/main/java/com/cloudera/api/ApiRootResource.java +++ b/java/src/main/java/com/cloudera/api/ApiRootResource.java @@ -20,6 +20,9 @@ import com.cloudera.api.v11.RootResourceV11; import com.cloudera.api.v12.RootResourceV12; import com.cloudera.api.v13.RootResourceV13; +import com.cloudera.api.v14.RootResourceV14; +import com.cloudera.api.v15.RootResourceV15; +import com.cloudera.api.v16.RootResourceV16; import com.cloudera.api.v2.RootResourceV2; import com.cloudera.api.v3.RootResourceV3; import com.cloudera.api.v4.RootResourceV4; @@ -122,6 +125,29 @@ public interface ApiRootResource { @Path("/v13") RootResourceV13 getRootV13(); + /** + * @return The v14 root resource. + */ + @Path("/v14") + RootResourceV14 getRootV14(); + + /** + * @return The v15 root resource. + */ + @Path("/v15") + RootResourceV15 getRootV15(); + + /** + * @return The v15 root resource. + */ + @Path("/v16") + RootResourceV16 getRootV16(); + + /** + * Important: Update {@link ApiRootResourceExternal} interface as well + * on adding new CM API version. + */ + /** * Fetch the current API version supported by the server. *

diff --git a/java/src/main/java/com/cloudera/api/ApiRootResourceExternal.java b/java/src/main/java/com/cloudera/api/ApiRootResourceExternal.java new file mode 100644 index 00000000..cc162fac --- /dev/null +++ b/java/src/main/java/com/cloudera/api/ApiRootResourceExternal.java @@ -0,0 +1,154 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api; + + +import com.cloudera.api.v16.RootResourceV16; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +/** + * ApiRootResourceExternal interface is used specifically to generate proxies by CXF for + * direct consumers of {@link ClouderaManagerClientBuilder}. + * + * It must be kept in-sync with {@link ApiRootResource}. + * + * In order to reduce memory usage while generating proxies, single RootResource version + * is returned. + * + * On adding a new API version: + * - add corresponding getRootV() method with newer version of RootResource as data type + * of return parameter + * - update return data type of all existing getRootV() methods as well + */ +@Path("/") +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +interface ApiRootResourceExternal { + + /** + * @return The v1 root resource. + */ + @Path("/v1") + RootResourceV16 getRootV1(); + + /** + * @return The v2 root resource. + */ + @Path("/v2") + RootResourceV16 getRootV2(); + + /** + * @return The v3 root resource. + */ + @Path("/v3") + RootResourceV16 getRootV3(); + + /** + * @return The v4 root resource. + */ + @Path("/v4") + RootResourceV16 getRootV4(); + + /** + * @return The v5 root resource. + */ + @Path("/v5") + RootResourceV16 getRootV5(); + + /** + * @return The v6 root resource. + */ + @Path("/v6") + RootResourceV16 getRootV6(); + + /** + * @return The v7 root resource. + */ + @Path("/v7") + RootResourceV16 getRootV7(); + + /** + * @return The v8 root resource. + */ + @Path("/v8") + RootResourceV16 getRootV8(); + + /** + * @return The v9 root resource. + */ + @Path("/v9") + RootResourceV16 getRootV9(); + + /** + * @return The v10 root resource. + */ + @Path("/v10") + RootResourceV16 getRootV10(); + + /** + * @return The v11 root resource. + */ + @Path("/v11") + RootResourceV16 getRootV11(); + + /** + * @return The v12 root resource. + */ + @Path("/v12") + RootResourceV16 getRootV12(); + + /** + * @return The v13 root resource. + */ + @Path("/v13") + RootResourceV16 getRootV13(); + + /** + * @return The v14 root resource. + */ + @Path("/v14") + RootResourceV16 getRootV14(); + + /** + * @return The v15 root resource. + */ + @Path("/v15") + RootResourceV16 getRootV15(); + + /** + * @return The v15 root resource. + */ + @Path("/v16") + RootResourceV16 getRootV16(); + + /** + * Fetch the current API version supported by the server. + *

+ * Available since API v2. + * + * @return The current API version (e.g., "v2"). + */ + @GET + @Path("/version") + @Consumes() + @Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN }) + String getCurrentVersion(); +} diff --git a/java/src/main/java/com/cloudera/api/ApiRootResourceInvocationHandler.java b/java/src/main/java/com/cloudera/api/ApiRootResourceInvocationHandler.java new file mode 100644 index 00000000..1eb7c62c --- /dev/null +++ b/java/src/main/java/com/cloudera/api/ApiRootResourceInvocationHandler.java @@ -0,0 +1,47 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + +/** + * ApiRootResourceInvocationHandler allows delegation of + * call on API proxy from {@link ApiRootResource} interface to {@link ApiRootResourceExternal}. + * + * Generating stubs using {@link ApiRootResourceExternal} is more memory efficient and hence + * the need for delegation which allows us to redirect call without requiring + * changes for consumers of {@link ClouderaManagerClientBuilder}. + */ +class ApiRootResourceInvocationHandler implements InvocationHandler { + final private ApiRootResourceExternal delegateRootResource; + + ApiRootResourceInvocationHandler(ApiRootResourceExternal rootResource) { + delegateRootResource = rootResource; + } + + ApiRootResourceExternal getDelegateRootResource() { + return delegateRootResource; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + Method delegateMethod = ApiRootResourceExternal.class.getMethod(method.getName(), + method.getParameterTypes()); + return delegateMethod.invoke(delegateRootResource, args); + } +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/ClouderaManagerClientBuilder.java b/java/src/main/java/com/cloudera/api/ClouderaManagerClientBuilder.java index f071bc4b..60fec7b4 100644 --- a/java/src/main/java/com/cloudera/api/ClouderaManagerClientBuilder.java +++ b/java/src/main/java/com/cloudera/api/ClouderaManagerClientBuilder.java @@ -22,6 +22,7 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import java.lang.reflect.Proxy; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -242,7 +243,15 @@ public void setTrustManagers(TrustManager[] managers) { * @return an ApiRootResource proxy object */ public ApiRootResource build() { - return build(ApiRootResource.class); + // Generating stubs on ApiRootResource consumes more memory. + // Hence we generate stubs using ApiRootResourceExternal and then use dynamic proxy mechanism + // to delegate call on ApiRootResource to ApiRootResourceExternal generated stub. + ApiRootResourceExternal apiRootResourceExternal = build(ApiRootResourceExternal.class); + + return (ApiRootResource) Proxy.newProxyInstance( + ClouderaManagerClientBuilder.class.getClassLoader(), + new Class[]{ApiRootResource.class}, + new ApiRootResourceInvocationHandler(apiRootResourceExternal)); } /** @@ -322,7 +331,7 @@ private static JAXRSClientFactoryBean cleanFactory(JAXRSClientFactoryBean bean) * @param root The resource returned by the build() method of this * builder class */ - public static void closeClient(ApiRootResource root) { + public static void closeClient(Object root) { Client client = WebClient.client(root); if (client != null) { client.close(); diff --git a/java/src/main/java/com/cloudera/api/Parameters.java b/java/src/main/java/com/cloudera/api/Parameters.java index 9e8ed805..7bf5913d 100644 --- a/java/src/main/java/com/cloudera/api/Parameters.java +++ b/java/src/main/java/com/cloudera/api/Parameters.java @@ -46,6 +46,11 @@ public final class Parameters { static public final String MUST_USE_DESIRED_ROLLUP = "mustUseDesiredRollup"; static public final String FILTER = "filter"; static public final String COMMAND_NAME = "commandName"; + static public final String DIR_PATH = "directoryPath"; + static public final String EXTERNAL_ACCOUNT_NAME = "name"; + static public final String EXTERNAL_ACCOUNT_TYPE_NAME = "typeName"; + static public final String EXTERNAL_ACCOUNT_CATEGORY_NAME = "categoryName"; + static public final String DISPLAY_NAME = "displayName"; /* Common query params. */ static public final String FROM = "from"; diff --git a/java/src/main/java/com/cloudera/api/model/ApiCluster.java b/java/src/main/java/com/cloudera/api/model/ApiCluster.java index f7f16397..01da3419 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiCluster.java +++ b/java/src/main/java/com/cloudera/api/model/ApiCluster.java @@ -34,11 +34,12 @@ @XmlRootElement(name = "cluster") @XmlType(propOrder = {"name", "displayName", "version", "fullVersion", "maintenanceMode", "maintenanceOwners", "services", "parcels", "clusterUrl", - "hostsUrl", "entityStatus"}) + "hostsUrl", "entityStatus", "uuid"}) public class ApiCluster { private String name; private String displayName; + private String uuid; private String clusterUrl; private String hostsUrl; private ApiClusterVersion version; @@ -104,6 +105,20 @@ public void setDisplayName(String displayName) { this.displayName = displayName; } + /** + * Readonly. The UUID of the cluster. + *

+ * Available since API v15. + */ + @XmlElement + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + /** * Readonly. Link into the Cloudera Manager web UI for this specific cluster. *

diff --git a/java/src/main/java/com/cloudera/api/model/ApiCollectDiagnosticDataArguments.java b/java/src/main/java/com/cloudera/api/model/ApiCollectDiagnosticDataArguments.java index 5d76c55c..62dd262f 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiCollectDiagnosticDataArguments.java +++ b/java/src/main/java/com/cloudera/api/model/ApiCollectDiagnosticDataArguments.java @@ -34,7 +34,7 @@ public class ApiCollectDiagnosticDataArguments { private String ticketNumber; private String comments; private String clusterName; - private boolean enableMonitorMetricsCollection; + private Boolean enableMonitorMetricsCollection; private List roles; /** @@ -128,11 +128,12 @@ public void setClusterName(String clusterName) { /** * Flag to enable collection of metrics for chart display. */ - public boolean getEnableMonitorMetricsCollection() { + @XmlElement + public Boolean getEnableMonitorMetricsCollection() { return enableMonitorMetricsCollection; } - public void setEnableMonitorMetricsCollection(boolean enable) { + public void setEnableMonitorMetricsCollection(Boolean enable) { this.enableMonitorMetricsCollection = enable; } diff --git a/java/src/main/java/com/cloudera/api/model/ApiCommand.java b/java/src/main/java/com/cloudera/api/model/ApiCommand.java index f31c6fa8..38c86c0c 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiCommand.java +++ b/java/src/main/java/com/cloudera/api/model/ApiCommand.java @@ -16,8 +16,10 @@ package com.cloudera.api.model; import com.cloudera.api.ApiUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.common.base.Objects; +import java.util.Arrays; import java.util.Date; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -260,12 +262,23 @@ public void setChildren(ApiCommandList children) { /** * Available since V11 + * + * @deprecated Use {@link ApiCommand#getCanRetry()} instead */ - @XmlElement + @Deprecated + @JsonIgnore public Boolean isCanRetry() { return this.canRetry; } + /** + * If the command can be retried. Available since V11 + */ + @XmlElement + public Boolean getCanRetry() { + return this.canRetry; + } + public void setCanRetry(Boolean canRetry) { this.canRetry = canRetry; } @@ -287,7 +300,7 @@ public boolean equals(Object o) { Objects.equal(hostRef, that.getHostRef()) && Objects.equal(clusterRef, that.getClusterRef()) && Objects.equal(parent, that.getParent()) && - Objects.equal(canRetry, that.isCanRetry())); + Objects.equal(canRetry, that.getCanRetry())); } @Override diff --git a/java/src/main/java/com/cloudera/api/model/ApiConfig.java b/java/src/main/java/com/cloudera/api/model/ApiConfig.java index ca4931d3..db2bc478 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiConfig.java +++ b/java/src/main/java/com/cloudera/api/model/ApiConfig.java @@ -40,6 +40,7 @@ "displayName", "description", "relatedName", + "sensitive", "validationState", "validationMessage", "validationWarningsSuppressed" }) @@ -55,6 +56,7 @@ public class ApiConfig { private ValidationState validationState; private String validationMessage; private Boolean validationWarningsSuppressed; + private Boolean sensitive; public static enum ValidationState { OK, @@ -92,7 +94,7 @@ public ApiConfig( this.relatedName = relatedName; this.validationState = validationState; this.validationMessage = validationMessage; - this.validationWarningsSuppressed = null; + this.sensitive = null; // unset prior to v14 } public ApiConfig(String name, String value) { @@ -110,6 +112,7 @@ public ApiConfig() { this.validationState = null; this.validationMessage = null; this.validationWarningsSuppressed = null; + this.sensitive = null; } public String toString() { @@ -204,7 +207,7 @@ public void setName(String name) { /** * The user-defined value. When absent, the default value (if any) - * will be used. + * will be used. Can also be absent, when enumerating allowed configs. */ @XmlElement public String getValue() { @@ -272,4 +275,20 @@ public void setValidationWarningsSuppressed( Boolean validationWarningsSuppressed) { this.validationWarningsSuppressed = validationWarningsSuppressed; } + + /** + * Readonly. + * Whether this configuration is sensitive, i.e. contains information such as passwords, which + * might affect how the value of this configuration might be shared by the caller. + * + * Available since v14. + */ + @XmlElement + public Boolean getSensitive() { + return sensitive; + } + + public void setSensitive(Boolean sensitive) { + this.sensitive = sensitive; + } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiDisableSentryHaArgs.java b/java/src/main/java/com/cloudera/api/model/ApiDisableSentryHaArgs.java new file mode 100644 index 00000000..6e5699b2 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiDisableSentryHaArgs.java @@ -0,0 +1,60 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Arguments used for disable Sentry HA API call. + */ +@XmlRootElement(name = "disableSentryHaArgs") +public class ApiDisableSentryHaArgs { + private String activeName; + + /** Name of the single role that will remain active after HA is disabled. */ + @XmlElement + public String getActiveName() { + return activeName; + } + + public void setActiveName(String activeName) { + this.activeName = activeName; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("activeName", activeName) + .toString(); + } + + @Override + public boolean equals(Object o) { + ApiDisableSentryHaArgs that = ApiUtils.baseEquals(this, o); + return this == that || (that != null && + Objects.equal(activeName, that.getActiveName())); + } + + @Override + public int hashCode() { + return Objects.hashCode(activeName); + } + +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiEnableSentryHaArgs.java b/java/src/main/java/com/cloudera/api/model/ApiEnableSentryHaArgs.java new file mode 100644 index 00000000..8c6ff3b7 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiEnableSentryHaArgs.java @@ -0,0 +1,107 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Arguments used for enable Sentry HA command. + */ +@XmlRootElement(name = "enableSentryHaArgs") +public class ApiEnableSentryHaArgs { + private String newSentryHostId; + private String newSentryRoleName; + private String zkServiceName; + private ApiSimpleRollingRestartClusterArgs rrcArgs; + + /** + * Id of host on which new Sentry Server role will be added. + */ + @XmlElement + public String getNewSentryHostId() { + return newSentryHostId; + } + + public void setNewSentryHostId(String newSentryHostId) { + this.newSentryHostId = newSentryHostId; + } + + /** + * Name of the new Sentry Server role to be created. This is an + * optional argument. + */ + @XmlElement + public String getNewSentryRoleName() { + return newSentryRoleName; + } + + public void setNewSentryRoleName(String newSentryRoleName) { + this.newSentryRoleName = newSentryRoleName; + } + + /** + * Name of the ZooKeeper service that will be used for Sentry HA. + * This is an optional parameter if the Sentry to ZooKeeper dependency is + * already set in CM. + */ + @XmlElement + public String getZkServiceName() { + return zkServiceName; + } + + public void setZkServiceName(String zkServiceName) { + this.zkServiceName = zkServiceName; + } + + public ApiSimpleRollingRestartClusterArgs getRrcArgs() { + return rrcArgs; + } + + public void setRrcArgs( + ApiSimpleRollingRestartClusterArgs rrcArgs) { + this.rrcArgs = rrcArgs; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("newSentryHostId", newSentryHostId) + .add("newSentryRoleName", newSentryRoleName) + .add("zkServiceName", zkServiceName) + .add("rrcArgs", rrcArgs) + .toString(); + } + + @Override + public boolean equals(Object o) { + ApiEnableSentryHaArgs that = ApiUtils.baseEquals(this, o); + return this == that || (that != null && + Objects.equal(newSentryHostId, that.getNewSentryHostId()) && + Objects.equal(newSentryRoleName, that.getNewSentryRoleName()) && + Objects.equal(zkServiceName, that.getZkServiceName()) && + Objects.equal(rrcArgs, that.getRrcArgs())); + } + + @Override + public int hashCode() { + return Objects.hashCode(newSentryHostId, newSentryRoleName, + zkServiceName, rrcArgs); + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiExternalAccount.java b/java/src/main/java/com/cloudera/api/model/ApiExternalAccount.java new file mode 100644 index 00000000..9f7e91ef --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiExternalAccount.java @@ -0,0 +1,149 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import com.google.common.base.Objects; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents an instantiation of an external account type, referencing a supported + * external account type, via the typeName field, along with suitable configuration to + * access an external resource of the provided type. + * + * The typeName field must match the name of an external account type. + */ +@XmlRootElement(name="externalAccount") +public class ApiExternalAccount { + private String name; + private String displayName; + private Date createdTime; + private Date lastModifiedTime; + private String typeName; + private ApiConfigList accountConfigs; + + public ApiExternalAccount() { + // For JAX-B + } + + /** + * Represents the intial name of the account; used to uniquely identify this account. + */ + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Represents a modifiable label to identify this account for user-visible purposes. + */ + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * Represents the time of creation for this account. + */ + public Date getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Date createTime) { + this.createdTime = createTime; + } + + /** + * Represents the last modification time for this account. + */ + public Date getLastModifiedTime() { + return lastModifiedTime; + } + + public void setLastModifiedTime(Date lastModifiedTime) { + this.lastModifiedTime = lastModifiedTime; + } + + /** + * Represents the Type ID of a supported external account type. + * The type represented by this field dictates which configuration options must be defined + * for this account. + */ + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + /** + * Represents the account configuration for this account. + * + * When an account is retrieved from the server, + * the configs returned must match allowed configuration for the type of this account. + * + * When specified for creation of a new account or for the update of an existing account, + * this field must include every required configuration parameter specified in the type's definition, + * with the account configuration's value field specified to represent the specific + * configuration desired for this account. + */ + public ApiConfigList getAccountConfigs() { + return accountConfigs; + } + + public void setAccountConfigs(ApiConfigList accountConfigs) { + this.accountConfigs = accountConfigs; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ApiExternalAccount that = (ApiExternalAccount) o; + return Objects.equal(name, that.name) && + Objects.equal(displayName, that.displayName) && + Objects.equal(createdTime, that.createdTime) && + Objects.equal(lastModifiedTime, that.lastModifiedTime) && + Objects.equal(typeName, that.typeName) && + Objects.equal(accountConfigs, that.accountConfigs); + } + + @Override + public int hashCode() { + return Objects.hashCode(name, displayName, createdTime, lastModifiedTime, typeName, accountConfigs); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("name", name) + .add("typeName", typeName) + .add("createdTime", createdTime) + .add("lastModifiedTime", lastModifiedTime) + .add("displayName", displayName) + .add("accountConfigs", accountConfigs) + .toString(); + } +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiExternalAccountCategory.java b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountCategory.java new file mode 100644 index 00000000..6cfbbc8c --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountCategory.java @@ -0,0 +1,58 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +/** + * Type representing an external account category. + */ +public class ApiExternalAccountCategory { + private String name; + private String displayName; + private String description; + + /** + * Represents an identifier for a category. + */ + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Represents a localized display name for a category. + */ + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * Represents a localized description for a category. + */ + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiExternalAccountCategoryList.java b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountCategoryList.java new file mode 100644 index 00000000..5e5a4df4 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountCategoryList.java @@ -0,0 +1,46 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents a list of external account categories. + */ +@XmlRootElement(name="externalAccountCategories") +public class ApiExternalAccountCategoryList extends ApiListBase { + + public ApiExternalAccountCategoryList() { + // For JAX-B + super(); + } + + public ApiExternalAccountCategoryList(List values) { + super(values); + } + + @XmlElementWrapper(name = ApiListBase.ITEMS_ATTR) + public List getExternalAccountCategories() { + return values; + } + + public void setExternalAccountCategories(List values) { + this.values = values; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiExternalAccountList.java b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountList.java new file mode 100644 index 00000000..d1e6c85d --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountList.java @@ -0,0 +1,45 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents a list of external accounts. + */ +@XmlRootElement(name="externalAccounts") +public class ApiExternalAccountList extends ApiListBase { + + public ApiExternalAccountList() { + super(); + } + + public ApiExternalAccountList(List values) { + super(values); + } + + @XmlElementWrapper(name = ApiListBase.ITEMS_ATTR) + public List getExternalAccounts() { + return values; + } + + public void setExternalAccountList(List values) { + this.values = values; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiExternalAccountType.java b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountType.java new file mode 100644 index 00000000..5dfe6d37 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountType.java @@ -0,0 +1,109 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * A supported external account type. + * An external account type represents an external authentication source that is used by + * Cloudera Manager in its APIs to take suitable actions that require authentication to an + * external service. + * + * An external account type is uniquely identified by a server-generated ID and identifies with + * a category identifier: e.g. The "AWS" category has an account type "AWS_Access_Key_Authorization" + * + */ +@XmlRootElement(name = "externalAccountType") +public class ApiExternalAccountType { + + private String name; + private String categoryName; + private String type; + private String displayName; + private String description; + private ApiConfigList allowedAccountConfigs; + + public ApiExternalAccountType() { + // For JAX-B + } + + /** + * Represents the immutable name for this account. + */ + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Represents the category of this account. + */ + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + /** + * Represents the type for this account. + */ + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * Represents the localized display name for this account. + */ + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * Represents the localized description for this account type. + */ + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + /** + * Represents the list of allowed account configs. + */ + public ApiConfigList getAllowedAccountConfigs() { + return allowedAccountConfigs; + } + + public void setAllowedAccountConfigs(ApiConfigList allowedAccountConfigs) { + this.allowedAccountConfigs = allowedAccountConfigs; + } +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiExternalAccountTypeList.java b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountTypeList.java new file mode 100644 index 00000000..77cf69f2 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiExternalAccountTypeList.java @@ -0,0 +1,48 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +// Types of external accounts supported - the list is dynamic, and can change/extend with +// CM versions without breaking API (though not behavior) backwards compatibility. + +/** + * Represents a list of external account types. + */ +@XmlRootElement(name = "externalAccountTypes") +public class ApiExternalAccountTypeList extends ApiListBase { + + public ApiExternalAccountTypeList() { + super(); + } + + public ApiExternalAccountTypeList(List values) { + super(values); + } + + @XmlElementWrapper(name = ApiListBase.ITEMS_ATTR) + public List getExternalAccountTypes() { + return values; + } + + public void setExternalAccountTypes(List values) { + this.values = values; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiHdfsCloudReplicationArguments.java b/java/src/main/java/com/cloudera/api/model/ApiHdfsCloudReplicationArguments.java new file mode 100644 index 00000000..75169898 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiHdfsCloudReplicationArguments.java @@ -0,0 +1,89 @@ +// Copyright (c) 2016 Cloudera, Inc. All rights reserved. +package com.cloudera.api.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; +import com.google.common.base.Preconditions; +import org.apache.cxf.common.util.StringUtils; + +@XmlRootElement(name = "hdfsCloudReplicationArguments") +public class ApiHdfsCloudReplicationArguments extends ApiHdfsReplicationArguments { + + /** + * Source Account during replication. If this is non-null, + * destinationAccount should be null + */ + private String sourceAccount; + + /** + * destination Account during replication. If this is non-null, + * sourceAccount should be null + */ + private String destinationAccount; + + // For JAX-B + public ApiHdfsCloudReplicationArguments() { + } + + public ApiHdfsCloudReplicationArguments(ApiServiceRef sourceService, + String sourcePath, String destinationPath, + String mapreduceServiceName, Integer numMaps, String userName, + String sourceAccount, String destinationAccount) { + super(sourceService, sourcePath, destinationPath, mapreduceServiceName, + numMaps, userName); + this.sourceAccount = sourceAccount; + this.destinationAccount = destinationAccount; + } + + @XmlElement + public String getSourceAccount() { + return sourceAccount; + } + + public void setSourceAccount(String sourceAccount) { + this.sourceAccount = sourceAccount; + } + + @XmlElement + public String getDestinationAccount() { + return destinationAccount; + } + + public void setDestinationAccount(String destinationAccount) { + this.destinationAccount = destinationAccount; + } + + @Override + public String toString() { + if (!StringUtils.isEmpty(sourceAccount)) { + return super.toStringHelper() + .add("sourceAccount", sourceAccount) + .toString(); + } else if (!StringUtils.isEmpty(destinationAccount)) { + return super.toStringHelper() + .add("destinationAccount", destinationAccount) + .toString(); + } + + Preconditions.checkState(false, "Both sourceAccount and destinationAccount are null " + + "in ApiHdfsCloudReplicationArguments"); + return null; + } + + @Override + public boolean equals(Object o) { + ApiHdfsCloudReplicationArguments other = ApiUtils.baseEquals(this, o); + return this == other || (other != null && + super.equals(other) && + Objects.equal(sourceAccount, other.sourceAccount) && + Objects.equal(destinationAccount, other.destinationAccount)); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), sourceAccount, destinationAccount); + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationArguments.java b/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationArguments.java index 5892abb4..ef6ed100 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationArguments.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHdfsReplicationArguments.java @@ -322,29 +322,32 @@ public void setExclusionFilters(List exclusionFilters) { this.exclusionFilters = exclusionFilters; } + protected Objects.ToStringHelper toStringHelper() { + return Objects.toStringHelper(this) + .add("sourceService", sourceService) + .add("sourcePath", sourcePath) + .add("destinationPath", destinationPath) + .add("mapreduceServiceName", mapreduceServiceName) + .add("schedulerPoolName", schedulerPoolName) + .add("numMaps", numMaps) + .add("dryRun", dryRun) + .add("bandwidthPerMap", bandwidthPerMap) + .add("abortOnError", abortOnError) + .add ("removeMissingFiles", removeMissingFiles) + .add("preserveReplicationCount", preserveReplicationCount) + .add("preserveBlockSize", preserveBlockSize) + .add("preservePermissions", preservePermissions) + .add("logPath", logPath) + .add("skipChecksumChecks", skipChecksumChecks) + .add("skipTrash", skipTrash) + .add("replicationStrategy", replicationStrategy) + .add("preserveXAttrs", preserveXAttrs) + .add("exclusionFilters", exclusionFilters); + } + @Override public String toString() { - return Objects.toStringHelper(this) - .add("sourceService", sourceService) - .add("sourcePath", sourcePath) - .add("destinationPath", destinationPath) - .add("mapreduceServiceName", mapreduceServiceName) - .add("schedulerPoolName", schedulerPoolName) - .add("numMaps", numMaps) - .add("dryRun", dryRun) - .add("bandwidthPerMap", bandwidthPerMap) - .add("abortOnError", abortOnError) - .add ("removeMissingFiles", removeMissingFiles) - .add("preserveReplicationCount", preserveReplicationCount) - .add("preserveBlockSize", preserveBlockSize) - .add("preservePermissions", preservePermissions) - .add("logPath", logPath) - .add("skipChecksumChecks", skipChecksumChecks) - .add("skipTrash", skipTrash) - .add("replicationStrategy", replicationStrategy) - .add("preserveXAttrs", preserveXAttrs) - .add("exclusionFilters", exclusionFilters) - .toString(); + return toStringHelper().toString(); } @Override diff --git a/java/src/main/java/com/cloudera/api/model/ApiHiveCloudReplicationArguments.java b/java/src/main/java/com/cloudera/api/model/ApiHiveCloudReplicationArguments.java new file mode 100644 index 00000000..8e714fd6 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiHiveCloudReplicationArguments.java @@ -0,0 +1,137 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; +import com.google.common.base.Preconditions; +import org.apache.cxf.common.util.StringUtils; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "hiveCloudReplicationArguments") +public class ApiHiveCloudReplicationArguments extends ApiHiveReplicationArguments { + + /** + * Source Account during replication. If this is non-null, + * destinationAccount should be null + */ + private String sourceAccount; + + /** + * destination Account during replication. If this is non-null, + * sourceAccount should be null + */ + private String destinationAccount; + + /** + * path at which data will be restored or backed up. + */ + private String cloudRootPath; + + /** + * This will decide how cloud replication will take place + */ + public enum ReplicationOption { + // This is used for backup as well as restore operation, + // Use this, when you want to store/get only metadata to/from cloud + METADATA_ONLY, + + // This is used for backup as well as restore operation, + // Use this, when you want to store/get complete metadata/data to/from cloud + METADATA_AND_DATA, + + // This is used for restore operation only, + // Use this, when you want to get metadata and hive entities are pointing to + // data on cloud. + KEEP_DATA_IN_CLOUD + } + + /** + * Decides the type of hive cloud replication. + */ + private ReplicationOption replicationOption; + + public ApiHiveCloudReplicationArguments() { + // For JAX-B + } + + @XmlElement + public String getSourceAccount() { + return sourceAccount; + } + + public void setSourceAccount(String sourceAccount) { + this.sourceAccount = sourceAccount; + } + + @XmlElement + public String getDestinationAccount() { + return destinationAccount; + } + + public void setDestinationAccount(String destinationAccount) { + this.destinationAccount = destinationAccount; + } + + public String getCloudRootPath() { + return cloudRootPath; + } + + public void setCloudRootPath(String cloudRootPath) { + this.cloudRootPath = cloudRootPath; + } + + public ReplicationOption getReplicationOption() { + return replicationOption; + } + + public void setReplicationOption(ReplicationOption replicationOption) { + this.replicationOption = replicationOption; + } + + @Override + public String toString() { + Objects.ToStringHelper stringHelper = super.toStringHelper(); + if (!StringUtils.isEmpty(sourceAccount)) { + stringHelper.add("sourceAccount", sourceAccount); + } else if (!StringUtils.isEmpty(destinationAccount)) { + stringHelper.add("destinationAccount", destinationAccount); + } + + stringHelper.add("cloudRootPath", cloudRootPath); + stringHelper.add("replicationOption", replicationOption); + return stringHelper.toString(); + } + + @Override + public boolean equals(Object o) { + ApiHiveCloudReplicationArguments other = ApiUtils.baseEquals(this, o); + return this == other || (other != null && + super.equals(other) && + Objects.equal(sourceAccount, other.sourceAccount) && + Objects.equal(destinationAccount, other.destinationAccount) && + Objects.equal(cloudRootPath, other.cloudRootPath) && + Objects.equal(replicationOption, other.replicationOption)); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), sourceAccount, destinationAccount, + cloudRootPath, replicationOption); + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationArguments.java b/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationArguments.java index a0fe898b..8d52275d 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationArguments.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationArguments.java @@ -155,8 +155,7 @@ public void setDryRun(boolean dryRun) { this.dryRun = dryRun; } - @Override - public String toString() { + protected Objects.ToStringHelper toStringHelper() { return Objects.toStringHelper(this) .add("sourceService", sourceService) .add("tableFilters", tableFilters) @@ -165,8 +164,12 @@ public String toString() { .add("replicateHdfs", replicateData) .add("hdfsArguments", hdfsArguments) .add("replicateImpalaMetadata", replicateImpalaMetadata) - .add("dryRun", dryRun) - .toString(); + .add("dryRun", dryRun); + } + + @Override + public String toString() { + return toStringHelper().toString(); } @Override diff --git a/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationError.java b/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationError.java index 812534df..8b43025d 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationError.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationError.java @@ -30,6 +30,7 @@ public class ApiHiveReplicationError { private String database; private String tableName; private String impalaUDF; + private String hiveUDF; private String error; public ApiHiveReplicationError() { @@ -49,6 +50,16 @@ public ApiHiveReplicationError(String database, String tableName, this.error = error; } + public ApiHiveReplicationError(String database, String tableName, + String impalaUDF, String hiveUDF, + String error) { + this.database = database; + this.tableName = tableName; + this.impalaUDF = impalaUDF; + this.hiveUDF = hiveUDF; + this.error = error; + } + /** Name of the database. */ @XmlElement public String getDatabase() { @@ -79,6 +90,16 @@ public void setImpalaUDF(String impalaUDF) { this.impalaUDF = impalaUDF; } + /** Hive UDF signature, includes the UDF name and parameter types. */ + @XmlElement + public String getHiveUDF() { + return hiveUDF; + } + + public void setHiveUDF(String hiveUDF) { + this.hiveUDF = hiveUDF; + } + /** Description of the error. */ @XmlElement public String getError() { @@ -95,6 +116,7 @@ public String toString() { .add("database", database) .add("tableName", tableName) .add("impalaUDF", impalaUDF) + .add("hiveUDF", hiveUDF) .add("error", error) .toString(); } @@ -106,12 +128,13 @@ public boolean equals(Object o) { Objects.equal(database, that.getDatabase()) && Objects.equal(tableName, that.getTableName()) && Objects.equal(impalaUDF, that.getImpalaUDF()) && + Objects.equal(hiveUDF, that.getHiveUDF()) && Objects.equal(error, that.getError())); } @Override public int hashCode() { - return Objects.hashCode(database, tableName, impalaUDF, error); + return Objects.hashCode(database, tableName, impalaUDF, hiveUDF, error); } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationResult.java b/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationResult.java index 49ef2872..c8e338cf 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationResult.java +++ b/java/src/main/java/com/cloudera/api/model/ApiHiveReplicationResult.java @@ -34,6 +34,8 @@ public class ApiHiveReplicationResult { private List tables; private Integer impalaUDFCount; private List impalaUDFs; + private Integer hiveUDFCount; + private List hiveUDFs; private Integer errorCount; private List errors; private ApiHdfsReplicationResult dataReplicationResult; @@ -105,6 +107,19 @@ public void setImpalaUDFCount(Integer impalaUDFCount) { this.impalaUDFCount = impalaUDFCount; } + /** + * Number of hive UDFs that were successfully replicated. Available since + * API v14. + */ + @XmlElement + public Integer getHiveUDFCount() { + return hiveUDFCount; + } + + public void setHiveUDFCount(Integer hiveUDFCount) { + this.hiveUDFCount = hiveUDFCount; + } + /** * The list of Impala UDFs successfully replicated. Available since API v6 * in the full view. @@ -118,6 +133,20 @@ public void setImpalaUDFs(List impalaUDFs) { this.impalaUDFs = impalaUDFs; } + + /** + * The list of Impala UDFs successfully replicated. Available since API v6 + * in the full view. + */ + @XmlElementWrapper + public List getHiveUDFs() { + return hiveUDFs; + } + + public void setHiveUDFs(List hiveUDFs) { + this.hiveUDFs = hiveUDFs; + } + /** * Number of errors detected during replication job. * Available since API v4. @@ -185,6 +214,7 @@ public boolean equals(Object o) { Objects.equal(phase, that.getPhase()) && Objects.equal(tables, that.getTables()) && Objects.equal(impalaUDFs, that.getImpalaUDFs()) && + Objects.equal(hiveUDFs, that.getHiveUDFs()) && Objects.equal(errors, that.getErrors()) && dryRun == that.isDryRun() && Objects.equal(runAsUser, that.getRunAsUser())); @@ -192,7 +222,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(phase, tables, impalaUDFs, errors, dryRun, + return Objects.hashCode(phase, tables, impalaUDFs, hiveUDFs, errors, dryRun, runAsUser); } @@ -202,6 +232,7 @@ public String toString() { .add("phase", phase) .add("tables", tables) .add("impalaUDFs", impalaUDFs) + .add("hiveUDFs", hiveUDFs) .add("errors", errors) .add("dryRun", dryRun) .add("runAsUser", runAsUser) diff --git a/java/src/main/java/com/cloudera/api/model/ApiHiveUDF.java b/java/src/main/java/com/cloudera/api/model/ApiHiveUDF.java new file mode 100644 index 00000000..58c0991d --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiHiveUDF.java @@ -0,0 +1,69 @@ +// Copyright (c) 2016 Cloudera, Inc. All rights reserved. +package com.cloudera.api.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +/** + * An hive UDF identifier. + */ +@XmlRootElement(name = "hiveUDF") +public class ApiHiveUDF { + + private String database; + private String signature; + + public ApiHiveUDF() { + // For JAX-B + } + + public ApiHiveUDF(String database, String signature) { + this.database = database; + this.signature = signature; + } + + /** Name of the database to which this UDF belongs. */ + @XmlElement + public String getDatabase() { + return database; + } + + public void setDatabase(String database) { + this.database = database; + } + + /** UDF signature, includes the UDF name and parameter types. */ + @XmlElement + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("database", database) + .add("signature", signature) + .toString(); + } + + @Override + public boolean equals(Object o) { + ApiHiveUDF that = ApiUtils.baseEquals(this, o); + return (this == that) || (that != null && + Objects.equal(database, that.getDatabase()) && + Objects.equal(signature, that.getSignature())); + } + + @Override + public int hashCode() { + return Objects.hashCode(database, signature); + } + +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiReplicationSchedule.java b/java/src/main/java/com/cloudera/api/model/ApiReplicationSchedule.java index e24b01a6..fbefa05d 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiReplicationSchedule.java +++ b/java/src/main/java/com/cloudera/api/model/ApiReplicationSchedule.java @@ -17,6 +17,7 @@ import java.util.Date; import java.util.List; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; @@ -41,6 +42,8 @@ public class ApiReplicationSchedule extends ApiSchedule { private ApiHdfsReplicationArguments hdfsArguments; private ApiHiveReplicationArguments hiveArguments; + private ApiHdfsCloudReplicationArguments hdfsCloudArguments; + private ApiHiveCloudReplicationArguments hiveCloudArguments; private List history; private Boolean active; @@ -73,6 +76,16 @@ public void setHiveArguments(ApiHiveReplicationArguments hiveArguments) { this.hiveArguments = hiveArguments; } + /** Arguments for HDFS cloud replication commands. */ + @XmlElement + public ApiHdfsCloudReplicationArguments getHdfsCloudArguments() { + return hdfsCloudArguments; + } + + public void setHdfsCloudArguments(ApiHdfsCloudReplicationArguments hdfsCloudArguments) { + this.hdfsCloudArguments = hdfsCloudArguments; + } + /** List of active and/or finished commands for this schedule. */ @XmlElementWrapper public List getHistory() { @@ -96,6 +109,16 @@ public void setActive(Boolean active) { this.active = active; } + /** Arguments for Hive cloud replication commands. */ + @XmlElement + public ApiHiveCloudReplicationArguments getHiveCloudArguments() { + return hiveCloudArguments; + } + + public void setHiveCloudArguments(ApiHiveCloudReplicationArguments hiveCloudArguments) { + this.hiveCloudArguments = hiveCloudArguments; + } + @Override public boolean equals(Object o) { if (!super.equals(o)) { @@ -104,20 +127,27 @@ public boolean equals(Object o) { ApiReplicationSchedule that = (ApiReplicationSchedule) o; return Objects.equal(hdfsArguments, that.getHdfsArguments()) && - Objects.equal(hiveArguments, that.getHiveArguments()); + Objects.equal(hiveArguments, that.getHiveArguments()) && + Objects.equal(hdfsCloudArguments, that.getHdfsCloudArguments()) && + Objects.equal(hiveCloudArguments, that.getHiveCloudArguments()); } @Override public int hashCode() { - return 31 * super.hashCode() + Objects.hashCode(hdfsArguments, hiveArguments); + return 31 * super.hashCode() + Objects.hashCode(hdfsArguments, + hiveArguments, hdfsCloudArguments, hiveCloudArguments); } - @Override - public String toString() { + protected Objects.ToStringHelper toStringHelper() { return super.toStringHelper() - .add("hdfsArguments", hdfsArguments) - .add("hiveArguments", hiveArguments) - .toString(); + .add("hdfsArguments", hdfsArguments) + .add("hiveArguments", hiveArguments) + .add("hdfsCloudArguments", hdfsCloudArguments) + .add("hiveCloudArguments", hiveCloudArguments); } + @Override + public String toString() { + return toStringHelper().toString(); + } } diff --git a/java/src/main/java/com/cloudera/api/model/ApiRollingRestartClusterArgs.java b/java/src/main/java/com/cloudera/api/model/ApiRollingRestartClusterArgs.java index f11eb051..65becf19 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiRollingRestartClusterArgs.java +++ b/java/src/main/java/com/cloudera/api/model/ApiRollingRestartClusterArgs.java @@ -37,8 +37,8 @@ public class ApiRollingRestartClusterArgs { private Boolean redeployClientConfiguration; private ApiRolesToInclude rolesToInclude; private List restartServiceNames; - - /** + + /** * Number of hosts with slave roles to restart at a time. * Must be greater than zero. Default is 1. */ @@ -46,30 +46,30 @@ public class ApiRollingRestartClusterArgs { public Integer getSlaveBatchSize() { return slaveBatchSize; } - + public void setSlaveBatchSize(Integer slaveBatchSize) { this.slaveBatchSize = slaveBatchSize; } - - /** + + /** * Number of seconds to sleep between restarts of slave host batches. - * + *

* Must be greater than or equal to 0. Default is 0. */ @XmlElement public Integer getSleepSeconds() { return sleepSeconds; } - + public void setSleepSeconds(Integer sleepSeconds) { this.sleepSeconds = sleepSeconds; } - - /** - * The threshold for number of slave host batches that are allowed to fail + + /** + * The threshold for number of slave host batches that are allowed to fail * to restart before the entire command is considered failed. - * - * Must be greather than or equal to 0. Default is 0. + *

+ * Must be greater than or equal to 0. Default is 0. *

* This argument is for ADVANCED users only. *

@@ -78,32 +78,38 @@ public void setSleepSeconds(Integer sleepSeconds) { public Integer getSlaveFailCountThreshold() { return slaveFailCountThreshold; } - + public void setSlaveFailCountThreshold(Integer slaveFailCountThreshold) { this.slaveFailCountThreshold = slaveFailCountThreshold; } - - /** Restart roles with stale configs only. */ + + /** + * Restart roles with stale configs only. + */ @XmlElement public Boolean getStaleConfigsOnly() { return staleConfigsOnly; } - + public void setStaleConfigsOnly(Boolean staleConfigsOnly) { this.staleConfigsOnly = staleConfigsOnly; } - - /** Restart roles that haven't been upgraded yet. */ + + /** + * Restart roles that haven't been upgraded yet. + */ @XmlElement public Boolean getUnUpgradedOnly() { return unUpgradedOnly; } - + public void setUnUpgradedOnly(Boolean unUpgradedOnly) { this.unUpgradedOnly = unUpgradedOnly; } - /** Re-deploy client configuration. Available since API v6. */ + /** + * Re-deploy client configuration. Available since API v6. + */ @XmlElement public Boolean getRedeployClientConfiguration() { return redeployClientConfiguration; @@ -113,18 +119,18 @@ public void setRedeployClientConfiguration(Boolean redeployClientConfiguration) this.redeployClientConfiguration = redeployClientConfiguration; } - /** + /** * Role types to restart. Default is slave roles only. */ @XmlElement public ApiRolesToInclude getRolesToInclude() { return rolesToInclude; } - + public void setRolesToInclude(ApiRolesToInclude rolesToInclude) { this.rolesToInclude = rolesToInclude; } - + /** * List of services to restart. */ @@ -132,22 +138,22 @@ public void setRolesToInclude(ApiRolesToInclude rolesToInclude) { public List getRestartServiceNames() { return restartServiceNames; } - + public void setRestartServiceNames(List restartServiceNames) { this.restartServiceNames = restartServiceNames; } - + @Override public String toString() { return Objects.toStringHelper(this) - .add("slaveBatchSize", slaveBatchSize) - .add("slaveFailCountThreshold", slaveFailCountThreshold) - .add("sleepSeconds", sleepSeconds) - .add("staleConfigsOnly", staleConfigsOnly) - .add("unUpgradedOnly", unUpgradedOnly) - .add("rolesToInclude", rolesToInclude) - .add("restartServiceNames", restartServiceNames) - .toString(); + .add("slaveBatchSize", slaveBatchSize) + .add("slaveFailCountThreshold", slaveFailCountThreshold) + .add("sleepSeconds", sleepSeconds) + .add("staleConfigsOnly", staleConfigsOnly) + .add("unUpgradedOnly", unUpgradedOnly) + .add("rolesToInclude", rolesToInclude) + .add("restartServiceNames", restartServiceNames) + .toString(); } @Override diff --git a/java/src/main/java/com/cloudera/api/model/ApiScmDbInfo.java b/java/src/main/java/com/cloudera/api/model/ApiScmDbInfo.java new file mode 100644 index 00000000..da66f4b1 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiScmDbInfo.java @@ -0,0 +1,88 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Cloudera Manager server's database information + */ +@XmlRootElement(name = "scmDbInfo") +public class ApiScmDbInfo { + + /** + * Enum for Cloudera Manager DB type. + * Note that DERBY and SQLITE3 are not supported DBs + */ + public static enum ScmDbType { + /** mysql db */ + MYSQL("mysql"), + /** postgresql db */ + POSTGRESQL("postgresql"), + /** hsql db, in memory version */ + HSQL("mem"), + /** oracle db */ + ORACLE("oracle"), + /** derby db, not supported */ + DERBY("derby"), + /** sqlite3 db, not supported */ + SQLITE3("sqlite3"); + + private String name; + + ScmDbType(String name) { + this.name = name; + } + + public static ScmDbType convert(String str) { + for (ScmDbType scmDbType : ScmDbType.values()) { + if (scmDbType.name.equals(str)) { + return scmDbType; + } + } + return null; + } + } + + private boolean scmUsingEmbeddedDb; + private ScmDbType scmDbType; + + public ApiScmDbInfo() { + } + + /** Cloudera Manager server's db type */ + @XmlElement + public ScmDbType getScmDbType() { + return scmDbType; + } + + public void setScmDbType(ScmDbType scmDbType) { + this.scmDbType = scmDbType; + } + + /** Whether Cloudera Manager server is using embedded DB */ + @XmlElement + public boolean getEmbeddedDbUsed() { + return scmUsingEmbeddedDb; + } + + public void setEmbeddedDbUsed(boolean scmUsingEmbeddedDb) { + this.scmUsingEmbeddedDb = scmUsingEmbeddedDb; + } + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/model/ApiShutdownReadiness.java b/java/src/main/java/com/cloudera/api/model/ApiShutdownReadiness.java new file mode 100644 index 00000000..15cee6b4 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiShutdownReadiness.java @@ -0,0 +1,60 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Cloudera Manager server's shutdown readiness + */ +@XmlRootElement(name = "shutdownReadiness") +public class ApiShutdownReadiness { + + /** + * Enum for Cloudera Manager shutdown readiness state. + */ + public static enum ShutdownReadinessState { + /** + * Ready for shutdown. This is a terminal state, meaning it will not change + * once reached, assuming same input. + */ + READY, + /** + * Critical activity still ongoing. + */ + NOT_READY; + + ShutdownReadinessState() { + } + } + + private ShutdownReadinessState state; + + public ApiShutdownReadiness() { + } + + /** Shutdown readiness state */ + @XmlElement + public ShutdownReadinessState getState() { + return state; + } + + public void setState(ShutdownReadinessState state) { + this.state = state; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiSimpleRollingRestartClusterArgs.java b/java/src/main/java/com/cloudera/api/model/ApiSimpleRollingRestartClusterArgs.java new file mode 100644 index 00000000..cb6ceb23 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiSimpleRollingRestartClusterArgs.java @@ -0,0 +1,102 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import com.cloudera.api.ApiUtils; +import com.google.common.base.Objects; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Basic arguments used for Rolling Restart Cluster commands. + */ +@XmlRootElement(name = "simpleRollingRestartClusterArgs") +public class ApiSimpleRollingRestartClusterArgs { + + private Integer slaveBatchSize; + private Integer sleepSeconds; + private Integer slaveFailCountThreshold; + + /** + * Number of hosts with slave roles to restart at a time. + * Must be greater than zero. Default is 1. + */ + @XmlElement + public Integer getSlaveBatchSize() { + return slaveBatchSize; + } + + public void setSlaveBatchSize(Integer slaveBatchSize) { + this.slaveBatchSize = slaveBatchSize; + } + + /** + * Number of seconds to sleep between restarts of slave host batches. + *

+ * Must be greater than or equal to 0. Default is 0. + */ + @XmlElement + public Integer getSleepSeconds() { + return sleepSeconds; + } + + public void setSleepSeconds(Integer sleepSeconds) { + this.sleepSeconds = sleepSeconds; + } + + /** + * The threshold for number of slave host batches that are allowed to fail + * to restart before the entire command is considered failed. + *

+ * Must be greater than or equal to 0. Default is 0. + *

+ * This argument is for ADVANCED users only. + *

+ */ + @XmlElement + public Integer getSlaveFailCountThreshold() { + return slaveFailCountThreshold; + } + + public void setSlaveFailCountThreshold(Integer slaveFailCountThreshold) { + this.slaveFailCountThreshold = slaveFailCountThreshold; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("slaveBatchSize", slaveBatchSize) + .add("sleepSeconds", sleepSeconds) + .add("slaveFailCountThreshold", slaveFailCountThreshold) + .toString(); + } + + @Override + public boolean equals(Object o) { + ApiSimpleRollingRestartClusterArgs that = ApiUtils.baseEquals(this, o); + return this == that || (that != null && + Objects.equal(slaveBatchSize, that.slaveBatchSize) && + Objects.equal(sleepSeconds, that.sleepSeconds) && + Objects.equal(slaveFailCountThreshold, that.slaveFailCountThreshold)); + } + + @Override + public int hashCode() { + return Objects.hashCode(slaveBatchSize, sleepSeconds, + slaveFailCountThreshold); + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiWatchedDir.java b/java/src/main/java/com/cloudera/api/model/ApiWatchedDir.java new file mode 100644 index 00000000..39a1eb5f --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiWatchedDir.java @@ -0,0 +1,37 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "watchedDir") +public class ApiWatchedDir { + + private String path; + + public ApiWatchedDir() { + } + + public ApiWatchedDir(String path) { + this.path = path; + } + + @XmlElement + public String getPath() { + return path; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiWatchedDirList.java b/java/src/main/java/com/cloudera/api/model/ApiWatchedDirList.java new file mode 100644 index 00000000..8adb1474 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/model/ApiWatchedDirList.java @@ -0,0 +1,48 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.model; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.collect.Lists; + +/** + * A list of watched directories. + */ +@XmlRootElement(name = "watchedDirList") +public class ApiWatchedDirList extends ApiListBase { + private List watchedDirs = Lists.newArrayList(); + + public ApiWatchedDirList() { + // For JAX-B. + } + + public void addWatchedDir(String dir) { + watchedDirs.add(new ApiWatchedDir(dir)); + } + + @XmlElementWrapper(name = ApiListBase.ITEMS_ATTR) + public List getDirs() { + return watchedDirs; + } + + public void setDirs(List watchedDirs) { + this.watchedDirs = watchedDirs; + } +} diff --git a/java/src/main/java/com/cloudera/api/model/ApiYarnApplication.java b/java/src/main/java/com/cloudera/api/model/ApiYarnApplication.java index 81f29ac5..71891231 100644 --- a/java/src/main/java/com/cloudera/api/model/ApiYarnApplication.java +++ b/java/src/main/java/com/cloudera/api/model/ApiYarnApplication.java @@ -51,6 +51,7 @@ public class ApiYarnApplication { private Integer runningContainers; private Double containerUsedMemorySeconds; + private Double containerUsedMemoryMax; private Double containerUsedCpuSeconds; private Double containerUsedVcoreSeconds; private Double containerAllocatedMemorySeconds; @@ -78,6 +79,7 @@ public ApiYarnApplication( Integer allocatedVCores, Integer runningContainers, Double containerUsedMemorySeconds, + Double containerUsedMemoryMax, Double containerUsedCpuSeconds, Double containerUsedVcoreSeconds, Double containerAllocatedMemorySeconds, @@ -104,6 +106,7 @@ public ApiYarnApplication( this.allocatedVCores = allocatedVCores; this.runningContainers = runningContainers; this.containerUsedMemorySeconds = containerUsedMemorySeconds; + this.containerUsedMemoryMax = containerUsedMemoryMax; this.containerUsedCpuSeconds = containerUsedCpuSeconds; this.containerUsedVcoreSeconds = containerUsedVcoreSeconds; this.containerAllocatedMemorySeconds = containerAllocatedMemorySeconds; @@ -303,6 +306,21 @@ public void setContainerUsedMemorySeconds(Double containerUsedMemorySeconds) { this.containerUsedMemorySeconds = containerUsedMemorySeconds; } + /** + * Maximum memory used by containers launched by the YARN application. + * Computed by running a MapReduce job from Cloudera Service Monitor to + * aggregate YARN usage metrics + * Available since v16 + */ + @XmlElement + public Double getContainerUsedMemoryMax() { + return containerUsedMemoryMax; + } + + public void setContainerUsedMemoryMax(Double containerUsedMemoryMax) { + this.containerUsedMemoryMax = containerUsedMemoryMax; + } + /** * Actual CPU (in percent-secs) used by containers launched by the YARN application. * Computed by running a MapReduce job from Cloudera Service Monitor to @@ -384,6 +402,7 @@ public String toString() { .add("allocatedVCores", allocatedVCores) .add("runningContainers", runningContainers) .add("containerUsedMemorySeconds", containerUsedMemorySeconds) + .add("containerUsedMemoryMax", containerUsedMemoryMax) .add("containerUsedCpuSeconds", containerUsedCpuSeconds) .add("containerUsedVcoreSeconds", containerUsedVcoreSeconds) .add("containerAllocatedMemorySeconds", containerAllocatedMemorySeconds) diff --git a/java/src/main/java/com/cloudera/api/v10/RoleCommandsResourceV10.java b/java/src/main/java/com/cloudera/api/v10/RoleCommandsResourceV10.java index 6bdd83a4..97df5a20 100644 --- a/java/src/main/java/com/cloudera/api/v10/RoleCommandsResourceV10.java +++ b/java/src/main/java/com/cloudera/api/v10/RoleCommandsResourceV10.java @@ -37,7 +37,8 @@ public interface RoleCommandsResourceV10 extends RoleCommandsResourceV8 { *

* For HDFS services, this command should be executed on NameNode or * DataNode roles. For NameNodes, it refreshes the role's node list. - * For DataNodes, it refreshes the role's data directory list. + * For DataNodes, it refreshes the role's data directory list and other + * configuration. *

* For YARN services, this command should be executed on ResourceManager * roles. It refreshes the role's queue and node information. diff --git a/java/src/main/java/com/cloudera/api/v11/CommandsResourceV11.java b/java/src/main/java/com/cloudera/api/v11/CommandsResourceV11.java index c6a78c1e..d5026e5e 100644 --- a/java/src/main/java/com/cloudera/api/v11/CommandsResourceV11.java +++ b/java/src/main/java/com/cloudera/api/v11/CommandsResourceV11.java @@ -21,12 +21,6 @@ public interface CommandsResourceV11 extends CommandsResource { /** * Try to rerun a command. * - *

- * Note: Only command that supports retry is UpgradeCluster. - * {@link ApiCommand#isCanRetry()} will be true for only - * UpgradeCluster command. - *

- * * @param commandId ID of the command that needs to be run. * @return Command that represents the retry attempt. */ diff --git a/java/src/main/java/com/cloudera/api/v14/ClouderaManagerResourceV14.java b/java/src/main/java/com/cloudera/api/v14/ClouderaManagerResourceV14.java new file mode 100644 index 00000000..02b92c0d --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v14/ClouderaManagerResourceV14.java @@ -0,0 +1,41 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v14; + +import com.cloudera.api.model.ApiScmDbInfo; +import com.cloudera.api.v12.ClouderaManagerResourceV12; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({MediaType.APPLICATION_JSON}) +@Produces({MediaType.APPLICATION_JSON}) +public interface ClouderaManagerResourceV14 extends ClouderaManagerResourceV12 { + + /** + * Provides Cloudera Manager server's database information + * + * @return Cloudera Manager server's database information + */ + @GET + @Path("scmDbInfo") + public ApiScmDbInfo getScmDbInfo(); + +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v14/ClustersResourceV14.java b/java/src/main/java/com/cloudera/api/v14/ClustersResourceV14.java new file mode 100644 index 00000000..019ff349 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v14/ClustersResourceV14.java @@ -0,0 +1,39 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v14; + +import static com.cloudera.api.Parameters.CLUSTER_NAME; + +import com.cloudera.api.v13.ClustersResourceV13; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ClustersResourceV14 extends ClustersResourceV13 { + + /** + * @return The services resource handler. + */ + @Override + @Path("/{clusterName}/services") + public ServicesResourceV14 getServicesResource( + @PathParam(CLUSTER_NAME) String clusterName); +} diff --git a/java/src/main/java/com/cloudera/api/v14/ExternalAccountsResourceV14.java b/java/src/main/java/com/cloudera/api/v14/ExternalAccountsResourceV14.java new file mode 100644 index 00000000..4a7319d7 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v14/ExternalAccountsResourceV14.java @@ -0,0 +1,95 @@ +// Copyright (c) 2016 Cloudera, Inc. All rights reserved. +package com.cloudera.api.v14; + +import com.cloudera.api.DataView; +import com.cloudera.api.Parameters; +import com.cloudera.api.model.ApiExternalAccount; +import com.cloudera.api.model.ApiExternalAccountCategoryList; +import com.cloudera.api.model.ApiExternalAccountList; +import com.cloudera.api.model.ApiExternalAccountTypeList; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +/** + * Manage external accounts used by various Cloudera Manager features, for performing external + * tasks. + */ +@Consumes({MediaType.APPLICATION_JSON}) +@Produces({MediaType.APPLICATION_JSON}) +public interface ExternalAccountsResourceV14 { + + /** + * List of external account categories supported by this Cloudera Manager. + * @return external account categories + */ + @GET + @Path("/supportedCategories") + ApiExternalAccountCategoryList getSupportedCategories(); + + /** + * List of external account types supported by this Cloudera Manager by category. + */ + @GET + @Path("/supportedTypes/{" + Parameters.EXTERNAL_ACCOUNT_CATEGORY_NAME + "}") + ApiExternalAccountTypeList getSupportedTypes( + @PathParam(Parameters.EXTERNAL_ACCOUNT_CATEGORY_NAME) String categoryName); + + /** + * Get a list of external accounts for a specific account type. + */ + @GET + @Path("/type/{" + Parameters.EXTERNAL_ACCOUNT_TYPE_NAME + "}") + ApiExternalAccountList readAccounts( + @PathParam(Parameters.EXTERNAL_ACCOUNT_TYPE_NAME) String typeName, + @QueryParam(Parameters.DATA_VIEW) DataView view); + + /** + * Get a single external account by account name. + */ + @GET + @Path("/account/{" + Parameters.EXTERNAL_ACCOUNT_NAME + "}") + ApiExternalAccount readAccount(@PathParam(Parameters.EXTERNAL_ACCOUNT_NAME) String name, + @QueryParam(Parameters.DATA_VIEW) DataView view); + + /** + * Get a single external account by display name. + */ + @GET + @Path("/accountByDisplayName/{" + Parameters.DISPLAY_NAME + "}") + ApiExternalAccount readAccountByDisplayName( + @PathParam(Parameters.DISPLAY_NAME) String displayName, + @QueryParam(Parameters.DATA_VIEW) DataView view); + + /** + * Create a new external account. + * Account names and display names must be unique, i.e. they must not share names or display + * names with an existing account. + * Server generates an account ID for the requested account. + */ + @POST + @Path("/create") + ApiExternalAccount createAccount(ApiExternalAccount account); + + /** + * Update an external account. + */ + @PUT + @Path("/update") + ApiExternalAccount updateAccount(ApiExternalAccount account); + + /** + * Delete an external account, specifying its name. + */ + @DELETE + @Path("/delete/{" + Parameters.EXTERNAL_ACCOUNT_NAME + "}") + ApiExternalAccount deleteAccount(@PathParam(Parameters.EXTERNAL_ACCOUNT_NAME) String name); +} diff --git a/java/src/main/java/com/cloudera/api/v14/NameservicesResourceV14.java b/java/src/main/java/com/cloudera/api/v14/NameservicesResourceV14.java new file mode 100644 index 00000000..538dea29 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v14/NameservicesResourceV14.java @@ -0,0 +1,41 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v14; + +import static com.cloudera.api.Parameters.NAMESERVICE_NAME; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import com.cloudera.api.v11.NameservicesResourceV11; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface NameservicesResourceV14 extends NameservicesResourceV11 { + + /** + * Returns the watched directory resource handler. + * + * @param nameservice The nameservice to retrieve. + * @return the watched directory resource handler + */ + @Path("/{nameservice}/watcheddir") + public WatchedDirResource getWatchedDirResource( + @PathParam(NAMESERVICE_NAME) String nameservice); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v14/RootResourceV14.java b/java/src/main/java/com/cloudera/api/v14/RootResourceV14.java new file mode 100644 index 00000000..f8305fcd --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v14/RootResourceV14.java @@ -0,0 +1,41 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v14; + +import com.cloudera.api.v13.RootResourceV13; + +import javax.ws.rs.Path; + +@Path("") +public interface RootResourceV14 extends RootResourceV13 { + + @Override + @Path("/cm") + public ClouderaManagerResourceV14 getClouderaManagerResource(); + + /** + * @return The external accounts resource handler. + */ + @Path("/externalAccounts") + ExternalAccountsResourceV14 getExternalAccountsResource(); + + /** + * @return The clusters resource handler. + */ + @Override + @Path("/clusters") + public ClustersResourceV14 getClustersResource(); +} diff --git a/java/src/main/java/com/cloudera/api/v14/ServicesResourceV14.java b/java/src/main/java/com/cloudera/api/v14/ServicesResourceV14.java new file mode 100644 index 00000000..426f2edd --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v14/ServicesResourceV14.java @@ -0,0 +1,78 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v14; + +import static com.cloudera.api.Parameters.SERVICE_NAME; + +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.v13.ServicesResourceV13; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ServicesResourceV14 extends ServicesResourceV13 { + + /** + * Returns the watched directory resource handler. + * + * @param serviceName The service name. + * @return the watched directory resource handler + */ + @Path("/{serviceName}/watcheddir") + public WatchedDirResource getWatchedDirResource( + @PathParam(SERVICE_NAME) String serviceName); + + /** + * Returns the nameservices resource handler. + * + * @param serviceName The service name. + * @return The nameservices resource handler. + */ + @Path("/{serviceName}/nameservices") + @Override + public NameservicesResourceV14 getNameservicesResource( + @PathParam(SERVICE_NAME) String serviceName); + + /** + * Dump the Oozie Server Database. + * + * @param serviceName The name of the service + * @return Information about the submitted command. + */ + @POST + @Consumes() + @Path("/{serviceName}/commands/oozieDumpDatabase") + public ApiCommand oozieDumpDatabaseCommand( + @PathParam(SERVICE_NAME) String serviceName); + + /** + * Load the Oozie Server Database from dump. + * + * @param serviceName The name of the service + * @return Information about the submitted command. + */ + @POST + @Consumes() + @Path("/{serviceName}/commands/oozieLoadDatabase") + public ApiCommand oozieLoadDatabaseCommand( + @PathParam(SERVICE_NAME) String serviceName); +} diff --git a/java/src/main/java/com/cloudera/api/v14/WatchedDirResource.java b/java/src/main/java/com/cloudera/api/v14/WatchedDirResource.java new file mode 100644 index 00000000..0a67910c --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v14/WatchedDirResource.java @@ -0,0 +1,76 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v14; + +import static com.cloudera.api.Parameters.DIR_PATH; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import com.cloudera.api.model.ApiWatchedDir; +import com.cloudera.api.model.ApiWatchedDirList; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface WatchedDirResource { + + /** + * Lists all the watched directories. + *

+ * Available since API v14. Only available with Cloudera Manager Enterprise + * Edition. + *

+ * + * @return List of currently watched directories. + */ + @GET + @Path("/") + public ApiWatchedDirList listWatchedDirectories(); + + /** + * Adds a directory to the watching list. + *

+ * Available since API v14. Only available with Cloudera Manager Enterprise + * Edition. + *

+ * + * @param dir The directory to be added. + * @return Added directory. + */ + @POST + @Path("/") + public ApiWatchedDir addWatchedDirectory(ApiWatchedDir dir); + + /** + * Removes a directory from the watching list. + *

+ * Available since API v14. Only available with Cloudera Manager Enterprise + * Edition. + *

+ * + * @param directoryPath The directory path to be removed. + * @return Removed directory. + */ + @DELETE + @Path("/{directoryPath}") + public ApiWatchedDir removeWatchedDirectory(@PathParam(DIR_PATH) String directoryPath); +} diff --git a/java/src/main/java/com/cloudera/api/v14/package-info.java b/java/src/main/java/com/cloudera/api/v14/package-info.java new file mode 100644 index 00000000..a5626a12 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v14/package-info.java @@ -0,0 +1,21 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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. + +/** + * API version 14, introduced in Cloudera Manager 5.9.0. + */ + +package com.cloudera.api.v14; diff --git a/java/src/main/java/com/cloudera/api/v15/ClouderaManagerResourceV15.java b/java/src/main/java/com/cloudera/api/v15/ClouderaManagerResourceV15.java new file mode 100644 index 00000000..2e33cbab --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v15/ClouderaManagerResourceV15.java @@ -0,0 +1,95 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v15; + +import com.cloudera.api.Parameters; +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.model.ApiConfigList; +import com.cloudera.api.model.ApiShutdownReadiness; +import com.cloudera.api.model.ApiHostNameList; +import com.cloudera.api.v14.ClouderaManagerResourceV14; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +@Consumes({MediaType.APPLICATION_JSON}) +@Produces({MediaType.APPLICATION_JSON}) +public interface ClouderaManagerResourceV15 extends ClouderaManagerResourceV14 { + + /** + * Update the Cloudera Manager settings. + *

+ * If a value is set in the given configuration, it will be added to the + * manager's settings, replacing any existing entry. If a value is unset (its + * value is null), the existing the setting will be erased. + *

+ * Settings that are not listed in the input will maintain their current + * values. + * + * @param config Settings to update. + * @param message Optional message describing the changes. + * @return The updated configuration. + */ + @PUT + @Path("/config") + public ApiConfigList updateConfig( + ApiConfigList config, + @QueryParam(Parameters.MESSAGE) String message); + + /** + * Retrieve Cloudera Manager's readiness for shutdown and destroy. + * Applications that wish to destroy Cloudera Manager and its managed cluster + * should poll this API, repeatedly if necessary, to respect its readiness. + * + * @param lastActivityTime End time of the last known activity/workload + * against the managed clusters, in ISO 8601 format. + * @return Cloudera Manager readiness for shutdown + */ + @GET + @Path("/shutdownReadiness") + public ApiShutdownReadiness getShutdownReadiness( + @QueryParam("lastActivityTime") + String lastActivityTime); + + + /** + * Recommission the given hosts. If slave roles support start when decommissioned, + * start those roles before recommission. + * All slave roles on the hosts will be recommissioned. + * + * Warning: Evolving. This method may change in the future and does not offer standard compatibility guarantees. + * Recommission the given hosts. If possible, start those roles before recommission. All slave roles on the hosts + * will be recommissioned. + * Do not use without guidance from Cloudera. + * + * Currently, only HDFS DataNodes will be started by this command. + * + * + * @return Information about the submitted command. + */ + @POST + @Consumes + @Path("/commands/hostsRecommissionWithStart") + public ApiCommand hostsRecommissionWithStartCommand( + ApiHostNameList hostNameList); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v15/ClustersResourceV15.java b/java/src/main/java/com/cloudera/api/v15/ClustersResourceV15.java new file mode 100644 index 00000000..619bbbdc --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v15/ClustersResourceV15.java @@ -0,0 +1,39 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v15; + +import static com.cloudera.api.Parameters.*; + +import com.cloudera.api.v14.ClustersResourceV14; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ClustersResourceV15 extends ClustersResourceV14 { + /** + * @return The services resource handler. + */ + @Override + @Path("/{clusterName}/services") + public ServicesResourceV15 getServicesResource( + @PathParam(CLUSTER_NAME) String clusterName); + +} diff --git a/java/src/main/java/com/cloudera/api/v15/RootResourceV15.java b/java/src/main/java/com/cloudera/api/v15/RootResourceV15.java new file mode 100644 index 00000000..56177a57 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v15/RootResourceV15.java @@ -0,0 +1,36 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v15; + +import com.cloudera.api.v14.RootResourceV14; + +import javax.ws.rs.Path; + +@Path("") +public interface RootResourceV15 extends RootResourceV14 { + + @Override + @Path("/cm") + public ClouderaManagerResourceV15 getClouderaManagerResource(); + + /** + * @return The clusters resource handler. + */ + @Override + @Path("/clusters") + public ClustersResourceV15 getClustersResource(); + +} diff --git a/java/src/main/java/com/cloudera/api/v15/ServicesResourceV15.java b/java/src/main/java/com/cloudera/api/v15/ServicesResourceV15.java new file mode 100644 index 00000000..25ef4dee --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v15/ServicesResourceV15.java @@ -0,0 +1,59 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v15; + +import static com.cloudera.api.Parameters.*; + +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.model.ApiRoleNameList; +import com.cloudera.api.v14.ServicesResourceV14; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ServicesResourceV15 extends ServicesResourceV14 { + /** + * Start and recommission roles of a service. + *

+ * The list should contain names of slave roles to start and recommission. + *

+ * + *

+ * Warning: Evolving. This method may change in the future and does not offer standard compatibility guarantees. + * Only support by HDFS. + * Do not use without guidance from Cloudera. + *

+ * + *

+ * Available since API v15. + *

+ * + * @param serviceName Name of the service on which to run the command. + * @param roleNames List of role names to recommision. + * @return Information about the submitted command. + */ + @POST + @Path("/{serviceName}/commands/recommissionWithStart") + public ApiCommand recommissionWithStartCommand( + @PathParam(SERVICE_NAME) String serviceName, + ApiRoleNameList roleNames); +} diff --git a/java/src/main/java/com/cloudera/api/v15/package-info.java b/java/src/main/java/com/cloudera/api/v15/package-info.java new file mode 100644 index 00000000..bde151a4 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v15/package-info.java @@ -0,0 +1,21 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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. + +/** + * API version 15, introduced in Cloudera Manager 5.10.0. + */ + +package com.cloudera.api.v15; diff --git a/java/src/main/java/com/cloudera/api/v16/ClouderaManagerResourceV16.java b/java/src/main/java/com/cloudera/api/v16/ClouderaManagerResourceV16.java new file mode 100644 index 00000000..31e01fb8 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v16/ClouderaManagerResourceV16.java @@ -0,0 +1,51 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v16; + +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.v15.ClouderaManagerResourceV15; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ClouderaManagerResourceV16 extends ClouderaManagerResourceV15 { + + /** + *

+ * Submit a command to refresh parcels information. + *

+ *

+ * This API could be used following two scenarios.
+ * - User updated Cloudera Manager's local parcel repository.
+ * - User updated remote parcel locations. + *

+ * User wants to invoke this API to make sure that Cloudera Manager gets + * latest parcels information. User can then monitor the returned command + * before proceeding to the next step. + *

+ * + * @return Information about the submitted command. + */ + @POST + @Path("/commands/refreshParcelRepos") + public ApiCommand refreshParcelRepos(); +} \ No newline at end of file diff --git a/java/src/main/java/com/cloudera/api/v16/ClustersResourceV16.java b/java/src/main/java/com/cloudera/api/v16/ClustersResourceV16.java new file mode 100644 index 00000000..c43b70d7 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v16/ClustersResourceV16.java @@ -0,0 +1,39 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v16; + +import static com.cloudera.api.Parameters.*; + +import com.cloudera.api.v15.ClustersResourceV15; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ClustersResourceV16 extends ClustersResourceV15 { + /** + * @return The services resource handler. + */ + @Override + @Path("/{clusterName}/services") + public ServicesResourceV16 getServicesResource( + @PathParam(CLUSTER_NAME) String clusterName); + +} diff --git a/java/src/main/java/com/cloudera/api/v16/ExternalAccountsResourceV16.java b/java/src/main/java/com/cloudera/api/v16/ExternalAccountsResourceV16.java new file mode 100644 index 00000000..d3d56000 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v16/ExternalAccountsResourceV16.java @@ -0,0 +1,109 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v16; + +import static com.cloudera.api.Parameters.COMMAND_NAME; +import static com.cloudera.api.Parameters.DATA_VIEW_DEFAULT; +import static com.cloudera.api.Parameters.EXTERNAL_ACCOUNT_NAME; +import static com.cloudera.api.Parameters.EXTERNAL_ACCOUNT_TYPE_NAME; + +import com.cloudera.api.DataView; +import com.cloudera.api.Parameters; +import com.cloudera.api.model.ApiCommand; +import com.cloudera.api.model.ApiCommandMetadataList; +import com.cloudera.api.model.ApiConfigList; +import com.cloudera.api.v14.ExternalAccountsResourceV14; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +/** + * Manage external accounts used by various Cloudera Manager features, for + * performing external tasks. + */ +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ExternalAccountsResourceV16 + extends ExternalAccountsResourceV14 { + + /** + * Get configs of external account for the given account name. + * + * @param external account name + * @param view The view to materialize, either "summary" or "full". + * @return the current external account configurations. + */ + @GET + @Path("/account/{" + Parameters.EXTERNAL_ACCOUNT_NAME + "}" + "/config") + ApiConfigList readConfig( + @PathParam(Parameters.EXTERNAL_ACCOUNT_NAME) String name, + @QueryParam(Parameters.DATA_VIEW) @DefaultValue(DATA_VIEW_DEFAULT) DataView view); + + /** + * Upadate configs of external account for the given account name. + * + * @param external account name + * @param config Settings to update. + * @param message Optional message describing the changes. + * @return The updated configuration. + */ + @PUT + @Path("/account/{" + Parameters.EXTERNAL_ACCOUNT_NAME + "}" + "/config") + ApiConfigList updateConfig( + @PathParam(Parameters.EXTERNAL_ACCOUNT_NAME) String name, + ApiConfigList config, + @QueryParam(Parameters.MESSAGE) String message); + + /** + * Executes a command on the external account specified + * by name. + *

+ * Available since API v16. + * + * @param name The external account name. + * @param commandName The command name. + * @return Information about the submitted command. + */ + @POST + @Path("/account/{" + Parameters.EXTERNAL_ACCOUNT_NAME + "}/commands/{" + + Parameters.COMMAND_NAME + "}") + public ApiCommand externalAccountCommandByName( + @PathParam(EXTERNAL_ACCOUNT_NAME) String name, + @PathParam(COMMAND_NAME) String commandName); + + /** + * Lists all the commands that can be executed by name on the + * provided external account type. + *

+ * Available since API v16. + * + * @param typeName The external account type name + * @return a list of command metadata objects + */ + @GET + @Path(("/typeInfo/{" + Parameters.EXTERNAL_ACCOUNT_TYPE_NAME + + "}/commandsByName")) + public ApiCommandMetadataList listExternalAccountCommands( + @PathParam(EXTERNAL_ACCOUNT_TYPE_NAME) String typeName); +} diff --git a/java/src/main/java/com/cloudera/api/v16/RootResourceV16.java b/java/src/main/java/com/cloudera/api/v16/RootResourceV16.java new file mode 100644 index 00000000..7c468cb5 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v16/RootResourceV16.java @@ -0,0 +1,37 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v16; + +import com.cloudera.api.v15.RootResourceV15; + +import javax.ws.rs.Path; + +@Path("") +public interface RootResourceV16 extends RootResourceV15 { + + /** + * @return The clusters resource handler. + */ + @Override + @Path("/clusters") + public ClustersResourceV16 getClustersResource(); + + /** + * @return The external accounts resource handler. + */ + @Path("/externalAccounts") + ExternalAccountsResourceV16 getExternalAccountsResource(); +} diff --git a/java/src/main/java/com/cloudera/api/v16/ServicesResourceV16.java b/java/src/main/java/com/cloudera/api/v16/ServicesResourceV16.java new file mode 100644 index 00000000..eef20e56 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v16/ServicesResourceV16.java @@ -0,0 +1,28 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.api.v16; + +import com.cloudera.api.v15.ServicesResourceV15; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) +public interface ServicesResourceV16 extends ServicesResourceV15 { + +} diff --git a/java/src/main/java/com/cloudera/api/v16/package-info.java b/java/src/main/java/com/cloudera/api/v16/package-info.java new file mode 100644 index 00000000..84f50ef0 --- /dev/null +++ b/java/src/main/java/com/cloudera/api/v16/package-info.java @@ -0,0 +1,21 @@ +// Licensed to Cloudera, Inc. under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. Cloudera, Inc. 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. + +/** + * API version 16, introduced in Cloudera Manager 5.11.0. + */ + +package com.cloudera.api.v16; diff --git a/java/src/main/java/com/cloudera/api/v4/ImpalaQueriesResource.java b/java/src/main/java/com/cloudera/api/v4/ImpalaQueriesResource.java index 4942e3db..4c0e13c5 100644 --- a/java/src/main/java/com/cloudera/api/v4/ImpalaQueriesResource.java +++ b/java/src/main/java/com/cloudera/api/v4/ImpalaQueriesResource.java @@ -51,7 +51,8 @@ public interface ImpalaQueriesResource { * 'user = root'. Multiple basic filters can be combined into a complex * expression using standard and / or boolean logic and parenthesis. * An example of a complex filter is: 'query_duration > 5s and (user = root or - * user = myUserName)'. + * user = myUserName)'. An example of expected full query string in requested + * URL is: '?filter=(query_duration > 5s and (user = root or user = myUserName))'. * @param from Start of the period to query in ISO 8601 format (defaults to 5 * minutes before the 'to' time). * @param to End of the period to query in ISO 8601 format (defaults to diff --git a/java/src/test/java/com/cloudera/api/ClouderaManagerClientBuilderTest.java b/java/src/test/java/com/cloudera/api/ClouderaManagerClientBuilderTest.java index 5066a5ee..bb6da6b7 100644 --- a/java/src/test/java/com/cloudera/api/ClouderaManagerClientBuilderTest.java +++ b/java/src/test/java/com/cloudera/api/ClouderaManagerClientBuilderTest.java @@ -23,6 +23,8 @@ import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; import org.junit.Test; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; import java.net.MalformedURLException; import java.net.URL; @@ -34,6 +36,20 @@ public class ClouderaManagerClientBuilderTest { + /** + * Replacement for WebClient.getConfig() on delegated proxy. + * + * Because we use dynamic proxy mechanism to delegate call from {@link ApiRootResource} + * to {@link ApiRootResourceExternal}, instanceof operator doesn't work since they don't + * share any common interface. Hence need for this method. + */ + private ClientConfiguration getClientConfigFromProxy(ApiRootResource proxy) { + InvocationHandler invocationHandler = Proxy.getInvocationHandler(proxy); + assertTrue(invocationHandler instanceof ApiRootResourceInvocationHandler); + return WebClient.getConfig( + ((ApiRootResourceInvocationHandler)invocationHandler).getDelegateRootResource()); + } + @Test public void testURLGeneration() throws MalformedURLException { assertEquals("Wrong address generated from base url", @@ -111,13 +127,13 @@ public void testMaintainSessionConfig() { .withPort(1) .enableLogging() .build(); - ClientConfiguration cfg = WebClient.getConfig(proxy); + ClientConfiguration cfg = getClientConfigFromProxy(proxy); assertNotNull(cfg); Boolean maintainSession = (Boolean)cfg.getRequestContext().get(Message.MAINTAIN_SESSION); assertNull(maintainSession); proxy = builder.setMaintainSessionAcrossRequests(true).build(); - cfg = WebClient.getConfig(proxy); + cfg = getClientConfigFromProxy(proxy); assertNotNull(cfg); maintainSession = (Boolean)cfg.getRequestContext().get(Message.MAINTAIN_SESSION); assertTrue(maintainSession); @@ -130,7 +146,7 @@ public void testPassingLocale() { .withPort(1) .enableLogging() .build(); - ClientConfiguration cfg = WebClient.getConfig(proxy); + ClientConfiguration cfg = getClientConfigFromProxy(proxy); HTTPConduit conduit = (HTTPConduit) cfg.getConduit(); HTTPClientPolicy clientPolicy = conduit.getClient(); @@ -139,7 +155,7 @@ public void testPassingLocale() { assertNull(acceptLanguage); proxy = builder.withAcceptLanguage("some-string").build(); - cfg = WebClient.getConfig(proxy); + cfg = getClientConfigFromProxy(proxy); conduit = (HTTPConduit) cfg.getConduit(); clientPolicy = conduit.getClient(); assertEquals("some-string", clientPolicy.getAcceptLanguage()); @@ -152,13 +168,13 @@ public void testStreamAutoClosureConfig() { .withPort(1) .enableLogging() .build(); - ClientConfiguration cfg = WebClient.getConfig(proxy); + ClientConfiguration cfg = getClientConfigFromProxy(proxy); assertNotNull(cfg); Boolean autoClosure = (Boolean)cfg.getRequestContext().get("response.stream.auto.close"); assertNull(autoClosure); proxy = builder.enableStreamAutoClosure().build(); - cfg = WebClient.getConfig(proxy); + cfg = getClientConfigFromProxy(proxy); assertNotNull(cfg); autoClosure = (Boolean)cfg.getRequestContext().get("response.stream.auto.close"); assertTrue(autoClosure); diff --git a/java/src/test/java/com/cloudera/api/model/ApiModelTest.java b/java/src/test/java/com/cloudera/api/model/ApiModelTest.java index babb169c..cb4b509a 100644 --- a/java/src/test/java/com/cloudera/api/model/ApiModelTest.java +++ b/java/src/test/java/com/cloudera/api/model/ApiModelTest.java @@ -226,6 +226,7 @@ public void testApiConfig() throws Exception { "description", "relatedName", ApiConfig.ValidationState.OK, "validationMessage"); cfg.setValidationWarningsSuppressed(true); + cfg.setSensitive(false); checkJsonXML(cfg); ApiServiceConfig svcCfg = new ApiServiceConfig(); @@ -528,6 +529,7 @@ public void testConfig() throws Exception { ApiConfig.ValidationState.OK, "validationMessage"); config.setValidationWarningsSuppressed(false); + config.setSensitive(true); checkJsonXML(config); } @@ -684,8 +686,10 @@ public void testHiveReplication() throws Exception { res.setTableCount(1); res.setImpalaUDFs(Arrays.asList(new ApiImpalaUDF("db1", "func1"))); res.setImpalaUDFCount(1); + res.setHiveUDFs(Arrays.asList(new ApiHiveUDF("db2", "func2"))); + res.setHiveUDFCount(1); res.setErrors(Arrays.asList(new ApiHiveReplicationError("db1", "table1", - "func1(STRING)", "error1"))); + "func1(STRING)", "func2(STRING)", "error1"))); res.setErrorCount(1); res.setDryRun(true); res.setPhase("foo"); @@ -859,7 +863,7 @@ public void testYarnApplication() throws Exception { "appId", "appName", new Date(), new Date(), "user", "pool", "FINISHED", 80.0, mr2Information, Maps.newHashMap(), ImmutableList.of("foo"), 1234L, 5678L, - 123, 1, 3, 1d, 2d, 3d, 4d, 5d); + 123, 1, 3, 1d, 1.5d, 2d, 3d, 4d, 5d); checkJsonXML(application); ApiYarnApplicationResponse response = new ApiYarnApplicationResponse( @@ -995,6 +999,7 @@ private ApiCluster newCluster() { cluster.setMaintenanceMode(true); cluster.setName("mycluster"); cluster.setDisplayName("mycluster-displayName"); + cluster.setUuid("abcd-efg-hijk-lmnop"); cluster.setClusterUrl("http://some-url:7180/cmf/clusterRedirect/mycluster"); cluster.setHostsUrl("http://some-url:7180/cmf/clusterRedirect/mycluster/hosts"); cluster.setVersion(ApiClusterVersion.CDH4);