Beispiel #1
0
def main_execution(program_args):

    host = determine_host()
    write_info("Retrieving IPV4 Address")
    ip_address = find_ip_address()

    if check_for_changes(ip_address) or program_args['notify']:

        formatted_chat_string = CHAT_STRING.format(server=host, ip=ip_address)

        # Notify Slack channel
        write_info("Sending Address to Slack Channel")
        Slack().notify(formatted_chat_string)

        # Notify Discord channel
        write_info("Sending Address to Discord Channel")
        Discord().notify(formatted_chat_string)

        # Notify Google DNS
        write_info("Sending Address to Google DNS")

        formatted_google_url = GOOGLE_DNS_URL_BASE.format(
            username=GOOGLE_USERNAME,
            password=GOOGLE_PASSWORD,
            subdomain=GOOGLE_DOMAIN,
            ip=ip_address)
        Webhook("Google DNS", formatted_google_url).api_post()
Beispiel #2
0
 def revoke_access(self, request, pk=None):
     new_hire = self.get_object()
     ScheduledAccess.objects.filter(
         new_hire=new_hire,
         integration=request.data['integration']).delete()
     if request.data['integration'] == 1:
         s = Slack()
         try:
             s.delete_user(new_hire.email)
         except PaidOnlyError:
             return Response({'error': 'paid'}, status=status.HTTP_400_BAD_REQUEST)
         except:
             return Response({'error': 'error'}, status=status.HTTP_400_BAD_REQUEST)
     if request.data['integration'] == 2:
         g = Google()
         g.delete_user(new_hire.email)
     return Response(status=status.HTTP_204_NO_CONTENT)