How to use the gql.gql.client.OperationException function in gql

To help you get started, we’ve selected a few gql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github magma / magma / symphony / cli / pyinventory / graphql / mutation / move_location.py View on Github external
def execute(cls, client: GraphqlClient, locationID: str, parentLocationID: Optional[str] = None) -> MoveLocationMutationData.Location:
        # fmt: off
        variables: Dict[str, Any] = {"locationID": locationID, "parentLocationID": parentLocationID}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("MoveLocationMutation", variables, network_time, decode_time)
            return res.moveLocation
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "MoveLocationMutation",
                variables,
            )
github magma / magma / symphony / cli / pyinventory / graphql / mutation / edit_equipment_type.py View on Github external
def execute(cls, client: GraphqlClient, input: EditEquipmentTypeInput) -> EditEquipmentTypeMutationData.EquipmentType:
        # fmt: off
        variables: Dict[str, Any] = {"input": input}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("EditEquipmentTypeMutation", variables, network_time, decode_time)
            return res.editEquipmentType
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "EditEquipmentTypeMutation",
                variables,
            )
github magma / magma / symphony / cli / pyinventory / graphql / query / service_endpoints.py View on Github external
def execute(cls, client: GraphqlClient, id: str) -> Optional[ServiceEndpointsQueryData.Node]:
        # fmt: off
        variables: Dict[str, Any] = {"id": id}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("ServiceEndpointsQuery", variables, network_time, decode_time)
            return res.service
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "ServiceEndpointsQuery",
                variables,
            )
github magma / magma / symphony / cli / pyinventory / graphql / query / user.py View on Github external
def execute(cls, client: GraphqlClient, authID: str) -> Optional[UserQueryData.User]:
        # fmt: off
        variables: Dict[str, Any] = {"authID": authID}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("UserQuery", variables, network_time, decode_time)
            return res.user
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "UserQuery",
                variables,
            )
github magma / magma / symphony / cli / pyinventory / _location.py View on Github external
name=location_name,
                    type=client.locationTypes[location_type].id,
                    latitude=lat,
                    longitude=long,
                    properties=properties,
                    externalID=externalID,
                )

                try:
                    result = AddLocationMutation.execute(
                        client, add_location_input
                    ).__dict__[ADD_LOCATION_MUTATION_NAME]
                    client.reporter.log_successful_operation(
                        ADD_LOCATION_MUTATION_NAME, add_location_input.__dict__
                    )
                except OperationException as e:
                    raise FailedOperationException(
                        client.reporter,
                        e.err_msg,
                        e.err_id,
                        ADD_LOCATION_MUTATION_NAME,
                        add_location_input.__dict__,
                    )
                last_location = Location(
                    name=result.name,
                    id=result.id,
                    latitude=result.latitude,
                    longitude=result.longitude,
                    externalId=result.externalId,
                    locationTypeName=result.locationType.name,
                )
        else:
github magma / magma / symphony / cli / pyinventory / graphql / mutation / remove_service_type.py View on Github external
def execute(cls, client: GraphqlClient, id: str) -> str:
        # fmt: off
        variables: Dict[str, Any] = {"id": id}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("RemoveServiceTypeMutation", variables, network_time, decode_time)
            return res.removeServiceType
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "RemoveServiceTypeMutation",
                variables,
            )
github magma / magma / symphony / cli / pyinventory / graphql / mutation / create_survey.py View on Github external
def execute(cls, client: GraphqlClient, data: SurveyCreateData) -> str:
        # fmt: off
        variables: Dict[str, Any] = {"data": data}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("CreateSurveyMutation", variables, network_time, decode_time)
            return res.createSurvey
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "CreateSurveyMutation",
                variables,
            )
github magma / magma / symphony / cli / pyinventory / graphql / mutation / edit_equipment.py View on Github external
def execute(cls, client: GraphqlClient, input: EditEquipmentInput) -> EditEquipmentMutationData.Equipment:
        # fmt: off
        variables: Dict[str, Any] = {"input": input}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("EditEquipmentMutation", variables, network_time, decode_time)
            return res.editEquipment
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "EditEquipmentMutation",
                variables,
            )
github magma / magma / symphony / cli / pyinventory / graphql / mutation / edit_location.py View on Github external
def execute(cls, client: GraphqlClient, input: EditLocationInput) -> EditLocationMutationData.Location:
        # fmt: off
        variables: Dict[str, Any] = {"input": input}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("EditLocationMutation", variables, network_time, decode_time)
            return res.editLocation
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "EditLocationMutation",
                variables,
            )
github magma / magma / symphony / cli / pysymphony / graphql / mutation / delete_image.py View on Github external
def execute(cls, client: GraphqlClient, entityType: ImageEntity, entityId: str, id: str) -> DeleteImageMutationData.File:
        # fmt: off
        variables: Dict[str, Any] = {"entityType": entityType, "entityId": entityId, "id": id}
        try:
            network_start = perf_counter()
            response_text = client.call(''.join(set(QUERY)), variables=variables)
            decode_start = perf_counter()
            res = cls.from_json(response_text).data
            decode_time = perf_counter() - decode_start
            network_time = decode_start - network_start
            client.reporter.log_successful_operation("DeleteImageMutation", variables, network_time, decode_time)
            return res.deleteImage
        except OperationException as e:
            raise FailedOperationException(
                client.reporter,
                e.err_msg,
                e.err_id,
                "DeleteImageMutation",
                variables,
            )