Build API: Add update sdk endpoint.

BUG=chromium:904938
TEST=run_tests, new tests

Change-Id: Ibf3a89a9a21a1756604c9bdc256efde1d1329946
Reviewed-on: https://chromium-review.googlesource.com/1495726
Commit-Ready: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Lann Martin <lannm@chromium.org>
diff --git a/api/controller/sdk.py b/api/controller/sdk.py
index 880da60..25ec2bf 100644
--- a/api/controller/sdk.py
+++ b/api/controller/sdk.py
@@ -44,3 +44,25 @@
     # This should be very rare, if ever used, but worth noting.
     cros_build_lib.Die('No chroot version could be found. There was likely an'
                        'error creating the chroot that was not detected.')
+
+
+def Update(input_proto, output_proto):
+  """Update the chroot.
+
+  Args:
+    input_proto (UpdateRequest): The input proto.
+    output_proto (UpdateResponse): The output proto.
+  """
+  build_source = input_proto.flags.build_source
+  targets = [target.name for target in input_proto.toolchain_targets]
+
+  args = sdk.UpdateArguments(build_source=build_source,
+                             toolchain_targets=targets)
+  version = sdk.Update(args)
+
+  if version:
+    output_proto.version.version = version
+  else:
+    # This should be very rare, if ever used, but worth noting.
+    cros_build_lib.Die('No chroot version could be found. There was likely an'
+                       'error creating the chroot that was not detected.')