@@ -751,6 +751,14 @@ export class ClusterService {
751751 this . client = client ;
752752 }
753753
754+ /**
755+ * Returns information about all pinned clusters, currently active clusters, up to 70 of the most
756+ * recently terminated interactive clusters in the past 7 days, and up to 30 of the most recently
757+ * terminated job clusters in the past 7 days. For example, if there is 1 pinned cluster, 4 active
758+ * clusters, 45 terminated interactive clusters in the past 7 days, and 50 terminated job clusters
759+ * in the past 7 days, then this API returns the 1 pinned cluster, 4 active clusters, all 45
760+ * terminated interactive clusters, and the 30 most recently terminated job clusters.
761+ */
754762 async listClusters (
755763 request : ListClustersRequest
756764 ) : Promise < ListClustersResponse > {
@@ -761,6 +769,51 @@ export class ClusterService {
761769 ) ) as ListClustersResponse ;
762770 }
763771
772+ /**
773+ * Creates a new Spark cluster. This method will acquire new instances from the cloud provider
774+ * if necessary. This method is asynchronous; the returned ``cluster_id`` can be used to poll the
775+ * cluster status. When this method returns, the cluster will be in
776+ * a ``PENDING`` state. The cluster will be usable once it enters a ``RUNNING`` state.
777+ * Note: Databricks may not be able to acquire some of the requested nodes, due to cloud provider
778+ * limitations (account limits, spot price, ...) or transient network issues. If Databricks
779+ * acquires at least 85% of the requested on-demand nodes, cluster creation will succeed.
780+ * Otherwise the cluster will terminate with an informative error message.
781+ *
782+ * An example request:
783+ *
784+ * .. code::
785+ *
786+ * {
787+ * "cluster_name": "my-cluster",
788+ * "spark_version": "2.0.x-scala2.10",
789+ * "node_type_id": "r3.xlarge",
790+ * "spark_conf": {
791+ * "spark.speculation": true
792+ * },
793+ * "aws_attributes": {
794+ * "availability": "SPOT",
795+ * "zone_id": "us-west-2a"
796+ * },
797+ * "num_workers": 25
798+ * }
799+ *
800+ *
801+ *
802+ * See below as an example for an autoscaling cluster. Note that this cluster will start with
803+ * `2` nodes, the minimum.
804+ *
805+ * .. code::
806+ *
807+ * {
808+ * "cluster_name": "autoscaling-cluster",
809+ * "spark_version": "2.0.x-scala2.10",
810+ * "node_type_id": "r3.xlarge",
811+ * "autoscale" : {
812+ * "min_workers": 2,
813+ * "max_workers": 50
814+ * }
815+ * }
816+ */
764817 async create (
765818 request : CreateClusterRequest
766819 ) : Promise < CreateClusterResponse > {
@@ -771,6 +824,23 @@ export class ClusterService {
771824 ) ) as CreateClusterResponse ;
772825 }
773826
827+ /**
828+ * Starts a terminated Spark cluster given its id. This works similar to `createCluster` except:
829+ * - The previous cluster id and attributes are preserved.
830+ * - The cluster starts with the last specified cluster size.
831+ * - If the previous cluster was an autoscaling cluster, the current cluster starts with
832+ * the minimum number of nodes.
833+ * - If the cluster is not currently in a ``TERMINATED`` state, nothing will happen.
834+ * - Clusters launched to run a job cannot be started.
835+ *
836+ * An example request:
837+ *
838+ * .. code::
839+ *
840+ * {
841+ * "cluster_id": "1202-211320-brick1"
842+ * }
843+ */
774844 async start ( request : StartClusterRequest ) : Promise < StartClusterResponse > {
775845 return ( await this . client . request (
776846 "/api/2.0/clusters/start" ,
@@ -779,6 +849,9 @@ export class ClusterService {
779849 ) ) as StartClusterResponse ;
780850 }
781851
852+ /**
853+ * Returns the list of available Spark versions. These versions can be used to launch a cluster.
854+ */
782855 async listSparkVersions (
783856 request : GetSparkVersionsRequest
784857 ) : Promise < GetSparkVersionsResponse > {
@@ -789,6 +862,19 @@ export class ClusterService {
789862 ) ) as GetSparkVersionsResponse ;
790863 }
791864
865+ /**
866+ * Terminates a Spark cluster given its id. The cluster is removed asynchronously. Once the
867+ * termination has completed, the cluster will be in a ``TERMINATED`` state. If the cluster is
868+ * already in a ``TERMINATING`` or ``TERMINATED`` state, nothing will happen.
869+ *
870+ * An example request:
871+ *
872+ * .. code::
873+ *
874+ * {
875+ * "cluster_id": "1202-211320-brick1"
876+ * }
877+ */
792878 async delete (
793879 request : DeleteClusterRequest
794880 ) : Promise < DeleteClusterResponse > {
@@ -799,6 +885,19 @@ export class ClusterService {
799885 ) ) as DeleteClusterResponse ;
800886 }
801887
888+ /**
889+ * Permanently deletes a Spark cluster. This cluster is terminated and resources are
890+ * asynchronously removed. In addition, users will no longer see permanently deleted clusters in
891+ * the cluster list, and API users can no longer perform any action on permanently deleted
892+ * clusters.
893+ * An example request:
894+ *
895+ * .. code::
896+ *
897+ * {
898+ * "cluster_id": "1202-211320-brick1"
899+ * }
900+ */
802901 async permanentDelete (
803902 request : PermanentDeleteClusterRequest
804903 ) : Promise < PermanentDeleteClusterResponse > {
@@ -809,6 +908,18 @@ export class ClusterService {
809908 ) ) as PermanentDeleteClusterResponse ;
810909 }
811910
911+ /**
912+ * Restarts a Spark cluster given its id. If the cluster is not currently in a ``RUNNING`` state,
913+ * nothing will happen.
914+ *
915+ * An example request:
916+ *
917+ * .. code::
918+ *
919+ * {
920+ * "cluster_id": "1202-211320-brick1"
921+ * }
922+ */
812923 async restart (
813924 request : RestartClusterRequest
814925 ) : Promise < RestartClusterResponse > {
@@ -819,6 +930,19 @@ export class ClusterService {
819930 ) ) as RestartClusterResponse ;
820931 }
821932
933+ /**
934+ * Resizes a cluster to have a desired number of workers. This will fail unless the cluster
935+ * is in a ``RUNNING`` state.
936+ *
937+ * An example request:
938+ *
939+ * .. code::
940+ *
941+ * {
942+ * "cluster_id": "1202-211320-brick1",
943+ * "num_workers": 30
944+ * }
945+ */
822946 async resize (
823947 request : ResizeClusterRequest
824948 ) : Promise < ResizeClusterResponse > {
@@ -829,6 +953,29 @@ export class ClusterService {
829953 ) ) as ResizeClusterResponse ;
830954 }
831955
956+ /**
957+ * Edits the configuration of a cluster to match the provided attributes and size.
958+ *
959+ * A cluster can be edited if it is in a ``RUNNING`` or ``TERMINATED`` state.
960+ * If a cluster is edited while in a ``RUNNING`` state, it will be restarted
961+ * so that the new attributes can take effect. If a cluster is edited while in a ``TERMINATED``
962+ * state, it will remain ``TERMINATED``. The next time it is started using the ``clusters/start``
963+ * API, the new attributes will take effect. An attempt to edit a cluster in any other state will
964+ * be rejected with an ``INVALID_STATE`` error code.
965+ *
966+ * Clusters created by the Databricks Jobs service cannot be edited.
967+ *
968+ * An example request:
969+ *
970+ * .. code::
971+ *
972+ * {
973+ * "cluster_id": "1202-211320-brick1",
974+ * "num_workers": 10,
975+ * "spark_version": "3.3.x-scala2.11",
976+ * "node_type_id": "i3.2xlarge"
977+ * }
978+ */
832979 async edit ( request : EditClusterRequest ) : Promise < EditClusterResponse > {
833980 return ( await this . client . request (
834981 "/api/2.0/clusters/edit" ,
@@ -837,6 +984,9 @@ export class ClusterService {
837984 ) ) as EditClusterResponse ;
838985 }
839986
987+ /**
988+ * Public version of editClusterOwner, allowing admins to change cluster owner
989+ */
840990 async changeClusterOwner (
841991 request : ChangeClusterOwnerRequest
842992 ) : Promise < ChangeClusterOwnerResponse > {
@@ -847,6 +997,15 @@ export class ClusterService {
847997 ) ) as ChangeClusterOwnerResponse ;
848998 }
849999
1000+ /**
1001+ * Retrieves the information for a cluster given its identifier.
1002+ * Clusters can be described while they are running, or up to 60 days after they are terminated.
1003+ *
1004+ * An example request:
1005+ *
1006+ *
1007+ * ``/clusters/get?cluster_id=1202-211320-brick1``
1008+ */
8501009 async get ( request : GetClusterRequest ) : Promise < GetClusterResponse > {
8511010 return ( await this . client . request (
8521011 "/api/2.0/clusters/get" ,
@@ -855,6 +1014,16 @@ export class ClusterService {
8551014 ) ) as GetClusterResponse ;
8561015 }
8571016
1017+ /**
1018+ * Pinning a cluster ensures that the cluster will always be returned by the ListClusters API.
1019+ * Pinning a cluster that is already pinned will have no effect.
1020+ * This API can only be called by workspace admins.
1021+ *
1022+ * An example request:
1023+ *
1024+ *
1025+ * ``/clusters/pin?cluster_id=1202-211320-brick1``
1026+ */
8581027 async pin ( request : PinClusterRequest ) : Promise < PinClusterResponse > {
8591028 return ( await this . client . request (
8601029 "/api/2.0/clusters/pin" ,
@@ -863,6 +1032,16 @@ export class ClusterService {
8631032 ) ) as PinClusterResponse ;
8641033 }
8651034
1035+ /**
1036+ * Unpinning a cluster will allow the cluster to eventually be removed from the ListClusters API.
1037+ * Unpinning a cluster that is not pinned will have no effect.
1038+ * This API can only be called by workspace admins.
1039+ *
1040+ * An example request:
1041+ *
1042+ *
1043+ * ``/clusters/unpin?cluster_id=1202-211320-brick1``
1044+ */
8661045 async unpin ( request : UnpinClusterRequest ) : Promise < UnpinClusterResponse > {
8671046 return ( await this . client . request (
8681047 "/api/2.0/clusters/unpin" ,
@@ -871,6 +1050,9 @@ export class ClusterService {
8711050 ) ) as UnpinClusterResponse ;
8721051 }
8731052
1053+ /**
1054+ * Returns a list of supported Spark node types. These node types can be used to launch a cluster.
1055+ */
8741056 async listNodeTypes (
8751057 request : ListNodeTypesRequest
8761058 ) : Promise < ListNodeTypesResponse > {
@@ -881,6 +1063,10 @@ export class ClusterService {
8811063 ) ) as ListNodeTypesResponse ;
8821064 }
8831065
1066+ /**
1067+ * Returns a list of availability zones where clusters can be created in (ex: us-west-2a).
1068+ * These zones can be used to launch a cluster.
1069+ */
8841070 async listAvailableZones (
8851071 request : ListAvailableZonesRequest
8861072 ) : Promise < ListAvailableZonesResponse > {
@@ -891,6 +1077,54 @@ export class ClusterService {
8911077 ) ) as ListAvailableZonesResponse ;
8921078 }
8931079
1080+ /**
1081+ * Retrieves a list of events about the activity of a cluster.
1082+ * This API is paginated. If there are more events to read, the response includes all the
1083+ * parameters necessary to request the next page of events.
1084+ *
1085+ * An example request:
1086+ *
1087+ * ``/clusters/events?cluster_id=1202-211320-brick1``
1088+ *
1089+ * An example response:
1090+ *
1091+ * {
1092+ * "events": [
1093+ * {
1094+ * "cluster_id": "1202-211320-brick1",
1095+ * "timestamp": 1509572145487,
1096+ * "event_type": "RESTARTING",
1097+ * "event_details": {
1098+ * "username": "admin"
1099+ * }
1100+ * },
1101+ * ...
1102+ * {
1103+ * "cluster_id": "1202-211320-brick1",
1104+ * "timestamp": 1509505807923,
1105+ * "event_type": "TERMINATING",
1106+ * "event_details": {
1107+ * "termination_reason": {
1108+ * "code": "USER_REQUEST",
1109+ * "parameters": [
1110+ * "username": "admin"
1111+ * ]
1112+ * }
1113+ * }
1114+ * ],
1115+ * "next_page": {
1116+ * "cluster_id": "1202-211320-brick1",
1117+ * "end_time": 1509572145487,
1118+ * "order": "DESC",
1119+ * "offset": 50
1120+ * },
1121+ * "total_count": 303
1122+ * }
1123+ *
1124+ * Example request to retrieve the next page of events
1125+ *
1126+ * ``/clusters/events?cluster_id=1202-211320-brick1&end_time=1509572145487&order=DESC&offset=50``
1127+ */
8941128 async getEvents ( request : GetEventsRequest ) : Promise < GetEventsResponse > {
8951129 return ( await this . client . request (
8961130 "/api/2.0/clusters/events" ,
0 commit comments