Beispiel #1
0
    def get_file_systems(
            self, auth_header: str
    ) -> Dict[str, "product_datasets_BackingFileSystem"]:
        """
        Returns a mapping from file system id to backing file system configuration.
        """

        _headers: Dict[str, Any] = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }

        _params: Dict[str, Any] = {}

        _path_params: Dict[str, Any] = {}

        _json: Any = None

        _path = '/catalog/fileSystems'
        _path = _path.format(**_path_params)

        _response: Response = self._request('GET',
                                            self._uri + _path,
                                            params=_params,
                                            headers=_headers,
                                            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(),
                               Dict[str, product_datasets_BackingFileSystem])
Beispiel #2
0
    def resolve_branch(self, auth_header: str, branch: str,
                       dataset_rid: str) -> Optional[str]:

        _headers: Dict[str, Any] = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }

        _params: Dict[str, Any] = {}

        _path_params: Dict[str, Any] = {
            'datasetRid': dataset_rid,
            'branch': branch,
        }

        _json: Any = None

        _path = '/catalog/datasets/{datasetRid}/branches/{branch}/resolve'
        _path = _path.format(**_path_params)

        _response: Response = self._request('GET',
                                            self._uri + _path,
                                            params=_params,
                                            headers=_headers,
                                            json=_json)

        _decoder = ConjureDecoder()
        return None if _response.status_code == 204 else _decoder.decode(
            _response.json(), OptionalTypeWrapper[str])
Beispiel #3
0
    def get_branches(self,
                     auth_header: str,
                     dataset_rid: str,
                     message: Optional[str] = None,
                     page_size: Optional[int] = None) -> List[str]:

        _headers: Dict[str, Any] = {
            'Accept': 'application/json',
            'Authorization': auth_header,
            'Special-Message': message,
        }

        _params: Dict[str, Any] = {
            'pageSize': page_size,
        }

        _path_params: Dict[str, Any] = {
            'datasetRid': dataset_rid,
        }

        _json: Any = None

        _path = '/catalog/datasets/{datasetRid}/branches'
        _path = _path.format(**_path_params)

        _response: Response = self._request('GET',
                                            self._uri + _path,
                                            params=_params,
                                            headers=_headers,
                                            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), List[str])
Beispiel #4
0
    def get_branches_deprecated(self, auth_header: str,
                                dataset_rid: str) -> List[str]:
        """
        Gets all branches of this dataset.
        """

        _headers: Dict[str, Any] = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }

        _params: Dict[str, Any] = {}

        _path_params: Dict[str, Any] = {
            'datasetRid': dataset_rid,
        }

        _json: Any = None

        _path = '/catalog/datasets/{datasetRid}/branchesDeprecated'
        _path = _path.format(**_path_params)

        _response: Response = self._request('GET',
                                            self._uri + _path,
                                            params=_params,
                                            headers=_headers,
                                            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), List[str])
Beispiel #5
0
    def get_dataset(self, auth_header, dataset_rid):
        # type: (str, str) -> Optional[Dataset]

        _headers = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }  # type: Dict[str, Any]

        _params = {}  # type: Dict[str, Any]

        _path_params = {
            'datasetRid': dataset_rid,
        }  # type: Dict[str, Any]

        _json = None  # type: Any

        _path = '/catalog/datasets/{datasetRid}'
        _path = _path.format(**_path_params)

        _response = self._request(  # type: ignore
            'GET',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return None if _response.status_code == 204 else _decoder.decode(
            _response.json(), OptionalType(Dataset))
Beispiel #6
0
    def get_file_systems(self, auth_header):
        # type: (str) -> Dict[str, BackingFileSystem]
        """Returns a mapping from file system id to backing file system configuration."""

        _headers = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }  # type: Dict[str, Any]

        _params = {}  # type: Dict[str, Any]

        _path_params = {}  # type: Dict[str, Any]

        _json = None  # type: Any

        _path = '/catalog/fileSystems'
        _path = _path.format(**_path_params)

        _response = self._request(  # type: ignore
            'GET',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(),
                               DictType(str, BackingFileSystem))
Beispiel #7
0
    def test_integer(self, auth_header):
        # type: (str) -> int

        _headers = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }  # type: Dict[str, Any]

        _params = {}  # type: Dict[str, Any]

        _path_params = {}  # type: Dict[str, Any]

        _json = None  # type: Any

        _path = '/catalog/integer'
        _path = _path.format(**_path_params)

        _response = self._request(  # type: ignore
            'GET',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), int)
