|
37 | 37 | build_jobs_delete_bulk_jobs_request,
|
38 | 38 | build_jobs_get_job_status_bulk_request,
|
39 | 39 | build_jobs_get_job_status_history_bulk_request,
|
| 40 | + build_jobs_get_sandbox_file_request, |
40 | 41 | build_jobs_get_single_job_request,
|
41 | 42 | build_jobs_get_single_job_status_history_request,
|
42 | 43 | build_jobs_get_single_job_status_request,
|
| 44 | + build_jobs_initiate_sandbox_upload_request, |
43 | 45 | build_jobs_kill_bulk_jobs_request,
|
44 | 46 | build_jobs_search_request,
|
45 | 47 | build_jobs_set_job_status_bulk_request,
|
@@ -819,6 +821,198 @@ def __init__(self, *args, **kwargs) -> None:
|
819 | 821 | input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
820 | 822 | )
|
821 | 823 |
|
| 824 | + @overload |
| 825 | + async def initiate_sandbox_upload( |
| 826 | + self, |
| 827 | + body: _models.SandboxInfo, |
| 828 | + *, |
| 829 | + content_type: str = "application/json", |
| 830 | + **kwargs: Any |
| 831 | + ) -> _models.SandboxUploadResponse: |
| 832 | + """Initiate Sandbox Upload. |
| 833 | +
|
| 834 | + Get the PFN for the given sandbox, initiate an upload as required. |
| 835 | +
|
| 836 | + If the sandbox already exists in the database then the PFN is returned |
| 837 | + and there is no "url" field in the response. |
| 838 | +
|
| 839 | + If the sandbox does not exist in the database then the "url" and "fields" |
| 840 | + should be used to upload the sandbox to the storage backend. |
| 841 | +
|
| 842 | + :param body: Required. |
| 843 | + :type body: ~client.models.SandboxInfo |
| 844 | + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. |
| 845 | + Default value is "application/json". |
| 846 | + :paramtype content_type: str |
| 847 | + :return: SandboxUploadResponse |
| 848 | + :rtype: ~client.models.SandboxUploadResponse |
| 849 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 850 | + """ |
| 851 | + |
| 852 | + @overload |
| 853 | + async def initiate_sandbox_upload( |
| 854 | + self, body: IO, *, content_type: str = "application/json", **kwargs: Any |
| 855 | + ) -> _models.SandboxUploadResponse: |
| 856 | + """Initiate Sandbox Upload. |
| 857 | +
|
| 858 | + Get the PFN for the given sandbox, initiate an upload as required. |
| 859 | +
|
| 860 | + If the sandbox already exists in the database then the PFN is returned |
| 861 | + and there is no "url" field in the response. |
| 862 | +
|
| 863 | + If the sandbox does not exist in the database then the "url" and "fields" |
| 864 | + should be used to upload the sandbox to the storage backend. |
| 865 | +
|
| 866 | + :param body: Required. |
| 867 | + :type body: IO |
| 868 | + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. |
| 869 | + Default value is "application/json". |
| 870 | + :paramtype content_type: str |
| 871 | + :return: SandboxUploadResponse |
| 872 | + :rtype: ~client.models.SandboxUploadResponse |
| 873 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 874 | + """ |
| 875 | + |
| 876 | + @distributed_trace_async |
| 877 | + async def initiate_sandbox_upload( |
| 878 | + self, body: Union[_models.SandboxInfo, IO], **kwargs: Any |
| 879 | + ) -> _models.SandboxUploadResponse: |
| 880 | + """Initiate Sandbox Upload. |
| 881 | +
|
| 882 | + Get the PFN for the given sandbox, initiate an upload as required. |
| 883 | +
|
| 884 | + If the sandbox already exists in the database then the PFN is returned |
| 885 | + and there is no "url" field in the response. |
| 886 | +
|
| 887 | + If the sandbox does not exist in the database then the "url" and "fields" |
| 888 | + should be used to upload the sandbox to the storage backend. |
| 889 | +
|
| 890 | + :param body: Is either a SandboxInfo type or a IO type. Required. |
| 891 | + :type body: ~client.models.SandboxInfo or IO |
| 892 | + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. |
| 893 | + Default value is None. |
| 894 | + :paramtype content_type: str |
| 895 | + :return: SandboxUploadResponse |
| 896 | + :rtype: ~client.models.SandboxUploadResponse |
| 897 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 898 | + """ |
| 899 | + error_map = { |
| 900 | + 401: ClientAuthenticationError, |
| 901 | + 404: ResourceNotFoundError, |
| 902 | + 409: ResourceExistsError, |
| 903 | + 304: ResourceNotModifiedError, |
| 904 | + } |
| 905 | + error_map.update(kwargs.pop("error_map", {}) or {}) |
| 906 | + |
| 907 | + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) |
| 908 | + _params = kwargs.pop("params", {}) or {} |
| 909 | + |
| 910 | + content_type: Optional[str] = kwargs.pop( |
| 911 | + "content_type", _headers.pop("Content-Type", None) |
| 912 | + ) |
| 913 | + cls: ClsType[_models.SandboxUploadResponse] = kwargs.pop("cls", None) |
| 914 | + |
| 915 | + content_type = content_type or "application/json" |
| 916 | + _json = None |
| 917 | + _content = None |
| 918 | + if isinstance(body, (IOBase, bytes)): |
| 919 | + _content = body |
| 920 | + else: |
| 921 | + _json = self._serialize.body(body, "SandboxInfo") |
| 922 | + |
| 923 | + request = build_jobs_initiate_sandbox_upload_request( |
| 924 | + content_type=content_type, |
| 925 | + json=_json, |
| 926 | + content=_content, |
| 927 | + headers=_headers, |
| 928 | + params=_params, |
| 929 | + ) |
| 930 | + request.url = self._client.format_url(request.url) |
| 931 | + |
| 932 | + _stream = False |
| 933 | + pipeline_response: PipelineResponse = ( |
| 934 | + await self._client._pipeline.run( # pylint: disable=protected-access |
| 935 | + request, stream=_stream, **kwargs |
| 936 | + ) |
| 937 | + ) |
| 938 | + |
| 939 | + response = pipeline_response.http_response |
| 940 | + |
| 941 | + if response.status_code not in [200]: |
| 942 | + map_error( |
| 943 | + status_code=response.status_code, response=response, error_map=error_map |
| 944 | + ) |
| 945 | + raise HttpResponseError(response=response) |
| 946 | + |
| 947 | + deserialized = self._deserialize("SandboxUploadResponse", pipeline_response) |
| 948 | + |
| 949 | + if cls: |
| 950 | + return cls(pipeline_response, deserialized, {}) |
| 951 | + |
| 952 | + return deserialized |
| 953 | + |
| 954 | + @distributed_trace_async |
| 955 | + async def get_sandbox_file( |
| 956 | + self, file_path: str, **kwargs: Any |
| 957 | + ) -> _models.SandboxDownloadResponse: |
| 958 | + """Get Sandbox File. |
| 959 | +
|
| 960 | + Get a presigned URL to download a sandbox file |
| 961 | +
|
| 962 | + This route cannot use a redirect response most clients will also send the |
| 963 | + authorization header when following a redirect. This is not desirable as |
| 964 | + it would leak the authorization token to the storage backend. Additionally, |
| 965 | + most storage backends return an error when they receive an authorization |
| 966 | + header for a presigned URL. |
| 967 | +
|
| 968 | + :param file_path: Required. |
| 969 | + :type file_path: str |
| 970 | + :return: SandboxDownloadResponse |
| 971 | + :rtype: ~client.models.SandboxDownloadResponse |
| 972 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 973 | + """ |
| 974 | + error_map = { |
| 975 | + 401: ClientAuthenticationError, |
| 976 | + 404: ResourceNotFoundError, |
| 977 | + 409: ResourceExistsError, |
| 978 | + 304: ResourceNotModifiedError, |
| 979 | + } |
| 980 | + error_map.update(kwargs.pop("error_map", {}) or {}) |
| 981 | + |
| 982 | + _headers = kwargs.pop("headers", {}) or {} |
| 983 | + _params = kwargs.pop("params", {}) or {} |
| 984 | + |
| 985 | + cls: ClsType[_models.SandboxDownloadResponse] = kwargs.pop("cls", None) |
| 986 | + |
| 987 | + request = build_jobs_get_sandbox_file_request( |
| 988 | + file_path=file_path, |
| 989 | + headers=_headers, |
| 990 | + params=_params, |
| 991 | + ) |
| 992 | + request.url = self._client.format_url(request.url) |
| 993 | + |
| 994 | + _stream = False |
| 995 | + pipeline_response: PipelineResponse = ( |
| 996 | + await self._client._pipeline.run( # pylint: disable=protected-access |
| 997 | + request, stream=_stream, **kwargs |
| 998 | + ) |
| 999 | + ) |
| 1000 | + |
| 1001 | + response = pipeline_response.http_response |
| 1002 | + |
| 1003 | + if response.status_code not in [200]: |
| 1004 | + map_error( |
| 1005 | + status_code=response.status_code, response=response, error_map=error_map |
| 1006 | + ) |
| 1007 | + raise HttpResponseError(response=response) |
| 1008 | + |
| 1009 | + deserialized = self._deserialize("SandboxDownloadResponse", pipeline_response) |
| 1010 | + |
| 1011 | + if cls: |
| 1012 | + return cls(pipeline_response, deserialized, {}) |
| 1013 | + |
| 1014 | + return deserialized |
| 1015 | + |
822 | 1016 | @overload
|
823 | 1017 | async def submit_bulk_jobs(
|
824 | 1018 | self, body: List[str], *, content_type: str = "application/json", **kwargs: Any
|
|
0 commit comments