diff --git a/python-shell/README.md b/python-shell/README.md index d14e982dd..2c407a707 100644 --- a/python-shell/README.md +++ b/python-shell/README.md @@ -40,7 +40,7 @@ from gafferpy import gaffer as g from gafferpy import gaffer_connector # Instantiate a connector -gc = gaffer_connector.GafferConnector("http://localhost:8080/rest/latest") +gc = gaffer_connector.GafferConnector("http://localhost:8080/rest") # You can use the connector to perform get requests schema = gc.execute_get(g.GetSchema()) diff --git a/python-shell/src/examples/Gaffer-Python-Demo.ipynb b/python-shell/src/examples/Gaffer-Python-Demo.ipynb index 16910ad31..2c511016c 100644 --- a/python-shell/src/examples/Gaffer-Python-Demo.ipynb +++ b/python-shell/src/examples/Gaffer-Python-Demo.ipynb @@ -32,7 +32,7 @@ "metadata": {}, "outputs": [], "source": [ - "host = \"http://localhost:8080/rest/latest\"" + "host = \"http://localhost:8080/rest\"" ] }, { diff --git a/python-shell/src/examples/example.py b/python-shell/src/examples/example.py index f3a195a5f..0d4eea440 100755 --- a/python-shell/src/examples/example.py +++ b/python-shell/src/examples/example.py @@ -391,7 +391,7 @@ def generate_domain_objects_chain(gc): [ g.GetElements( input=[g.EntitySeed(vertex='M5')], - seed_matching_type=g.SeedMatchingType.RELATED, + #seed_matching=g.SeedMatchingType.RELATED, view=g.View( edges=[ g.ElementDefinition( @@ -960,4 +960,4 @@ def op_chain_in_json(gc): if __name__ == "__main__": - run('http://localhost:8080/rest/latest', False) + run('http://localhost:8080/rest', False) diff --git a/python-shell/src/examples/example_map.py b/python-shell/src/examples/example_map.py index 9f8c400d6..badb73be2 100644 --- a/python-shell/src/examples/example_map.py +++ b/python-shell/src/examples/example_map.py @@ -45,4 +45,4 @@ def count_all_elements_default_view(gc): print() if __name__ == "__main__": - run('http://localhost:8080/rest/latest', False) + run('http://localhost:8080/rest', False) diff --git a/python-shell/src/fishbowl/README.md b/python-shell/src/fishbowl/README.md index f904b27b6..3ddfcca4d 100644 --- a/python-shell/src/fishbowl/README.md +++ b/python-shell/src/fishbowl/README.md @@ -34,7 +34,7 @@ Things it should do: from fishbowl.connector import GafferConnector from fishbowl.fishbowl import Fishbowl -fb = Fishbowl(gaffer_connector=GafferConnector(host="http://localhost:8080/rest/latest")) +fb = Fishbowl(gaffer_connector=GafferConnector(host="http://localhost:8080/rest")) ``` Your python files will be appear in a folder called `generated` They can be imported using the following command: diff --git a/python-shell/src/fishbowl/fishbowl.py b/python-shell/src/fishbowl/fishbowl.py index 23778fc87..7a19de2df 100644 --- a/python-shell/src/fishbowl/fishbowl.py +++ b/python-shell/src/fishbowl/fishbowl.py @@ -11,7 +11,7 @@ def __init__(self, gaffer_connector, generated_directory_path="generated"): self._gaffer_connector = gaffer_connector self.generated_directory_path = generated_directory_path print("Generating python Library from REST service") - self.__generate_library() + self._generate_library() print("done") print("To import operations, predicates and functions, use the following command:") print("from " + generated_directory_path + " import *") @@ -20,7 +20,7 @@ def _write_to_file(self, file_path, data): with open(file_path, "w+") as file: file.write(data) - def __generate_library(self): + def _generate_library(self): if os.path.exists(self.generated_directory_path): shutil.rmtree(self.generated_directory_path) @@ -86,7 +86,11 @@ def _generate_functions(self, path, import_path, base_class): return "\n".join(functions_python) def _generate_operations(self): - operation_summaries = self._gaffer_connector.get("/graph/operations/details", json_result=True) + # Gaffer 2 spring-rest has an endpoint for every store operation, even ones unsupported by the store + try: + operation_summaries = self._gaffer_connector.get("/graph/operations/details/all", json_result=True) + except ConnectionError: + operation_summaries = self._gaffer_connector.get("/graph/operations/details", json_result=True) operations_python = ["from gafferpy.gaffer_operations import Operation\n\n"] diff --git a/python-shell/src/gafferpy/gaffer_config.py b/python-shell/src/gafferpy/gaffer_config.py index d36df5681..d27e371b8 100755 --- a/python-shell/src/gafferpy/gaffer_config.py +++ b/python-shell/src/gafferpy/gaffer_config.py @@ -30,30 +30,9 @@ def get_url(self): return self._url -class GetSchema(gaffer_operations.Operation, GetGraph): - CLASS = 'uk.gov.gchq.gaffer.store.operation.GetSchema' - - def __init__(self, - compact=None, - options=None): - super().__init__(_class_name=self.CLASS, - options=options) - - if compact is not None: - self.compact = compact - else: - self.compact = False - - self._url = '/graph/config/schema' - - def to_json(self): - operation = super().to_json() - - if self.compact is not None: - operation['compact'] = self.compact - - return operation - +class GetSchema(GetGraph): + def __init__(self): + super().__init__('/graph/config/schema') class GetFilterFunctions(GetGraph): def __init__(self): @@ -84,6 +63,10 @@ class GetOperations(GetGraph): def __init__(self): super().__init__('/graph/operations') +class GetAllOperationDetails(GetGraph): + def __init__(self): + super().__init__('/graph/operations/details/all') + class GetSerialisedFields(GetGraph): def __init__(self, class_name=None): diff --git a/python-shell/src/gafferpy/gaffer_operations.py b/python-shell/src/gafferpy/gaffer_operations.py index d4378d7f4..04ac001e7 100755 --- a/python-shell/src/gafferpy/gaffer_operations.py +++ b/python-shell/src/gafferpy/gaffer_operations.py @@ -571,11 +571,11 @@ def to_json(self): if self.options is not None: operation['options'] = self.options if self.view is not None: - operation['view'] = self.view.to_json() + operation['view'] = ToJson.recursive_to_json(self.view) if self.views is not None: operation['views'] = [] for view in self.views: - operation['views'].append(view.to_json()) + operation['views'].append(ToJson.recursive_to_json(view)) return operation @@ -644,1975 +644,6 @@ def to_json(self): return match_json -#### Generated: -class OperationChain(Operation): - CLASS = "uk.gov.gchq.gaffer.operation.OperationChain" - - def __init__(self, operations, options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - self._class_name = self.CLASS - self.operations = operations - - def to_json(self): - operation_chain_json = super().to_json() - operations_json = [] - for operation in self.operations: - if isinstance(operation, ToJson): - operations_json.append(operation.to_json()) - else: - operations_json.append(operation) - operation_chain_json['operations'] = operations_json - return operation_chain_json - - -class OperationChainDAO(OperationChain): - CLASS = "uk.gov.gchq.gaffer.operation.OperationChainDAO" - - def __init__(self, operations, - options=None): - super().__init__(operations=operations, options=options) - - def to_json(self): - operation_chain_json = super().to_json() - operation_chain_json.pop('class', None) - return operation_chain_json - - -class GetTraits(Operation): - CLASS = 'uk.gov.gchq.gaffer.store.operation.GetTraits' - - def __init__(self, - current_traits=True, - options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - self.current_traits = current_traits - - def to_json(self): - operation = super().to_json() - - operation['currentTraits'] = self.current_traits - return operation - -class HasTrait(Operation): - CLASS = 'uk.gov.gchq.gaffer.store.operation.HasTrait' - - def __init__(self, - trait, - current_traits=True, - options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - self.trait = trait - self.current_traits = current_traits - - def to_json(self): - operation = super().to_json() - - operation['trait'] = self.trait - operation['currentTraits'] = self.current_traits - return operation - - -class AddElements(Operation): - """ - This class defines a Gaffer Add Operation. - """ - - CLASS = 'uk.gov.gchq.gaffer.operation.impl.add.AddElements' - - def __init__(self, - input=None, - skip_invalid_elements=None, - validate=None, - options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - self.input = input - self.skip_invalid_elements = skip_invalid_elements - self.validate = validate - - def to_json(self): - operation = super().to_json() - if self.skip_invalid_elements is not None: - operation['skipInvalidElements'] = self.skip_invalid_elements - if self.validate is not None: - operation['validate'] = self.validate - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - return operation - - -class GenerateElements(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements' - - def __init__(self, - element_generator, - input=None, - options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - if not isinstance(element_generator, gaffer_functions.ElementGenerator): - element_generator = gaffer_functions.ElementGenerator( - element_generator['class'], - element_generator) - self.element_generator = element_generator - self.input = input - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - input_json = [] - for item in self.input: - if isinstance(item, ToJson): - input_json.append(item.to_json()) - else: - input_json.append(item) - operation['input'] = input_json - - operation['elementGenerator'] = self.element_generator.to_json() - return operation - - -class GenerateObjects(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects' - - def __init__(self, - element_generator, - input=None, - options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - if not isinstance(element_generator, gaffer_functions.ElementGenerator): - element_generator = gaffer_functions.ElementGenerator( - element_generator['class'], - element_generator) - self.element_generator = element_generator - self.input = input - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - elements_json = [] - for element in self.input: - if isinstance(element, ToJson): - elements_json.append(element.to_json()) - else: - elements_json.append(element) - operation['input'] = elements_json - - operation['elementGenerator'] = self.element_generator.to_json() - return operation - - -class Validate(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.Validate' - - def __init__(self, - validate, - skip_invalid_elements=True, - options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - self.validate = validate - self.skip_invalid_elements = skip_invalid_elements - - def to_json(self): - operation = super().to_json() - - operation['validate'] = self.validate - operation['skipInvalidElements'] = self.skip_invalid_elements - return operation - - -class ExportToGafferResultCache(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache' - - def __init__(self, - key=None, - op_auths=None, - options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - if not isinstance(key, str) and key is not None: - raise TypeError('key must be a string') - self.key = key - self.op_auths = op_auths - - def to_json(self): - operation = super().to_json() - - if self.key is not None: - operation['key'] = self.key - - if self.op_auths is not None: - operation['opAuths'] = self.op_auths - return operation - - -class GetGafferResultCacheExport(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport' - - def __init__(self, - job_id=None, - key=None, - options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.job_id = job_id - self.key = key - - def to_json(self): - operation = super().to_json() - - if self.job_id is not None: - operation['jobId'] = self.job_id - if self.key is not None: - operation['key'] = self.key - return operation - - -class ExportToSet(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet' - - def __init__(self, key=None, options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - if not isinstance(key, str) and key is not None: - raise TypeError('key must be a string') - self.key = key - - def to_json(self): - operation = super().to_json() - - if self.key is not None: - operation['key'] = self.key - - return operation - - -class GetSetExport(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport' - - def __init__(self, - job_id=None, - key=None, - start=None, - end=None, - options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.job_id = job_id - self.key = key - self.start = start - self.end = end - - def to_json(self): - operation = super().to_json() - - if self.job_id is not None: - operation['jobId'] = self.job_id - if self.key is not None: - operation['key'] = self.key - if self.start is not None: - operation['start'] = self.start - if self.end is not None: - operation['end'] = self.end - - return operation - - -class GetExports(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.export.GetExports' - - def __init__(self, - get_exports, - options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.get_exports = [] - for export in get_exports: - self.get_exports.append(JsonConverter.validate(export, Operation, False)) - - def to_json(self): - operation = super().to_json() - - operation['getExports'] = [export.to_json() for export in self.get_exports] - - return operation - - -class GetJobDetails(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails' - - def __init__(self, - job_id=None, - options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.job_id = job_id - - def to_json(self): - operation = super().to_json() - - if self.job_id is not None: - operation['jobId'] = self.job_id - - return operation - - -class GetAllJobDetails(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - - def to_json(self): - operation = super().to_json() - - return operation - - -class GetJobResults(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.job.GetJobResults' - - def __init__(self, job_id, options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.job_id = job_id - - def to_json(self): - operation = super().to_json() - operation['jobId'] = self.job_id - return operation - - -class CancelScheduledJob(Operation): - CLASS = "uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob" - - def __init__(self, job_id): - super().__init__(_class_name=self.CLASS) - self.job_id = job_id - - def to_json(self): - operation_json = super().to_json() - if self.job_id is not None: - operation_json['jobId'] = self.job_id - return operation_json - - -class SplitStoreFromFile(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile' - - def __init__(self, input_path, options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.input_path = input_path - - def to_json(self): - operation = super().to_json() - operation['inputPath'] = self.input_path - return operation - - -class SplitStoreFromIterable(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.SplitStoreFromIterable' - - def __init__(self, input=None, options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.input = input - - def to_json(self): - operation = super().to_json() - if self.input is not None: - operation['input'] = self.input - return operation - - -class SampleElementsForSplitPoints(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.SampleElementsForSplitPoints' - - def __init__(self, input=None, num_splits=None, proportion_to_sample=None, - options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.input = input - self.num_splits = num_splits - self.proportion_to_sample = proportion_to_sample - - def to_json(self): - operation = super().to_json() - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - if self.num_splits is not None: - operation['numSplits'] = self.num_splits - if self.proportion_to_sample is not None: - operation['proportionToSample'] = self.proportion_to_sample - return operation - - -class GetOperation(Operation): - def __init__(self, - _class_name, - input=None, - view=None, - directed_type=None, - include_incoming_out_going=None, - # deprecated, use seed_matching instead - seed_matching_type=None, - seed_matching=None, - options=None): - super().__init__( - _class_name=_class_name, - view=view, - options=options) - - if not isinstance(_class_name, str): - raise TypeError( - 'ClassName must be the operation class name as a string') - - self.input = input - self.directed_type = directed_type - self.include_incoming_out_going = include_incoming_out_going - self.seed_matching = seed_matching_type - if seed_matching is not None: - self.seed_matching = seed_matching - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - json_seeds = [] - if isinstance(self.input, list): - for seed in self.input: - if isinstance(seed, ElementSeed): - json_seeds.append(seed.to_json()) - else: - json_seeds.append(EntitySeed(seed).to_json()) - else: - if isinstance(self.input, ElementSeed): - json_seeds.append(self.input.to_json()) - else: - json_seeds.append(EntitySeed(self.input).to_json()) - operation['input'] = json_seeds - - if self.seed_matching is not None: - operation['seedMatching'] = self.seed_matching - if self.include_incoming_out_going is not None: - if self.directed_type is not None: - operation['directedType'] = self.directed_type - operation[ - 'includeIncomingOutGoing'] = self.include_incoming_out_going - return operation - - -class GetElements(GetOperation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.get.GetElements' - - def __init__(self, - input=None, - view=None, - directed_type=None, - include_incoming_out_going=None, - seed_matching_type=None, - # deprecated, use seed_matching instead - seed_matching=None, - options=None): - super().__init__( - _class_name=self.CLASS, - input=input, - view=view, - directed_type=directed_type, - include_incoming_out_going=include_incoming_out_going, - seed_matching_type=seed_matching_type, - seed_matching=seed_matching, - options=options) - -class GetFromEndpoint(Operation): - CLASS = "uk.gov.gchq.gaffer.operation.impl.get.GetFromEndpoint" - - def __init__(self, endpoint, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.endpoint = endpoint - - def to_json(self): - operation_json = super().to_json() - if self.endpoint is not None: - operation_json['endpoint'] = self.endpoint - - return operation_json - - -class GetAdjacentIds(GetOperation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds' - - def __init__(self, - input=None, - view=None, - include_incoming_out_going=None, - options=None): - super().__init__( - _class_name=self.CLASS, - input=input, - view=view, - directed_type=None, - include_incoming_out_going=include_incoming_out_going, - seed_matching_type=None, - seed_matching=None, - options=options) - - -class CountAllElementsDefaultView(Operation): - CLASS = "uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView" - - def __init__(self, input=None, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.input = input - - def to_json(self): - operation_json = super().to_json() - if self.input is not None: - operation_json["input"] = self.input - return operation_json - - -class GetAllElements(GetOperation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.get.GetAllElements' - - def __init__(self, - view=None, - directed_type=None, - options=None): - super().__init__( - _class_name=self.CLASS, - input=None, - view=view, - directed_type=directed_type, - include_incoming_out_going=None, - options=options) - - -class NamedOperation(GetOperation): - CLASS = 'uk.gov.gchq.gaffer.named.operation.NamedOperation' - - def __init__(self, - operation_name, - input=None, - view=None, - parameters=None, - options=None): - super().__init__( - _class_name=self.CLASS, - input=input, - view=view, - directed_type=None, - include_incoming_out_going=None, - seed_matching_type=None, - seed_matching=None, - options=options) - self.operation_name = operation_name - self.parameters = parameters - - def to_json(self): - operation = super().to_json() - operation['operationName'] = self.operation_name - if self.parameters is not None: - operation['parameters'] = self.parameters - return operation - - -class AddNamedOperation(Operation): - CLASS = 'uk.gov.gchq.gaffer.named.operation.AddNamedOperation' - - def __init__(self, - operation_chain, - operation_name, - description=None, - read_access_roles=None, - write_access_roles=None, - overwrite_flag=None, - parameters=None, - options=None, - score=None, - labels=None): - super().__init__( - _class_name=self.CLASS, - options=options) - if isinstance(operation_chain, OperationChain): - if not isinstance(operation_chain, OperationChainDAO): - operation_chain = OperationChainDAO( - operations=operation_chain.operations) - self.operation_chain = operation_chain - else: - operations = [] - ops = operation_chain - if isinstance(ops, dict): - ops = ops['operations'] - if not isinstance(ops, list): - raise TypeError('Operation chain type was not recognised') - for op in ops: - if not isinstance(op, Operation): - op = JsonConverter.from_json(op) - operations.append(op) - self.operation_chain = OperationChainDAO(operations=operations) - self.operation_name = operation_name - self.description = description - self.read_access_roles = read_access_roles - self.write_access_roles = write_access_roles - self.overwrite_flag = overwrite_flag - self.score = score - self.labels = labels - - self.parameters = None - if parameters is not None: - self.parameters = [] - if isinstance(parameters, list): - for param in parameters: - self.parameters.append( - JsonConverter.validate( - param, NamedOperationParameter, False - ) - ) - else: - for name, param in parameters.items(): - param = dict(param) - param['name'] = name - param = JsonConverter.from_json(param, - NamedOperationParameter) - self.parameters.append(param) - - def to_json(self): - operation = super().to_json() - if isinstance(self.operation_chain, OperationChain): - operation['operationChain'] = self.operation_chain.to_json() - else: - operation['operationChain'] = self.operation_chain - operation['operationName'] = self.operation_name - if self.overwrite_flag is not None: - operation['overwriteFlag'] = self.overwrite_flag - if self.description is not None: - operation['description'] = self.description - if self.read_access_roles is not None: - operation['readAccessRoles'] = self.read_access_roles - if self.write_access_roles is not None: - operation['writeAccessRoles'] = self.write_access_roles - if self.score is not None: - operation['score'] = self.score - if self.labels is not None: - operation['labels'] = self.labels - if self.parameters is not None: - operation['parameters'] = {} - for param in self.parameters: - operation['parameters'][param.name] = param.get_detail() - - return operation - - -class DeleteNamedOperation(Operation): - CLASS = 'uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation' - - def __init__(self, operation_name, options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - self.operation_name = operation_name - - def to_json(self): - operation = super().to_json() - operation['operationName'] = self.operation_name - return operation - - -class GetAllNamedOperations(Operation): - CLASS = 'uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - - -class AddNamedView(Operation): - CLASS = 'uk.gov.gchq.gaffer.named.view.AddNamedView' - - def __init__(self, - view, - name, - description=None, - overwrite_flag=None, - parameters=None, - write_access_roles=None, - options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - self.view = JsonConverter.validate(view, View) - - self.name = name - self.description = description - self.overwrite_flag = overwrite_flag - self.write_access_roles = write_access_roles - self.parameters = None - if parameters is not None: - self.parameters = [] - if isinstance(parameters, list): - for param in parameters: - self.parameters.append(JsonConverter.validate(param, NamedViewParameter, False)) - else: - for name, param in parameters.items(): - param = dict(param) - param['name'] = name - param = JsonConverter.from_json(param, - NamedViewParameter) - self.parameters.append(param) - - def to_json(self): - operation = super().to_json() - if isinstance(self.view, View): - operation['view'] = self.view.to_json() - else: - operation['view'] = self.view - operation['name'] = self.name - if self.overwrite_flag is not None: - operation['overwriteFlag'] = self.overwrite_flag - if self.description is not None: - operation['description'] = self.description - if self.parameters is not None: - operation['parameters'] = {} - for param in self.parameters: - operation['parameters'][param.name] = param.get_detail() - if self.write_access_roles is not None: - operation['writeAccessRoles'] = self.write_access_roles - return operation - - -class DeleteNamedView(Operation): - CLASS = 'uk.gov.gchq.gaffer.named.view.DeleteNamedView' - - def __init__(self, name, options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - self.name = name - - def to_json(self): - operation = super().to_json() - operation['name'] = self.name - return operation - - -class GetAllNamedViews(Operation): - CLASS = 'uk.gov.gchq.gaffer.named.view.GetAllNamedViews' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, - options=options) - - -class DiscardOutput(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.DiscardOutput' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - -class Count(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.Count' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, options=options - ) - - -class CountGroups(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.CountGroups' - - def __init__(self, limit=None, options=None): - super().__init__( - _class_name=self.CLASS, - view=None, - options=options) - self.limit = limit - - def to_json(self): - operation = super().to_json() - - if self.limit is not None: - operation['limit'] = self.limit - - return operation - - -class Limit(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.Limit' - - def __init__(self, result_limit, truncate=None, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.result_limit = result_limit - self.truncate = truncate - - def to_json(self): - operation = super().to_json() - operation['resultLimit'] = self.result_limit - if self.truncate is not None: - operation['truncate'] = self.truncate - - return operation - - -class ToSet(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToSet' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - -class ToArray(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToArray' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - -class ToEntitySeeds(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - -class ToList(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToList' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - -class ToStream(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToStream' - - def __init__(self, options=None): - super().__init__( - _class_name=self.CLASS, options=options) - - -class ToVertices(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToVertices' - - def __init__(self, edge_vertices=None, use_matched_vertex=None, - options=None): - super().__init__( - _class_name=self.CLASS, options=options) - self.edge_vertices = edge_vertices - self.use_matched_vertex = use_matched_vertex - - def to_json(self): - operation = super().to_json() - - if self.edge_vertices is not None: - operation['edgeVertices'] = self.edge_vertices - - if self.use_matched_vertex is not None: - operation['useMatchedVertex'] = self.use_matched_vertex - - return operation - - -class ToCsv(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToCsv' - - def __init__(self, - element_generator, - include_header=True, options=None): - super().__init__( - _class_name=self.CLASS, options=options - ) - self.element_generator = JsonConverter.validate(element_generator, - gaffer_functions.CsvGenerator, False) - self.include_header = include_header - - def to_json(self): - operation = super().to_json() - - operation['elementGenerator'] = self.element_generator.to_json() - operation['includeHeader'] = self.include_header - - return operation - - -class ToMap(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToMap' - - def __init__(self, - element_generator, options=None): - super().__init__( - _class_name=self.CLASS, options=options - ) - self.element_generator = JsonConverter.validate(element_generator, - gaffer_functions.MapGenerator, False) - - def to_json(self): - operation = super().to_json() - - operation['elementGenerator'] = self.element_generator.to_json() - - return operation - - -class Sort(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.compare.Sort' - - def __init__(self, comparators, - input=None, - result_limit=None, - deduplicate=None, options=None): - super().__init__( - _class_name=self.CLASS, options=options - ) - self.comparators = comparators - self.input = input - self.result_limit = result_limit - self.deduplicate = deduplicate - - def to_json(self): - operation = super().to_json() - - comparators_json = [] - for comparator in self.comparators: - if not isinstance(comparator, Comparator): - raise TypeError( - 'All comparators must be a Gaffer Comparator object') - comparators_json.append(comparator.to_json()) - operation['comparators'] = comparators_json - - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - - if self.result_limit is not None: - operation['resultLimit'] = self.result_limit - - if self.deduplicate is not None: - operation['deduplicate'] = self.deduplicate - - return operation - - -class Max(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.compare.Max' - - def __init__(self, comparators, input=None, options=None): - super().__init__( - _class_name=self.CLASS, options=options - ) - self.comparators = comparators - self.input = input - - def to_json(self): - operation = super().to_json() - - comparators_json = [] - for comparator in self.comparators: - if not isinstance(comparator, Comparator): - raise TypeError( - 'All comparators must be a Gaffer Comparator object') - comparators_json.append(comparator.to_json()) - operation['comparators'] = comparators_json - - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - - return operation - - -class Min(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.compare.Min' - - def __init__(self, comparators, input=None, options=None): - super().__init__( - _class_name=self.CLASS, options=options - ) - self.comparators = comparators - self.input = input - - def to_json(self): - operation = super().to_json() - - comparators_json = [] - for comparator in self.comparators: - if not isinstance(comparator, Comparator): - raise TypeError( - 'All comparators must be a Gaffer Comparator object') - comparators_json.append(comparator.to_json()) - operation['comparators'] = comparators_json - - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - - return operation - - -class ExportToOtherGraph(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph' - - def __init__(self, graph_id=None, input=None, parent_schema_ids=None, - schema=None, parent_store_properties_id=None, - store_properties=None, options=None): - super().__init__( - self.CLASS, options=options - ) - - self.graph_id = graph_id - self.input = input - self.parent_schema_ids = parent_schema_ids - self.schema = schema - self.parent_store_properties_id = parent_store_properties_id - self.store_properties = store_properties - - def to_json(self): - operation = super().to_json() - - if self.graph_id is not None: - operation['graphId'] = self.graph_id - - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - - if self.parent_schema_ids is not None: - operation['parentSchemaIds'] = self.parent_schema_ids - - if self.schema is not None: - operation['schema'] = self.schema - - if self.parent_store_properties_id is not None: - operation[ - 'parentStorePropertiesId'] = self.parent_store_properties_id - - if self.store_properties is not None: - operation['storeProperties'] = self.store_properties - - return operation - - -class ExportToOtherAuthorisedGraph(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph' - - def __init__(self, graph_id=None, input=None, parent_schema_ids=None, - parent_store_properties_id=None, options=None): - super().__init__( - self.CLASS, options=options - ) - - self.graph_id = graph_id - self.input = input - self.parent_schema_ids = parent_schema_ids - self.parent_store_properties_id = parent_store_properties_id - - def to_json(self): - operation = super().to_json() - - if self.graph_id is not None: - operation['graphId'] = self.graph_id - - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - - if self.parent_schema_ids is not None: - operation['parentSchemaIds'] = self.parent_schema_ids - - if self.parent_store_properties_id is not None: - operation[ - 'parentStorePropertiesId'] = self.parent_store_properties_id - - return operation - - -class AddElementsFromSocket(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket' - - def __init__(self, hostname=None, port=None, element_generator=None, - parallelism=None, validate=None, skip_invalid_elements=None, - delimiter=None, options=None): - super().__init__( - self.CLASS, - options=options - ) - - self.hostname = hostname - self.port = port - if not isinstance(element_generator, str): - raise TypeError('element_generator must be a java class name (str)') - self.element_generator = element_generator - self.parallelism = parallelism - self.validate = validate - self.skip_invalid_elements = skip_invalid_elements - self.delimiter = delimiter - - def to_json(self): - operation = super().to_json() - - if self.hostname is not None: - operation['hostname'] = self.hostname - - if self.port is not None: - operation['port'] = self.port - - if self.element_generator is not None: - operation['elementGenerator'] = self.element_generator - - if self.parallelism is not None: - operation['parallelism'] = self.parallelism - - if self.validate is not None: - operation['validate'] = self.validate - - if self.skip_invalid_elements is not None: - operation['skipInvalidElements'] = self.skip_invalid_elements - - if self.delimiter is not None: - operation['delimiter'] = self.delimiter - - return operation - - -class AddElementsFromKafka(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromKafka' - - def __init__(self, topic, group_id, bootstrap_servers, element_generator, - parallelism=None, validate=None, skip_invalid_elements=None, - options=None): - super().__init__( - self.CLASS, - options=options - ) - - self.topic = topic - self.group_id = group_id - self.bootstrap_servers = bootstrap_servers - if not isinstance(element_generator, str): - raise TypeError('element_generator must be a java class name (str)') - self.element_generator = element_generator - self.parallelism = parallelism - self.validate = validate - self.skip_invalid_elements = skip_invalid_elements - - def to_json(self): - operation = super().to_json() - - if self.topic is not None: - operation['topic'] = self.topic - - if self.group_id is not None: - operation['groupId'] = self.group_id - - if self.bootstrap_servers is not None: - operation['bootstrapServers'] = self.bootstrap_servers - - if self.element_generator is not None: - operation['elementGenerator'] = self.element_generator - - if self.parallelism is not None: - operation['parallelism'] = self.parallelism - - if self.validate is not None: - operation['validate'] = self.validate - - if self.skip_invalid_elements is not None: - operation['skipInvalidElements'] = self.skip_invalid_elements - - return operation - - -class AddElementsFromFile(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromFile' - - def __init__(self, filename=None, element_generator=None, - parallelism=None, validate=None, skip_invalid_elements=None, - options=None): - super().__init__( - self.CLASS, - options=options - ) - - self.filename = filename - if not isinstance(element_generator, str): - raise TypeError('element_generator must be a java class name (str)') - self.element_generator = element_generator - self.parallelism = parallelism - self.validate = validate - self.skip_invalid_elements = skip_invalid_elements - - def to_json(self): - operation = super().to_json() - - if self.filename is not None: - operation['filename'] = self.filename - - if self.element_generator is not None: - operation['elementGenerator'] = self.element_generator - - if self.parallelism is not None: - operation['parallelism'] = self.parallelism - - if self.validate is not None: - operation['validate'] = self.validate - - if self.skip_invalid_elements is not None: - operation['skipInvalidElements'] = self.skip_invalid_elements - - return operation - - -class GetElementsBetweenSets(GetOperation): - CLASS = 'uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsBetweenSets' - - def __init__(self, - input=None, - input_b=None, - view=None, - directed_type=None, - include_incoming_out_going=None, - # deprecated, use seed_matching instead - seed_matching_type=None, - seed_matching=None, - options=None): - super().__init__( - _class_name=self.CLASS, - input=input, - view=view, - directed_type=directed_type, - include_incoming_out_going=include_incoming_out_going, - seed_matching_type=seed_matching_type, - seed_matching=seed_matching, - options=options) - self.input_b = input_b - - def to_json(self): - operation = super().to_json() - - if self.input_b is not None: - json_seeds_b = [] - for seed_b in self.input_b: - if isinstance(seed_b, ElementSeed): - json_seeds_b.append(seed_b.to_json()) - elif isinstance(seed_b, str): - json_seeds_b.append(EntitySeed(seed_b).to_json()) - else: - raise TypeError( - 'SeedsB argument must contain ElementSeed objects') - operation['inputB'] = json_seeds_b - return operation - - -class GetElementsWithinSet(GetOperation): - CLASS = 'uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsWithinSet' - - def __init__(self, - input=None, - view=None, - directed_type=None, - options=None): - super().__init__( - _class_name=self.CLASS, - input=input, - view=view, - directed_type=directed_type, - include_incoming_out_going=None, - options=options) - - -class GetElementsInRanges(GetOperation): - CLASS = 'uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges' - - def __init__(self, - input=None, - view=None, - directed_type=None, - include_incoming_out_going=None, - # deprecated, use seed_matching instead - seed_matching_type=None, - seed_matching=None, - options=None): - super().__init__( - _class_name=self.CLASS, - input=None, - view=view, - directed_type=directed_type, - include_incoming_out_going=include_incoming_out_going, - seed_matching_type=seed_matching_type, - seed_matching=seed_matching, - options=options) - self.input = input - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - json_seed_pairs = [] - for seed_pair in self.input: - if isinstance(seed_pair, SeedPair): - json_seed_pairs.append(seed_pair.to_json()) - else: - raise TypeError( - 'input argument must contain SeedPair objects') - operation['input'] = json_seed_pairs - return operation - - -class SummariseGroupOverRanges(Operation): - CLASS = 'uk.gov.gchq.gaffer.accumulostore.operation.impl.SummariseGroupOverRanges' - - def __init__(self, input, - view=None, - include_incoming_out_going=None, - directed_type=None, - options=None): - super().__init__( - _class_name=self.CLASS, - options=options, - view=view - ) - self.input = input - self.include_incoming_out_going = include_incoming_out_going - self.directed_type = directed_type - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - json_seed_pairs = [] - for seed_pair in self.input: - if isinstance(seed_pair, SeedPair): - json_seed_pairs.append(seed_pair.to_json()) - else: - raise TypeError( - 'input argument must contain SeedPair objects') - - operation['input'] = json_seed_pairs - if self.include_incoming_out_going is not None: - operation[ - 'includeIncomingOutGoing'] = self.include_incoming_out_going - - if self.directed_type is not None: - operation['directedType'] = self.directed_type - - return operation - - -class Filter(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.function.Filter' - - def __init__(self, - input=None, - entities=None, - edges=None, - global_elements=None, - global_entities=None, - global_edges=None, - options=None): - super().__init__( - _class_name=self.CLASS, - options=options - ) - self.input = input - self.entities = None - self.edges = None - - if entities is not None: - self.entities = [] - if isinstance(entities, list): - for el_def in entities: - self.entities.append( - JsonConverter.validate( - el_def, ElementFilterDefinition, False - ) - ) - else: - for group, el_def in entities.items(): - el_def = JsonConverter.validate( - el_def, ElementFilterDefinition, False - ) - el_def.group = group - self.entities.append(el_def) - - if edges is not None: - self.edges = [] - if isinstance(edges, list): - for el_def in edges: - self.edges.append( - JsonConverter.validate( - el_def, ElementFilterDefinition, False - ) - ) - else: - for group, el_def in edges.items(): - el_def = JsonConverter.validate( - el_def, ElementFilterDefinition, False - ) - el_def.group = group - self.edges.append(el_def) - - self.global_elements = JsonConverter.validate(global_elements, GlobalElementFilterDefinition) - self.global_entities = JsonConverter.validate(global_entities, GlobalElementFilterDefinition) - self.global_edges = JsonConverter.validate(global_edges, GlobalElementFilterDefinition) - - def to_json(self): - operation = super().to_json() - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - - if self.entities is not None: - el_defs = {} - for el_def in self.entities: - el_defs[el_def.group] = el_def.to_json() - operation['entities'] = el_defs - if self.edges is not None: - el_defs = {} - for el_def in self.edges: - el_defs[el_def.group] = el_def.to_json() - operation['edges'] = el_defs - - if self.global_elements is not None: - operation['globalElements'] = self.global_elements.to_json() - - if self.global_entities is not None: - operation['globalEntities'] = self.global_entities.to_json() - - if self.global_edges is not None: - operation['globalEdges'] = self.global_edges.to_json() - - return operation - - -class Aggregate(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.function.Aggregate' - - def __init__(self, - input=None, - entities=None, - edges=None, - options=None): - super().__init__( - _class_name=self.CLASS, - options=options - ) - self.input = input - self.entities = None - self.edges = None - - if entities is not None: - self.entities = [] - if isinstance(entities, list): - for el_def in entities: - self.entities.append( - JsonConverter.validate( - el_def, AggregatePair, False - ) - ) - else: - for group, el_def in entities.items(): - el_def = JsonConverter.validate( - el_def, AggregatePair, False - ) - el_def.group = group - self.entities.append(el_def) - - if edges is not None: - self.edges = [] - if isinstance(edges, list): - for el_def in edges: - self.edges.append( - JsonConverter.validate( - el_def, AggregatePair, False - ) - ) - else: - for group, el_def in edges.items(): - el_def = JsonConverter.validate( - el_def, AggregatePair, False - ) - el_def.group = group - self.edges.append(el_def) - - def to_json(self): - operation = super().to_json() - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - if self.entities is not None: - el_defs = {} - for el_def in self.entities: - el_defs[el_def.group] = el_def.to_json() - operation['entities'] = el_defs - if self.edges is not None: - el_defs = {} - for el_def in self.edges: - el_defs[el_def.group] = el_def.to_json() - operation['edges'] = el_defs - - return operation - - -class Transform(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.function.Transform' - - def __init__(self, - input=None, - entities=None, - edges=None, - options=None): - super().__init__( - _class_name=self.CLASS, - options=options - ) - self.input = input - self.entities = None - self.edges = None - - if entities is not None: - self.entities = [] - if isinstance(entities, list): - for el_def in entities: - self.entities.append( - JsonConverter.validate( - el_def, ElementTransformDefinition, False - ) - ) - else: - for group, el_def in entities.items(): - el_def = JsonConverter.validate( - el_def, ElementTransformDefinition, False - ) - el_def.group = group - self.entities.append(el_def) - - if edges is not None: - self.edges = [] - if isinstance(edges, list): - for el_def in edges: - self.edges.append( - JsonConverter.validate( - el_def, ElementTransformDefinition, False - ) - ) - else: - for group, el_def in edges.items(): - el_def = JsonConverter.validate( - el_def, ElementTransformDefinition, False - ) - el_def.group = group - self.edges.append(el_def) - - def to_json(self): - operation = super().to_json() - if self.input is not None: - elements_json = [] - for element in self.input: - elements_json.append(element.to_json()) - operation['input'] = elements_json - if self.entities is not None: - el_defs = {} - for el_def in self.entities: - el_defs[el_def.group] = el_def.to_json() - operation['entities'] = el_defs - if self.edges is not None: - el_defs = {} - for el_def in self.edges: - el_defs[el_def.group] = el_def.to_json() - operation['edges'] = el_defs - - return operation - - -class ScoreOperationChain(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.ScoreOperationChain' - - def __init__(self, operation_chain, options=None): - super().__init__(_class_name=self.CLASS, - options=options) - self.operation_chain = self.validate_operation_chain(operation_chain) - - def to_json(self): - operation = super().to_json() - operation['operationChain'] = self.operation_chain.to_json() - - return operation - - -class GetWalks(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.GetWalks' - - def __init__(self, - input=None, - operations=None, - include_partial=None, - conditional=None, - results_limit=None, - options=None): - super().__init__(_class_name=self.CLASS, - options=options) - self.input = input - self.operations = None - self.include_partial = include_partial - self.results_limit = results_limit - - if operations is not None: - self.operations = [] - for op in operations: - op = JsonConverter.validate(op, Operation) - if not isinstance(op, GetElements) and not isinstance(op, OperationChain): - raise TypeError('Operations must be of type GetElements or OperationChain') - self.operations.append(op) - - self.conditional = JsonConverter.validate(conditional, Conditional) - - def to_json(self): - operation = super().to_json() - if self.results_limit is not None: - operation['resultsLimit'] = self.results_limit - - if self.input is not None: - entity_seed_json = [] - for entity_seed in self.input: - entity_seed_json.append(entity_seed.to_json()) - operation['input'] = entity_seed_json - - if self.operations is not None: - operations_json = [] - for op in self.operations: - operations_json.append(op.to_json()) - operation['operations'] = operations_json - - if self.include_partial is not None: - operation['include_partial'] = self.include_partial - - if self.conditional is not None: - operation['conditional'] = self.conditional.to_json() - - return operation - - -class Map(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.Map' - - def __init__(self, - functions, - input=None, - options=None): - super().__init__(_class_name=self.CLASS, - options=options) - - self.input = input - - if functions is not None: - self.functions = [] - for func in functions: - self.functions.append( - JsonConverter.validate( - func, gaffer_functions.Function, False - ) - ) - - def to_json(self): - operation = super().to_json() - if self.input is not None: - operation['input'] = self.input - - if self.functions is not None: - functions_json = [] - for function in self.functions: - functions_json.append(function.to_json()) - operation['functions'] = functions_json - - return operation - - -class If(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.If' - - def __init__(self, input=None, condition=None, conditional=None, - then=None, otherwise=None, options=None): - super().__init__(_class_name=self.CLASS, - options=options) - - self.input = input - self.condition = condition - - self.conditional = JsonConverter.validate(conditional, Conditional) - self.then = JsonConverter.validate(then, Operation) - self.otherwise = JsonConverter.validate(otherwise, Operation) - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - json_seeds = [] - if isinstance(self.input, list): - for seed in self.input: - if isinstance(seed, ToJson): - json_seeds.append(seed.to_json()) - else: - json_seeds.append(seed) - else: - if isinstance(self.input, ToJson): - json_seeds.append(self.input.to_json()) - else: - json_seeds.append(self.input.to_json()) - operation['input'] = json_seeds - - if self.condition is not None: - operation['condition'] = self.condition - - if self.conditional is not None: - operation['conditional'] = self.conditional.to_json() - - if self.then is not None: - operation['then'] = self.then.to_json() - - if self.otherwise is not None: - operation['otherwise'] = self.otherwise.to_json() - - return operation - - -class While(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.While' - - def __init__(self, max_repeats=1000, input=None, operation=None, - condition=None, conditional=None, options=None): - - super().__init__(_class_name=self.CLASS, - options=options) - - self.max_repeats = max_repeats - self.input = input - self.condition = condition - - self.operation = JsonConverter.validate(operation, Operation) - self.conditional = JsonConverter.validate(conditional, Conditional) - - def to_json(self): - operation = super().to_json() - - operation['maxRepeats'] = self.max_repeats - - if self.input is not None: - json_seeds = [] - if isinstance(self.input, list): - for seed in self.input: - if isinstance(seed, ToJson): - json_seeds.append(seed.to_json()) - else: - json_seeds.append(seed) - else: - if isinstance(self.input, ToJson): - json_seeds.append(self.input.to_json()) - else: - json_seeds.append(self.input.to_json()) - operation['input'] = json_seeds - - if self.operation is not None: - operation['operation'] = self.operation.to_json() - - if self.condition is not None: - operation['condition'] = self.condition - - if self.conditional is not None: - operation['conditional'] = self.conditional.to_json() - - return operation - - -class Reduce(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.Reduce' - - def __init__(self, input=None, identity=None, - aggregate_function=None, options=None): - - super().__init__(_class_name=self.CLASS, - options=options) - - self.input = input - self.identity = identity - - self.aggregate_function = JsonConverter.validate( - aggregate_function, gaffer_binaryoperators.BinaryOperator, False - ) - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - json_seeds = [] - if isinstance(self.input, list): - for seed in self.input: - if isinstance(seed, ToJson): - json_seeds.append(seed.to_json()) - else: - json_seeds.append(seed) - else: - if isinstance(self.input, ToJson): - json_seeds.append(self.input.to_json()) - else: - json_seeds.append(self.input.to_json()) - operation['input'] = json_seeds - - operation['aggregateFunction'] = self.aggregate_function.to_json() - - if self.identity is not None: - if isinstance(self.identity, ToJson): - operation['identity'] = self.identity.to_json() - else: - operation['identity'] = self.identity - - return operation - - -class ForEach(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.ForEach' - - def __init__(self, input=None, operation=None, options=None): - - super().__init__(_class_name=self.CLASS, - options=options) - - self.input = input - - self.operation = JsonConverter.validate( - operation, Operation, False - ) - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - json_seeds = [] - if isinstance(self.input, list): - for seed in self.input: - if isinstance(seed, ToJson): - json_seeds.append(seed.to_json()) - else: - json_seeds.append(seed) - else: - if isinstance(self.input, ToJson): - json_seeds.append(self.input.to_json()) - else: - json_seeds.append(self.input.to_json()) - operation['input'] = json_seeds - - if self.operation is not None: - operation['operation'] = self.operation.to_json() - - return operation - - -class ToSingletonList(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList' - - def __init__(self, input=None, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.input = input - - def to_json(self): - operation = super().to_json() - - if self.input is not None: - json_seeds = [] - if isinstance(self.input, list): - for seed in self.input: - if isinstance(seed, ToJson): - json_seeds.append(seed.to_json()) - else: - json_seeds.append(seed) - else: - if isinstance(self.input, ToJson): - json_seeds.append(self.input.to_json()) - else: - json_seeds.append(self.input.to_json()) - operation['input'] = json_seeds - - return operation - - -class ValidateOperationChain(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain' - - def __init__(self, operation_chain=None, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.operation_chain = self.validate_operation_chain(operation_chain) - - def to_json(self): - operation_json = super().to_json() - operation_json['operationChain'] = self.operation_chain.to_json() - return operation_json - - class Conditional(ToJson, ToCodeString): CLASS = 'uk.gov.gchq.gaffer.operation.util.Conditional' @@ -2634,299 +665,152 @@ def to_json(self): return conditional_json +from .generated.operations import * -class Join(Operation): - - CLASS = 'uk.gov.gchq.gaffer.operation.impl.join.Join' - - def __init__(self, input=None, operation=None, match_method=None, match_key=None, flatten=None, join_type=None, collection_limit=None, options=None): - super().__init__(_class_name=self.CLASS, options=options) - - self.operation = JsonConverter.validate( - operation, Operation, False - ) - self.match_method = JsonConverter.validate( - match_method, Match, False - ) - - self.input = input - self.flatten = flatten - self.match_key = match_key - self.collection_limit = collection_limit - self.join_type = join_type - +# Parameters +class AddNamedOperation(AddNamedOperation): def to_json(self): operation_json = super().to_json() - - if self.input is not None: - json_input = [] - for input in self.input: - if isinstance(input, ToJson): - json_input.append(input.to_json()) - else: - json_input.append(input) - - operation_json['input'] = json_input - if self.operation is not None: - operation_json['operation'] = self.operation.to_json() - if self.match_method is not None: - operation_json['matchMethod'] = self.match_method.to_json() - if self.match_key is not None: - operation_json['matchKey'] = self.match_key - if self.flatten is not None: - operation_json['flatten'] = self.flatten - if self.join_type is not None: - operation_json['joinType'] = self.join_type - if self.collection_limit is not None: - operation_json['collectionLimit'] = self.collection_limit - + if self.parameters is not None: + if isinstance(self.parameters, list): + operation_json['parameters'] = {} + for param in self.parameters: + operation_json['parameters'][param.name] = param.get_detail() return operation_json - -class GetAllGraphIds(Operation): - CLASS = 'uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds' - - def __init__(self, options=None): - super().__init__(_class_name=self.CLASS, options=options) - -class GetAllGraphInfo(Operation): - CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo" - - def __init__(self, options=None): - super().__init__(_class_name=self.CLASS, options=options) - -class FederatedOperationChain(Operation): - CLASS = 'uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain' - - def __init__(self,operation_chain=None,options=None): - super().__init__(_class_name=self.CLASS, options=options) - - self.operation_chain = self.validate_operation_chain(operation_chain) - +class AddNamedView(AddNamedView): def to_json(self): - operation = super().to_json() - operation['operationChain'] = self.operation_chain.to_json() - - return operation - - -class RemoveGraph(Operation): - CLASS = 'uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph' - - def __init__(self, graph_id, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.graph_id = graph_id + operation_json = super().to_json() + if self.parameters is not None: + if isinstance(self.parameters, list): + operation_json['parameters'] = {} + for param in self.parameters: + operation_json['parameters'][param.name] = param.get_detail() + return operation_json +# Element definitions +class Filter(Filter): def to_json(self): - operation = super().to_json() - operation['graphId'] = self.graph_id - return operation - - -class AddGraph(Operation): - CLASS = 'uk.gov.gchq.gaffer.federatedstore.operation.AddGraph' - - def __init__(self, graph_id, - store_properties=None, - parent_properties_id=None, - schema=None, - parent_schema_ids=None, - graph_auths=None, - is_public=None, - disabled_by_default=None, - options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.graph_id = graph_id - self.store_properties = store_properties - self.parent_properties_id = parent_properties_id - self.schema = schema - self.parent_properties_id = parent_properties_id - self.parent_schema_ids = parent_schema_ids - self.graph_auths = graph_auths - self.is_public = is_public - self.disabled_by_default = disabled_by_default + operation_json = super().to_json() + if self.edges is not None: + if isinstance(self.edges, list): + operation_json['edges'] = {} + for el_def in self.edges: + operation_json['edges'][el_def.group] = el_def.to_json() + if self.entities is not None: + if isinstance(self.entities, list): + operation_json['entities'] = {} + for el_def in self.entities: + operation_json['entities'][el_def.group] = el_def.to_json() + return operation_json +class Aggregate(Aggregate): def to_json(self): - operation = super().to_json() - operation['graphId'] = self.graph_id - if self.store_properties is not None: - operation['storeProperties'] = self.store_properties - - if self.parent_properties_id is not None: - operation['parentPropertiesId'] = self.parent_properties_id - - if self.schema is not None: - operation['schema'] = self.schema - - if self.parent_schema_ids is not None: - operation['parentSchemaIds'] = self.parent_schema_ids - - if self.graph_auths is not None: - operation['graphAuths'] = self.graph_auths - - if self.is_public is not None: - operation['isPublic'] = self.is_public - - if self.disabled_by_default is not None: - operation['disabledByDefault'] = self.disabled_by_default - - return operation - - -class AddGraphWithHooks(Operation): - CLASS = 'uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks' - - def __init__(self, graph_id, - store_properties=None, - parent_properties_id=None, - schema=None, - parent_schema_ids=None, - graph_auths=None, - is_public=None, - disabled_by_default=None, - hooks=None, - options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.graph_id = graph_id - self.store_properties = store_properties - self.parent_properties_id = parent_properties_id - self.schema = schema - self.parent_properties_id = parent_properties_id - self.parent_schema_ids = parent_schema_ids - self.graph_auths = graph_auths - self.is_public = is_public - self.disabled_by_default = disabled_by_default - self.hooks = hooks + operation_json = super().to_json() + if self.edges is not None: + if isinstance(self.edges, list): + operation_json['edges'] = {} + for el_def in self.edges: + operation_json['edges'][el_def.group] = el_def.to_json() + if self.entities is not None: + if isinstance(self.entities, list): + operation_json['entities'] = {} + for el_def in self.entities: + operation_json['entities'][el_def.group] = el_def.to_json() + return operation_json +class Transform(Transform): def to_json(self): - operation = super().to_json() - operation['graphId'] = self.graph_id - if self.store_properties is not None: - operation['storeProperties'] = self.store_properties - - if self.parent_properties_id is not None: - operation['parentPropertiesId'] = self.parent_properties_id - - if self.schema is not None: - operation['schema'] = self.schema - - if self.parent_schema_ids is not None: - operation['parentSchemaIds'] = self.parent_schema_ids - - if self.graph_auths is not None: - operation['graphAuths'] = self.graph_auths - - if self.is_public is not None: - operation['isPublic'] = self.is_public - - if self.disabled_by_default is not None: - operation['disabledByDefault'] = self.disabled_by_default - - if self.hooks is not None: - operation['hooks'] = self.hooks - - return operation - - -class ChangeGraphAccess(Operation): - CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphAccess" - - def __init__(self, - graph_id: str, - graph_auths: list=None, - owner_user_id: str=None, - is_public: bool=None, - disabled_by_default: bool=None, - options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.graph_id = graph_id - self.graph_auths = graph_auths - self.owner_user_id = owner_user_id - self.is_public = is_public - self.disabled_by_default = disabled_by_default + operation_json = super().to_json() + if self.edges is not None: + if isinstance(self.edges, list): + operation_json['edges'] = {} + for el_def in self.edges: + operation_json['edges'][el_def.group] = el_def.to_json() + if self.entities is not None: + if isinstance(self.entities, list): + operation_json['entities'] = {} + for el_def in self.entities: + operation_json['entities'][el_def.group] = el_def.to_json() + return operation_json +# Element Input +class GetElements(GetElements): def to_json(self): - operation = super().to_json() - operation['graphId'] = self.graph_id - - if self.graph_auths is not None: - operation['graphAuths'] = self.graph_auths - - if self.owner_user_id is not None: - operation['ownerUserId'] = self.owner_user_id - - if self.is_public is not None: - operation['isPublic'] = self.is_public - - if self.disabled_by_default is not None: - operation['disabledByDefault'] = self.disabled_by_default - - return operation - -class ChangeGraphId(Operation): - CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId" - - def __init__(self, graph_id, new_graph_id, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.graph_id = graph_id - self.new_graph_id = new_graph_id + operation_json = super().to_json() + if self.input is not None: + json_seeds = [] + if not isinstance(self.input, list): + self.input = [self.input] + for seed in self.input: + if isinstance(seed, ElementSeed): + json_seeds.append(seed.to_json()) + else: + json_seeds.append(EntitySeed(seed).to_json()) + operation_json['input'] = json_seeds + return operation_json +class ToVertices(ToVertices): def to_json(self): - operation = super().to_json() - operation["graphId"] = self.graph_id - operation["newGraphId"] = self.new_graph_id - return operation - -class GetVariable(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.GetVariable' + operation_json = super().to_json() + if self.input is not None: + json_seeds = [] + if not isinstance(self.input, list): + self.input = [self.input] + for seed in self.input: + if isinstance(seed, ElementSeed): + json_seeds.append(seed.to_json()) + else: + json_seeds.append(EntitySeed(seed).to_json()) + operation_json['input'] = json_seeds + return operation_json - def __init__(self, variable_name=None, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.variable_name = variable_name +# Entity Input +class GetWalks(GetWalks): def to_json(self): - operation = super().to_json() - - if self.variable_name is not None: - operation['variableName'] = self.variable_name - - return operation - - -class GetVariables(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.GetVariables' - - def __init__(self, variable_names=None, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.variable_names = variable_names + operation_json = super().to_json() + if self.input is not None: + json_seeds = [] + if not isinstance(self.input, list): + self.input = [self.input] + for seed in self.input: + if isinstance(seed, EntitySeed): + json_seeds.append(seed.to_json()) + else: + json_seeds.append(EntitySeed(seed).to_json()) + operation_json['input'] = json_seeds + return operation_json +class GetAdjacentIds(GetAdjacentIds): def to_json(self): - operation = super().to_json() - - if self.variable_names is not None: - operation['variableNames'] = self.variable_names - - return operation - - -class SetVariable(Operation): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.SetVariable' - - def __init__(self, input=None, variable_name=None, options=None): - super().__init__(_class_name=self.CLASS, options=options) - self.input = input - self.variable_name = variable_name + operation_json = super().to_json() + if self.input is not None: + json_seeds = [] + if not isinstance(self.input, list): + self.input = [self.input] + for seed in self.input: + if isinstance(seed, EntitySeed): + json_seeds.append(seed.to_json()) + else: + json_seeds.append(EntitySeed(seed).to_json()) + operation_json['input'] = json_seeds + return operation_json +class GetElementsWithinSet(GetElementsWithinSet): def to_json(self): - operation = super().to_json() - - if self.variable_name is not None: - operation['variableName'] = self.variable_name - + operation_json = super().to_json() if self.input is not None: - operation['input'] = self.input - - return operation + json_seeds = [] + if not isinstance(self.input, list): + self.input = [self.input] + for seed in self.input: + if isinstance(seed, EntitySeed): + json_seeds.append(seed.to_json()) + else: + json_seeds.append(EntitySeed(seed).to_json()) + operation_json['input'] = json_seeds + return operation_json def load_operation_json_map(): for name, class_obj in inspect.getmembers( diff --git a/python-shell/src/gafferpy/generate.py b/python-shell/src/gafferpy/generate.py new file mode 100644 index 000000000..a5a1a1fa3 --- /dev/null +++ b/python-shell/src/gafferpy/generate.py @@ -0,0 +1,4 @@ +from gafferpy import gaffer_connector +gc = gaffer_connector.GafferConnector("http://localhost:8080/rest") +from fishbowl.fishbowl import Fishbowl +Fishbowl(gc) diff --git a/python-shell/src/test/test_connector.py b/python-shell/src/test/test_connector.py index f4eea7858..3b4bc0fcc 100755 --- a/python-shell/src/test/test_connector.py +++ b/python-shell/src/test/test_connector.py @@ -21,247 +21,150 @@ from gafferpy import gaffer_connector -class GafferConnectorTest(unittest.TestCase): - def test_execute_operation(self): - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest') - elements = gc.execute_operation( - g.GetElements( - input=[ - g.EntitySeed('M5:10') - ], - view=g.View( - edges=[ - g.ElementDefinition( - group='JunctionLocatedAt' - ) - ] +class BaseTestCases: + class GafferConnectorTest(unittest.TestCase): + client_class = "" + + def test_execute_operation(self): + gc = gaffer_connector.GafferConnector('http://localhost:8080/rest', client_class=self.client_class) + elements = gc.execute_operation( + g.GetElements( + input=[ + g.EntitySeed('M5:10') + ], + view=g.View( + edges=[ + g.ElementDefinition( + group='JunctionLocatedAt' + ) + ] + ) ) ) - ) - self.assertEqual( - [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, - "SOURCE")], - elements) + self.assertEqual( + [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, + "SOURCE")], + elements) - def test_is_operation_supported(self): - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest') + def test_is_operation_supported(self): + gc = gaffer_connector.GafferConnector('http://localhost:8080/rest', client_class=self.client_class) - response_text = gc.is_operation_supported( - g.IsOperationSupported( - operation='uk.gov.gchq.gaffer.operation.impl.get.GetAllElements' + response = gc.is_operation_supported( + g.IsOperationSupported( + operation='uk.gov.gchq.gaffer.operation.impl.get.GetAllElements' + ), + json_result=True ) - ) + response.pop("next") + response_text = json.dumps(response) - expected_response_text = ''' - { - "name": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", - "summary": "Gets all elements compatible with a provided View", - "fields": [ - { - "name": "view", - "className": "uk.gov.gchq.gaffer.data.elementdefinition.view.View", - "required": false - }, - { - "name": "options", - "className": "java.util.Map", - "required": false - }, + expected_response_text = ''' { - "name": "directedType", - "summary": "Is the Edge directed?", - "className": "java.lang.String", - "options": [ - "DIRECTED", - "UNDIRECTED", - "EITHER" - ], - "required": false + "name": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", + "summary": "Gets all elements compatible with a provided View", + "fields": [ + { + "name": "view", + "className": "uk.gov.gchq.gaffer.data.elementdefinition.view.View", + "required": false + }, + { + "name": "options", + "className": "java.util.Map", + "required": false + }, + { + "name": "directedType", + "summary": "Is the Edge directed?", + "className": "java.lang.String", + "options": [ + "DIRECTED", + "UNDIRECTED", + "EITHER" + ], + "required": false + }, + { + "name": "views", + "className": "java.util.List", + "required": false + } + ], + "exampleJson": { + "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" }, - { - "name": "views", - "className": "java.util.List", - "required": false + "outputClassName": "java.lang.Iterable" } - ], - "next": [ - "uk.gov.gchq.gaffer.operation.impl.add.AddElements", - "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", - "uk.gov.gchq.gaffer.operation.impl.output.ToArray", - "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds", - "uk.gov.gchq.gaffer.operation.impl.output.ToList", - "uk.gov.gchq.gaffer.operation.impl.output.ToMap", - "uk.gov.gchq.gaffer.operation.impl.output.ToCsv", - "uk.gov.gchq.gaffer.operation.impl.output.ToSet", - "uk.gov.gchq.gaffer.operation.impl.output.ToStream", - "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", - "uk.gov.gchq.gaffer.named.operation.NamedOperation", - "uk.gov.gchq.gaffer.operation.impl.compare.Max", - "uk.gov.gchq.gaffer.operation.impl.compare.Min", - "uk.gov.gchq.gaffer.operation.impl.compare.Sort", - "uk.gov.gchq.gaffer.operation.impl.GetWalks", - "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", - "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", - "uk.gov.gchq.gaffer.operation.impl.Validate", - "uk.gov.gchq.gaffer.operation.impl.Count", - "uk.gov.gchq.gaffer.operation.impl.CountGroups", - "uk.gov.gchq.gaffer.operation.impl.Limit", - "uk.gov.gchq.gaffer.operation.impl.DiscardOutput", - "uk.gov.gchq.gaffer.operation.impl.Map", - "uk.gov.gchq.gaffer.operation.impl.If", - "uk.gov.gchq.gaffer.operation.impl.While", - "uk.gov.gchq.gaffer.operation.impl.ForEach", - "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList", - "uk.gov.gchq.gaffer.operation.impl.Reduce", - "uk.gov.gchq.gaffer.operation.impl.join.Join", - "uk.gov.gchq.gaffer.operation.impl.SetVariable", - "uk.gov.gchq.gaffer.operation.impl.function.Filter", - "uk.gov.gchq.gaffer.operation.impl.function.Transform", - "uk.gov.gchq.gaffer.operation.impl.function.Aggregate", - "uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView", - "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph", - "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", - "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache" - ], - "exampleJson": { - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, - "outputClassName": "java.lang.Iterable" - } - ''' + ''' - self.assertEqual( - json.loads(expected_response_text), - json.loads(response_text) - ) - - def test_execute_get(self): - self.maxDiff = None - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest') + self.assertEqual( + json.loads(expected_response_text), + json.loads(response_text) + ) - response_text = gc.execute_get( - g.GetOperations() - ) + def test_execute_get(self): + gc = gaffer_connector.GafferConnector('http://localhost:8080/rest', client_class=self.client_class) - expected_response_text = ''' - [ - "uk.gov.gchq.gaffer.operation.impl.add.AddElements", - "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", - "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", - "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", - "uk.gov.gchq.gaffer.operation.impl.export.GetExports", - "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails", - "uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails", - "uk.gov.gchq.gaffer.operation.impl.job.GetJobResults", - "uk.gov.gchq.gaffer.operation.impl.output.ToArray", - "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds", - "uk.gov.gchq.gaffer.operation.impl.output.ToList", - "uk.gov.gchq.gaffer.operation.impl.output.ToMap", - "uk.gov.gchq.gaffer.operation.impl.output.ToCsv", - "uk.gov.gchq.gaffer.operation.impl.output.ToSet", - "uk.gov.gchq.gaffer.operation.impl.output.ToStream", - "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", - "uk.gov.gchq.gaffer.named.operation.NamedOperation", - "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", - "uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations", - "uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation", - "uk.gov.gchq.gaffer.named.view.AddNamedView", - "uk.gov.gchq.gaffer.named.view.GetAllNamedViews", - "uk.gov.gchq.gaffer.named.view.DeleteNamedView", - "uk.gov.gchq.gaffer.operation.impl.compare.Max", - "uk.gov.gchq.gaffer.operation.impl.compare.Min", - "uk.gov.gchq.gaffer.operation.impl.compare.Sort", - "uk.gov.gchq.gaffer.operation.OperationChain", - "uk.gov.gchq.gaffer.operation.OperationChainDAO", - "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", - "uk.gov.gchq.gaffer.operation.impl.GetWalks", - "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", - "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", - "uk.gov.gchq.gaffer.operation.impl.Validate", - "uk.gov.gchq.gaffer.operation.impl.Count", - "uk.gov.gchq.gaffer.operation.impl.CountGroups", - "uk.gov.gchq.gaffer.operation.impl.Limit", - "uk.gov.gchq.gaffer.operation.impl.DiscardOutput", - "uk.gov.gchq.gaffer.store.operation.GetSchema", - "uk.gov.gchq.gaffer.operation.impl.Map", - "uk.gov.gchq.gaffer.operation.impl.If", - "uk.gov.gchq.gaffer.operation.impl.While", - "uk.gov.gchq.gaffer.operation.impl.ForEach", - "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList", - "uk.gov.gchq.gaffer.operation.impl.Reduce", - "uk.gov.gchq.gaffer.operation.impl.join.Join", - "uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob", - "uk.gov.gchq.gaffer.operation.impl.SetVariable", - "uk.gov.gchq.gaffer.operation.impl.GetVariable", - "uk.gov.gchq.gaffer.operation.impl.GetVariables", - "uk.gov.gchq.gaffer.operation.impl.function.Filter", - "uk.gov.gchq.gaffer.operation.impl.function.Transform", - "uk.gov.gchq.gaffer.operation.impl.function.Aggregate", - "uk.gov.gchq.gaffer.store.operation.HasTrait", - "uk.gov.gchq.gaffer.store.operation.GetTraits", - "uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView", - "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph", - "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", - "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache", - "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport" - ] - ''' + response = gc.execute_get( + g.GetSchema(), + json_result=True + ) - self.assertEqual( - json.loads(expected_response_text), - json.loads(response_text) - ) + self.assertTrue( + isinstance(response, dict) and response != {} + ) - def test_dummy_header(self): - """Test that the addition of a dummy header does not effect the standard test""" - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest', headers={"dummy_Header": "value"}) - elements = gc.execute_operation( - g.GetElements( - input=[ - g.EntitySeed('M5:10') - ], - view=g.View( - edges=[ - g.ElementDefinition( - group='JunctionLocatedAt' - ) - ] + def test_dummy_header(self): + """Test that the addition of a dummy header does not effect the standard test""" + gc = gaffer_connector.GafferConnector('http://localhost:8080/rest', headers={"dummy_Header": "value"}, client_class=self.client_class) + elements = gc.execute_operation( + g.GetElements( + input=[ + g.EntitySeed('M5:10') + ], + view=g.View( + edges=[ + g.ElementDefinition( + group='JunctionLocatedAt' + ) + ] + ) ) ) - ) - - self.assertEqual( - [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, - "SOURCE")], - elements) - - def test_class_initilisation(self): - """Test that the gaffer_connector class is correctly initialised with instance attributes""" - host = 'http://localhost:8080/rest/latest' - verbose = False - headers = {"dummy_Header": "value"} - gc = gaffer_connector.GafferConnector(host, verbose, headers) - - actuals = [gc._host, gc._verbose, gc._headers] - expecteds = [host, verbose, headers] - - for actual, expected in zip(actuals, expecteds): - self.assertEqual(actual, expected) - - def test_raise_connection_error(self): - """Test that a ConnectionError is correctly raised when a HTTP 404 error is caught""" - # Define a host that has an invalid endpoint in order to get a HTTP 404 error - host_with_bad_endpoint = "http://localhost:8080/badEndPoint" - gc = gaffer_connector.GafferConnector(host_with_bad_endpoint) - # Check that a ConnectionError is raised (which is catching the underlying HTTP 404) - with self.assertRaises(ConnectionError): - gc.execute_get(g.GetOperations()) + self.assertEqual( + [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, + "SOURCE")], + elements) + + def test_class_initilisation(self): + """Test that the gaffer_connector class is correctly initialised with instance attributes""" + host = 'http://localhost:8080/rest' + verbose = False + headers = {"dummy_Header": "value"} + gc = gaffer_connector.GafferConnector(host, verbose, headers, client_class=self.client_class) + + actuals = [gc._host, gc._verbose, gc._headers] + expecteds = [host, verbose, headers] + + for actual, expected in zip(actuals, expecteds): + self.assertEqual(actual, expected) + + def test_raise_connection_error(self): + """Test that a ConnectionError is correctly raised when a HTTP 404 error is caught""" + # Define a host that has an invalid endpoint in order to get a HTTP 404 error + host_with_bad_endpoint = "http://localhost:8080/badEndPoint" + gc = gaffer_connector.GafferConnector(host_with_bad_endpoint, client_class=self.client_class) + + # Check that a ConnectionError is raised (which is catching the underlying HTTP 404) + with self.assertRaises(ConnectionError): + gc.execute_get(g.GetOperations()) + +class GafferConnectorUrllibTest(BaseTestCases.GafferConnectorTest): + client_class = "urllib" +class GafferConnectorRequestsTest(BaseTestCases.GafferConnectorTest): + client_class = "requests" if __name__ == "__main__": unittest.main() diff --git a/python-shell/src/test/test_connector_requests.py b/python-shell/src/test/test_connector_requests.py deleted file mode 100755 index b80b87986..000000000 --- a/python-shell/src/test/test_connector_requests.py +++ /dev/null @@ -1,267 +0,0 @@ -# -# Copyright 2016-2019 Crown Copyright -# -# Licensed 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. -# - -import unittest -import json - -from gafferpy import gaffer as g -from gafferpy import gaffer_connector - - -class GafferConnectorTest(unittest.TestCase): - def test_execute_operation(self): - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest', client_class="requests") - elements = gc.execute_operation( - g.GetElements( - input=[ - g.EntitySeed('M5:10') - ], - view=g.View( - edges=[ - g.ElementDefinition( - group='JunctionLocatedAt' - ) - ] - ) - ) - ) - - self.assertEqual( - [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, - "SOURCE")], - elements) - - def test_is_operation_supported(self): - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest', client_class="requests") - - response_text = gc.is_operation_supported( - g.IsOperationSupported( - operation='uk.gov.gchq.gaffer.operation.impl.get.GetAllElements' - ) - ) - - expected_response_text = ''' - { - "name": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", - "summary": "Gets all elements compatible with a provided View", - "fields": [ - { - "name": "view", - "className": "uk.gov.gchq.gaffer.data.elementdefinition.view.View", - "required": false - }, - { - "name": "options", - "className": "java.util.Map", - "required": false - }, - { - "name": "directedType", - "summary": "Is the Edge directed?", - "className": "java.lang.String", - "options": [ - "DIRECTED", - "UNDIRECTED", - "EITHER" - ], - "required": false - }, - { - "name": "views", - "className": "java.util.List", - "required": false - } - ], - "next": [ - "uk.gov.gchq.gaffer.operation.impl.add.AddElements", - "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", - "uk.gov.gchq.gaffer.operation.impl.output.ToArray", - "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds", - "uk.gov.gchq.gaffer.operation.impl.output.ToList", - "uk.gov.gchq.gaffer.operation.impl.output.ToMap", - "uk.gov.gchq.gaffer.operation.impl.output.ToCsv", - "uk.gov.gchq.gaffer.operation.impl.output.ToSet", - "uk.gov.gchq.gaffer.operation.impl.output.ToStream", - "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", - "uk.gov.gchq.gaffer.named.operation.NamedOperation", - "uk.gov.gchq.gaffer.operation.impl.compare.Max", - "uk.gov.gchq.gaffer.operation.impl.compare.Min", - "uk.gov.gchq.gaffer.operation.impl.compare.Sort", - "uk.gov.gchq.gaffer.operation.impl.GetWalks", - "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", - "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", - "uk.gov.gchq.gaffer.operation.impl.Validate", - "uk.gov.gchq.gaffer.operation.impl.Count", - "uk.gov.gchq.gaffer.operation.impl.CountGroups", - "uk.gov.gchq.gaffer.operation.impl.Limit", - "uk.gov.gchq.gaffer.operation.impl.DiscardOutput", - "uk.gov.gchq.gaffer.operation.impl.Map", - "uk.gov.gchq.gaffer.operation.impl.If", - "uk.gov.gchq.gaffer.operation.impl.While", - "uk.gov.gchq.gaffer.operation.impl.ForEach", - "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList", - "uk.gov.gchq.gaffer.operation.impl.Reduce", - "uk.gov.gchq.gaffer.operation.impl.join.Join", - "uk.gov.gchq.gaffer.operation.impl.SetVariable", - "uk.gov.gchq.gaffer.operation.impl.function.Filter", - "uk.gov.gchq.gaffer.operation.impl.function.Transform", - "uk.gov.gchq.gaffer.operation.impl.function.Aggregate", - "uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView", - "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph", - "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", - "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache" - ], - "exampleJson": { - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, - "outputClassName": "java.lang.Iterable" - } - ''' - - self.assertEqual( - json.loads(expected_response_text), - json.loads(response_text) - ) - - def test_execute_get(self): - self.maxDiff = None - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest', client_class="requests") - - response_text = gc.execute_get( - g.GetOperations() - ) - - expected_response_text = ''' - [ - "uk.gov.gchq.gaffer.operation.impl.add.AddElements", - "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", - "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", - "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", - "uk.gov.gchq.gaffer.operation.impl.export.GetExports", - "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails", - "uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails", - "uk.gov.gchq.gaffer.operation.impl.job.GetJobResults", - "uk.gov.gchq.gaffer.operation.impl.output.ToArray", - "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds", - "uk.gov.gchq.gaffer.operation.impl.output.ToList", - "uk.gov.gchq.gaffer.operation.impl.output.ToMap", - "uk.gov.gchq.gaffer.operation.impl.output.ToCsv", - "uk.gov.gchq.gaffer.operation.impl.output.ToSet", - "uk.gov.gchq.gaffer.operation.impl.output.ToStream", - "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", - "uk.gov.gchq.gaffer.named.operation.NamedOperation", - "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", - "uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations", - "uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation", - "uk.gov.gchq.gaffer.named.view.AddNamedView", - "uk.gov.gchq.gaffer.named.view.GetAllNamedViews", - "uk.gov.gchq.gaffer.named.view.DeleteNamedView", - "uk.gov.gchq.gaffer.operation.impl.compare.Max", - "uk.gov.gchq.gaffer.operation.impl.compare.Min", - "uk.gov.gchq.gaffer.operation.impl.compare.Sort", - "uk.gov.gchq.gaffer.operation.OperationChain", - "uk.gov.gchq.gaffer.operation.OperationChainDAO", - "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", - "uk.gov.gchq.gaffer.operation.impl.GetWalks", - "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", - "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", - "uk.gov.gchq.gaffer.operation.impl.Validate", - "uk.gov.gchq.gaffer.operation.impl.Count", - "uk.gov.gchq.gaffer.operation.impl.CountGroups", - "uk.gov.gchq.gaffer.operation.impl.Limit", - "uk.gov.gchq.gaffer.operation.impl.DiscardOutput", - "uk.gov.gchq.gaffer.store.operation.GetSchema", - "uk.gov.gchq.gaffer.operation.impl.Map", - "uk.gov.gchq.gaffer.operation.impl.If", - "uk.gov.gchq.gaffer.operation.impl.While", - "uk.gov.gchq.gaffer.operation.impl.ForEach", - "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList", - "uk.gov.gchq.gaffer.operation.impl.Reduce", - "uk.gov.gchq.gaffer.operation.impl.join.Join", - "uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob", - "uk.gov.gchq.gaffer.operation.impl.SetVariable", - "uk.gov.gchq.gaffer.operation.impl.GetVariable", - "uk.gov.gchq.gaffer.operation.impl.GetVariables", - "uk.gov.gchq.gaffer.operation.impl.function.Filter", - "uk.gov.gchq.gaffer.operation.impl.function.Transform", - "uk.gov.gchq.gaffer.operation.impl.function.Aggregate", - "uk.gov.gchq.gaffer.store.operation.HasTrait", - "uk.gov.gchq.gaffer.store.operation.GetTraits", - "uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView", - "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph", - "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", - "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache", - "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport" - ] - ''' - - self.assertEqual( - json.loads(expected_response_text), - json.loads(response_text) - ) - - def test_dummy_header(self): - """Test that the addition of a dummy header does not effect the standard test""" - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest', headers={"dummy_Header": "value"}, client_class="requests") - elements = gc.execute_operation( - g.GetElements( - input=[ - g.EntitySeed('M5:10') - ], - view=g.View( - edges=[ - g.ElementDefinition( - group='JunctionLocatedAt' - ) - ] - ) - ) - ) - - self.assertEqual( - [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, - "SOURCE")], - elements) - - def test_class_initilisation(self): - """Test that the gaffer_connector class is correctly initialised with instance attributes""" - host = 'http://localhost:8080/rest/latest' - verbose = False - headers = {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'dummy_Header': 'value'} - gc = gaffer_connector.GafferConnector(host, verbose, headers, client_class="requests") - - actuals = [gc._host, gc._verbose, gc._headers] - expecteds = [host, verbose, headers] - - for actual, expected in zip(actuals, expecteds): - self.assertEqual(actual, expected) - - def test_raise_connection_error(self): - """Test that a ConnectionError is correctly raised when a HTTP 404 error is caught""" - # Define a host that has an invalid endpoint in order to get a HTTP 404 error - host_with_bad_endpoint = "http://localhost:8080/badEndPoint" - gc = gaffer_connector.GafferConnector(host_with_bad_endpoint, client_class="requests") - - # Check that a ConnectionError is raised (which is catching the underlying HTTP 404) - with self.assertRaises(ConnectionError): - gc.execute_get(g.GetOperations()) - -if __name__ == "__main__": - unittest.main() diff --git a/python-shell/src/test/test_example.py b/python-shell/src/test/test_example.py index 1a0ad9c35..9301552bd 100755 --- a/python-shell/src/test/test_example.py +++ b/python-shell/src/test/test_example.py @@ -21,7 +21,7 @@ class ExampleTest(unittest.TestCase): def test_example_does_not_error(self): - example.run('http://localhost:8080/rest/latest') + example.run('http://localhost:8080/rest') if __name__ == "__main__": diff --git a/python-shell/src/test/test_example_map.py b/python-shell/src/test/test_example_map.py index 785de42f6..d72542cbc 100644 --- a/python-shell/src/test/test_example_map.py +++ b/python-shell/src/test/test_example_map.py @@ -21,7 +21,7 @@ class ExampleMapTest(unittest.TestCase): def test_example_map_does_not_error(self): - example_map.run('http://localhost:8080/rest/latest') + example_map.run('http://localhost:8080/rest') if __name__ == "__main__": diff --git a/python-shell/src/test/test_gaffer_functions_it.py b/python-shell/src/test/test_gaffer_functions_it.py index 4c93c2d2b..db52bf6a1 100755 --- a/python-shell/src/test/test_gaffer_functions_it.py +++ b/python-shell/src/test/test_gaffer_functions_it.py @@ -24,7 +24,7 @@ class GafferFunctionsIntegrationTest(unittest.TestCase): def test_all_functions_have_classes(self): gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest') + 'http://localhost:8080/rest') functions = gc.execute_get( g.GetTransformFunctions() ) diff --git a/python-shell/src/test/test_gaffer_operations.py b/python-shell/src/test/test_gaffer_operations.py index a44ce6629..98fdbeb15 100755 --- a/python-shell/src/test/test_gaffer_operations.py +++ b/python-shell/src/test/test_gaffer_operations.py @@ -18,6 +18,7 @@ import unittest from gafferpy import gaffer as g +from gafferpy.gaffer_operations import GetSchema class GafferOperationsTest(unittest.TestCase): @@ -1107,8 +1108,7 @@ class GafferOperationsTest(unittest.TestCase): "directedType" : "EITHER", "matchedVertex" : "SOURCE", "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" - } ], - "seedMatching": "EQUAL" + } ] } ''', g.GetElements( @@ -1122,8 +1122,7 @@ class GafferOperationsTest(unittest.TestCase): destination=3, matched_vertex="SOURCE" ) - ], - seed_matching=g.SeedMatchingType.EQUAL + ] ) ], [ @@ -4398,7 +4397,7 @@ class GafferOperationsTest(unittest.TestCase): "compact": true } ''', - g.GetSchema( + GetSchema( compact=True ) ], @@ -5373,7 +5372,7 @@ class GafferOperationsTest(unittest.TestCase): ] } }, - "include_partial": false, + "includePartial": false, "resultsLimit": 500000, "input": [{ "class": "uk.gov.gchq.gaffer.operation.data.EntitySeed", @@ -5475,10 +5474,6 @@ def test_get_walks_correct_op(self): self.assertEqual(g.GetWalks( operations=[g.GetElements()]), expected_output_json) - def test_get_walks_incorrect_op(self): - with self.assertRaises(TypeError): - g.GetWalks(operations=[g.GetAllElements()]) - def test_get_walks_correct_json(self): get_elements_json = { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements" @@ -5494,13 +5489,6 @@ def test_get_walks_correct_json(self): expected_output_json ) - def test_get_walks_incorect_json(self): - get_all_elements_json = { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - } - with self.assertRaises(TypeError): - g.GetWalks(operations=[get_all_elements_json]) - def test_federated_graph_ids_helper(self): expected_output_json = { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", diff --git a/python-shell/src/test/test_gaffer_operations_it.py b/python-shell/src/test/test_gaffer_operations_it.py index c7d6771c8..8065a1335 100755 --- a/python-shell/src/test/test_gaffer_operations_it.py +++ b/python-shell/src/test/test_gaffer_operations_it.py @@ -22,9 +22,9 @@ class GafferOperationsIntegrationTest(unittest.TestCase): - def test_all_operations_have_classes(self): + def test_all_supported_operations_have_classes(self): gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest') + 'http://localhost:8080/rest') operations = gc.execute_get( g.GetOperations() ) @@ -33,6 +33,31 @@ def test_all_operations_have_classes(self): self.assertTrue(op in g.JsonConverter.GENERIC_JSON_CONVERTERS, 'Missing operation class: ' + op) + def _get_all_subclasses(self, cls): + all_subclasses = [] + + for subclass in cls.__subclasses__(): + all_subclasses.append(subclass) + all_subclasses.extend(self._get_all_subclasses(subclass)) + + return all_subclasses + + def test_all_operations_have_classes(self): + gc = gaffer_connector.GafferConnector('http://localhost:8080/rest') + + response = gc.execute_get( + g.GetAllOperationDetails(), + json_result=True + ) + response = [operation["name"] for operation in response] + + operation_subclasses = self._get_all_subclasses(g.Operation) + expected_response = set(c.CLASS for c in operation_subclasses) + + self.assertEqual( + sorted(expected_response), + sorted(response) + ) if __name__ == "__main__": unittest.main() diff --git a/python-shell/src/test/test_gaffer_predicates_it.py b/python-shell/src/test/test_gaffer_predicates_it.py index 7b32b29e2..0df6ed24d 100755 --- a/python-shell/src/test/test_gaffer_predicates_it.py +++ b/python-shell/src/test/test_gaffer_predicates_it.py @@ -24,7 +24,7 @@ class GafferPredicatesIntegrationTest(unittest.TestCase): def test_all_predicates_have_classes(self): gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest') + 'http://localhost:8080/rest') predicates = gc.execute_get( g.GetFilterFunctions() )