Beispiel #8
0
    def create_dataset(self, auth_header, request, test_header_arg):
        # type: (str, CreateDatasetRequest, str) -> Dataset

        _headers = {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'Authorization': auth_header,
            'Test-Header': test_header_arg,
        }  # type: Dict[str, Any]

        _params = {}  # type: Dict[str, Any]

        _path_params = {}  # type: Dict[str, Any]

        _json = ConjureEncoder().default(request)  # type: Any

        _path = '/catalog/datasets'
        _path = _path.format(**_path_params)

        _response = self._request(  # type: ignore
            'POST',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), Dataset)
Beispiel #9
0
    def test_query_params(self, auth_header, implicit, something):
        # type: (str, str, str) -> int

        _headers = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }  # type: Dict[str, Any]

        _params = {
            'different': something,
            'implicit': implicit,
        }  # type: Dict[str, Any]

        _path_params = {}  # type: Dict[str, Any]

        _json = None  # type: Any

        _path = '/catalog/test-query-params'
        _path = _path.format(**_path_params)

        _response = self._request(  # type: ignore
            'GET',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), int)
Beispiel #10
0
    def test_query_params(self, auth_header: str, implicit: str,
                          something: str) -> int:

        _headers: Dict[str, Any] = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }

        _params: Dict[str, Any] = {
            'different': something,
            'implicit': implicit,
        }

        _path_params: Dict[str, Any] = {}

        _json: Any = None

        _path = '/catalog/test-query-params'
        _path = _path.format(**_path_params)

        _response: Response = self._request('GET',
                                            self._uri + _path,
                                            params=_params,
                                            headers=_headers,
                                            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), int)
Beispiel #11
0
    def get_dataset(self, auth_header: str,
                    dataset_rid: str) -> Optional["product_datasets_Dataset"]:

        _headers: Dict[str, Any] = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }

        _params: Dict[str, Any] = {}

        _path_params: Dict[str, Any] = {
            'datasetRid': dataset_rid,
        }

        _json: Any = None

        _path = '/catalog/datasets/{datasetRid}'
        _path = _path.format(**_path_params)

        _response: Response = self._request('GET',
                                            self._uri + _path,
                                            params=_params,
                                            headers=_headers,
                                            json=_json)

        _decoder = ConjureDecoder()
        return None if _response.status_code == 204 else _decoder.decode(
            _response.json(), OptionalTypeWrapper[product_datasets_Dataset])
Beispiel #12
0
    def get_branches(self,
                     auth_header,
                     dataset_rid,
                     message=None,
                     page_size=None):
        # type: (str, str, Optional[str], Optional[int]) -> List[str]

        _headers = {
            'Accept': 'application/json',
            'Authorization': auth_header,
            'Special-Message': message,
        }  # type: Dict[str, Any]

        _params = {
            'pageSize': page_size,
        }  # type: Dict[str, Any]

        _path_params = {
            'datasetRid': dataset_rid,
        }  # type: Dict[str, Any]

        _json = None  # type: Any

        _path = '/catalog/datasets/{datasetRid}/branches'
        _path = _path.format(**_path_params)

        _response = self._request(  # type: ignore
            'GET',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), ListType(str))
Beispiel #13
0
    def get_branches_deprecated(self, auth_header, dataset_rid):
        # type: (str, str) -> List[str]
        """Gets all branches of this dataset."""

        _headers = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }  # type: Dict[str, Any]

        _params = {}  # type: Dict[str, Any]

        _path_params = {
            'datasetRid': dataset_rid,
        }  # type: Dict[str, Any]

        _json = None  # type: Any

        _path = '/catalog/datasets/{datasetRid}/branchesDeprecated'
        _path = _path.format(**_path_params)

        _response = self._request(  # type: ignore
            'GET',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), ListType(str))
Beispiel #14
0
    def test_endpoint(self, string):
        # type: (str) -> str

        _headers = {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        }  # type: Dict[str, Any]

        _params = {}  # type: Dict[str, Any]

        _path_params = {}  # type: Dict[str, Any]

        _json = ConjureEncoder().default(string)  # type: Any

        _path = '/catalog/testEndpoint'
        _path = _path.format(**_path_params)

        _response = self._request(  # type: ignore
            'POST',
            self._uri + _path,
            params=_params,
            headers=_headers,
            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), str)
