Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
is_ok = graphene.Boolean()
@staticmethod
def publish(payload, info):
"""Send the subscription notification."""
del payload, info
return OnTrigger(is_ok=True)
class Subscription(graphene.ObjectType):
"""Root subscription."""
on_trigger = OnTrigger.Field()
class Mutation(graphene.ObjectType):
"""Root mutation."""
trigger = Trigger.Field()
import graphene
import graphql_jwt
import events.schema
import users.schema
# Query for getting the data from the server.
class Query(users.schema.Query, events.schema.Query, graphene.ObjectType):
pass
# Mutation for sending the data to the server.
class Mutation(users.schema.Mutation, events.schema.Mutation, graphene.ObjectType):
token_auth = graphql_jwt.ObtainJSONWebToken.Field()
verify_token = graphql_jwt.Verify.Field()
refresh_token = graphql_jwt.Refresh.Field()
# Create schema
schema = graphene.Schema(query=Query, mutation=Mutation)
host = graphene.String()
time = graphene.String()
pid = graphene.String()
class OsVersion(graphene.ObjectType):
name = graphene.String()
version = graphene.String()
major = graphene.String()
minor = graphene.String()
patch = graphene.String()
build = graphene.String()
platform = graphene.String()
platform_like = graphene.String()
codename = graphene.String()
class PlatformInfo(graphene.ObjectType):
vendor = graphene.String()
version = graphene.String()
date = graphene.String()
revision = graphene.String()
address = graphene.String()
size = graphene.String()
volume_size = graphene.String()
extra = graphene.String()
class ProcessOpenSockets(graphene.ObjectType):
pid = graphene.String()
fd = graphene.String()
socket = graphene.String()
family = graphene.String()
protocol = graphene.String()
local_address = graphene.String()
# {{{1 Custom Nodes
# {{{2 TruncDate Node
class TruncDateNode(graphene.ObjectType):
timestop = graphene.DateTime()
count = graphene.Int()
def resolve_timestop(self, info):
return self.get('timestop')
def resolve_count(self, info):
return self.get('count')
# {{{2 TruncValue Node
class TruncValueNode(graphene.ObjectType):
value = graphene.Int()
count = graphene.Int()
def resolve_value(self, info):
return self.get('value')
def resolve_count(self, info):
return self.get('count')
# {{{2 Wiki Node
class WikiNode(graphene.ObjectType):
id = graphene.ID(required=True)
content = graphene.String()
class Meta:
day = graphene.String()
events = graphene.List(CalendarEvent)
class PaginatedEvents(graphene.ObjectType):
"""
Paginated result for daily room events
analytics
"""
DailyRoomEvents = graphene.List(DailyEvents)
has_previous = graphene.Boolean()
has_next = graphene.Boolean()
pages = graphene.Int()
class AvailableRooms(graphene.ObjectType):
id = graphene.String()
name = graphene.String()
class AllAvailableRooms(graphene.ObjectType):
availableRoom = graphene.List(AvailableRooms)
class Query(graphene.ObjectType):
"""
Returns paginated rooms
"""
all_rooms = graphene.Field(
PaginatedRooms,
room_labels=graphene.String(),
page=graphene.Int(),
def resolve_chat_group(self, info, **kwargs):
id = kwargs.get('id')
if id is not None:
return ChatGroup.objects.get(id=id)
return None
def resolve_chat_groups(self, info, **kwargs):
return ChatGroup.objects.all()
def resolve_chat_users(self, info, **kwargs):
return User.objects.all()
class ChatMutation(graphene.ObjectType):
create_message = CreateMessage.Field()
create_group = CreateGroup.Field()
schema = graphene.Schema(query=ChatQuery, mutation=ChatMutation)
import graphene
from apps.account.mutations import (
Activate,
DeleteAccount,
Login,
RefreshToken,
Register,
ResetPassword,
ResetPasswordConfirm,
)
from apps.account.schema import User, Viewer
class RootQuery(graphene.ObjectType):
viewer = graphene.Field(Viewer)
def resolve_viewer(self, info, **kwargs):
if info.context.user.is_authenticated:
return info.context.user
return None
class Mutation(graphene.ObjectType):
activate = Activate.Field()
login = Login.Field()
register = Register.Field()
deleteAccount = DeleteAccount.Field()
refreshToken = RefreshToken.Field()
resetPassword = ResetPassword.Field()
resetPasswordConfirm = ResetPasswordConfirm.Field()
\n- structure_ids: The structure_id of the structure(s)"
)
update_office_structure = UpdateOfficeStructure.Field(
description="Updates an office structure and takes the arguments\
\n- structure_id: The structure id for the office structure\
\n- level: The level of the office structure\
\n- name: The name of the office structure\
\n- parent_id: The parent id of the office structure\
\n- parent_title: The parent title of the structure\
\n- tag: Tags for the office structure\
\n- location_id: The location id of the office structure\
\n- position: The position of the office structure"
)
class Query(graphene.ObjectType):
"""
Query for office structures
"""
all_structures = graphene.List(
Structure,
description="Returns a list containing all office structures")
structure_by_structure_id = graphene.Field(
Structure, structure_id=graphene.String(), description="Returns the office \
structure corresponding to the provided structureId")
@Auth.user_roles('Admin', 'Default User', 'Super Admin')
def resolve_all_structures(self, info):
query = Structure.get_query(info)
location_id = admin_roles.user_location_for_analytics_view()
all_structures = query.filter(
StructureModel.state == "active",
from graphene import List, ObjectType
from .sql.types import DjangoDebugSQL
class DjangoDebug(ObjectType):
class Meta:
description = "Debugging information for the current query."
sql = List(DjangoDebugSQL, description="Executed SQL queries for this API query.")
chassis_type = graphene.String(required=True)
part_number = graphene.String(required=True)
serial_number = graphene.String(required=True)
class ProductInfo(graphene.ObjectType):
asset_tag = graphene.String()
manufacturer = graphene.String()
part_number = graphene.String()
product_name = graphene.String()
serial_number = graphene.String(required=True)
version = graphene.String()
@setup_resolve
class Asset(graphene.ObjectType):
_data = None
_fields = [
('board_info', BoardInfo),
('chassis_info', ChassisInfo),
('product_info', ProductInfo)
]
board_info = graphene.Field(BoardInfo, required=True)
chassis_info = graphene.Field(ChassisInfo, required=True)
product_info = graphene.Field(ProductInfo, required=True)
class DeviceInterface(graphene.Interface):
_data = None
id = graphene.String(required=True)