summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/internal.py
blob: 66ad45f2a0d48668821f29a4ed59d8d130d16307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Authors:
#   Pavel Zuna <pzuna@redhat.com>
#   Adam YOung <ayoung@redhat.com>
#
# Copyright (c) 2010  Red Hat
# See file 'copying' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""
Plugins not accessible directly through the CLI, commands used internally
"""

import json

from ipalib import api, errors
from ipalib import Command
from ipalib import Str
from ipalib.output import Output
from ipalib.text import _
from ipalib.util import json_serialize

class json_metadata(Command):
    """
    Export plugin meta-data for the webUI.
    """
    NO_CLI = True


    takes_args = (
        Str('objname?',
            doc=_('Name of object to export'),
        ),
    )

    has_output = (
        Output('metadata', dict, doc=_('Dict of JSON encoded IPA Objects')),
    )

    def execute(self, objname):

        if objname and objname in self.api.Object:

            meta = dict(
                result=dict(
                    ((objname, json_serialize(self.api.Object[objname])), )
                )
            )
            retval= dict([("metadata",meta)])

        else:
            meta=dict(
                (o.name, json_serialize(o)) for o in self.api.Object()
                )

            retval= dict([("metadata",meta)])

        return retval

    def output_for_cli(self, textui, result, *args, **options):
        print json.dumps(result, default=json_serialize)

api.register(json_metadata)

class i18n_messages(Command):
    NO_CLI = True

    messages={
        "login": {"header" :_("Logged In As")},
        "button":{
            "add":_("Add"),
            "find": _("Find"),
            "reset":_("Reset"),
            "update":_("Update"),
            "enroll":_("Enroll"),
            "remove":_("Delete"),
            },
        "facets":{
            "search":_("Search"),
            "details": _("Settings"),
            },
        "search":{
            "quick_links":_("Quick Links"),
            "select_all":_("Select All"),
            "unselect_all":_("Unselect All"),
            "delete_confirm":_("Are you sure you want to delete selected entries?"),
            },
        "details":{
            "identity":_("Identity Settings"),
            "account":_("Account Settings"),
            "contact":_("Contact Settings"),
            "mailing":_("Mailing Address"),
            "employee":_("Employee Information"),
            "misc":_("Misc. Information"),
            "to_top":_("Back to Top")},
        "tabs": {
            "identity":_("Identity"),
            "policy":_("Policy"),
            "audit": _("Audit"),
            "ipaserver":_("IPA Server"),
            "sudo":_("SUDO"),
            "hbac":_("HBAC"),
            "role":_("Role Based Access Control")},
        "association":{
            "managedby":_("Managed by"),
            "members":_("Members"),
            "membershipin":_("Membership in")},
        "ajax":{
            "401":_("Your kerberos ticket no longer valid."+
                "Please run KInit and then click 'retry'"+
                "If this is your first time running the IPA Web UI"+
                "<a href='/ipa/errors/ssbrowser.html'> "+
                "Follow these directions</a> to configure your browser.")
            },
        "dirty":_("This page has unsaved changes. Please save or revert."),
        }
    has_output = (
        Output('messages', dict, doc=_('Dict of I18N messages')),
    )
    def execute(self):
        return dict([("messages",json_serialize(self.messages))])

    def output_for_cli(self, textui, result, *args, **options):
        print json.dumps(result, default=json_serialize)


api.register(i18n_messages)