Beispiel #15
0
    def create_dataset(self, auth_header: str,
                       request: "product_CreateDatasetRequest",
                       test_header_arg: str) -> "product_datasets_Dataset":

        _headers: Dict[str, Any] = {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'Authorization': auth_header,
            'Test-Header': test_header_arg,
        }

        _params: Dict[str, Any] = {}

        _path_params: Dict[str, Any] = {}

        _json: Any = ConjureEncoder().default(request)

        _path = '/catalog/datasets'
        _path = _path.format(**_path_params)

        _response: Response = self._request('POST',
                                            self._uri + _path,
                                            params=_params,
                                            headers=_headers,
                                            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), product_datasets_Dataset)
Beispiel #16
0
    def test_integer(self, auth_header: str) -> int:

        _headers: Dict[str, Any] = {
            'Accept': 'application/json',
            'Authorization': auth_header,
        }

        _params: Dict[str, Any] = {}

        _path_params: Dict[str, Any] = {}

        _json: Any = None

        _path = '/catalog/integer'
        _path = _path.format(**_path_params)

        _response: Response = self._request('GET',
                                            self._uri + _path,
                                            params=_params,
                                            headers=_headers,
                                            json=_json)

        _decoder = ConjureDecoder()
        return _decoder.decode(_response.json(), int)
def test_list_with_no_items_decodes():
    decoded = ConjureDecoder().read_from_string("[]", ListType(int))
    assert type(decoded) is list
def test_list_with_one_badly_typed_item_fails():
    with pytest.raises(Exception):
        ConjureDecoder().read_from_string("""[1,"two",3]""", ListType(int))
def test_list_with_well_typed_items_decodes():
    decoded = ConjureDecoder().read_from_string("[1,2,3]", ListType(int))
    assert type(decoded) is list
    assert type(decoded[0]) is int
def test_nan_float_decodes():
    decoded = ConjureDecoder.decode_primitive("NaN", float)
    assert type(decoded) is float
def test_int_float_decodes():
    decoded = ConjureDecoder.decode_primitive(1, float)
    assert type(decoded) is float
Beispiel #22
0
def test_object_with_null_field_fails():
    with pytest.raises(Exception):
        ConjureDecoder().read_from_string(
            """{"fileSystemId": null, "path": "bar"}""", CreateDatasetRequest)
Beispiel #23
0
def test_object_with_wrong_type_field_fails():
    with pytest.raises(Exception):
        ConjureDecoder().read_from_string(
            """{"fileSystemId": "foo", "path": 999}""", CreateDatasetRequest)
Beispiel #24
0
def test_object_with_missing_field_should_throw_helpful_exception():
    with pytest.raises(Exception) as excinfo:
        ConjureDecoder().read_from_string(
            """{"path": "bar", "redundant": 1}""", CreateDatasetRequest)
    message_regex = re.compile("field fileSystemId not found in object {.+}")
    assert message_regex.match(str(excinfo.value)), excinfo.value
Beispiel #25
0
def test_object_with_omitted_map_field_decodes():
    decoded = ConjureDecoder().read_from_string('{}', MapExample)
    assert decoded == MapExample({})
Beispiel #26
0
def test_object_with_omitted_list_field_decodes():
    decoded = ConjureDecoder().read_from_string('{}', ListExample)
    assert decoded == ListExample([])
Beispiel #27
0
def test_object_with_extra_fields_should_only_keep_expected_fields():
    decoded = ConjureDecoder().read_from_string(
        """{"fileSystemId": "foo", "path": "bar", "redundant": 1}""",
        CreateDatasetRequest,
    )
    assert decoded == CreateDatasetRequest("foo", "bar")
def test_list_from_json_object_fails():
    with pytest.raises(Exception):
        ConjureDecoder().read_from_string("{}", ListType(int))
def test_list_does_not_decode_from_json_string():
    with pytest.raises(Exception):
        ConjureDecoder().read_from_string("\"hello\"", ListType(int))
Beispiel #30
0
def test_object_decodes_when_exact_fields_are_present():
    decoded = ConjureDecoder().read_from_string(
        """{"fileSystemId": "foo", "path": "bar"}""", CreateDatasetRequest)
    assert decoded == CreateDatasetRequest("foo", "bar")