LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions
apdb_cli Namespace Reference

Functions

None main (Sequence[str]|None args=None)
 
None _create_sql_subcommand (argparse._SubParsersAction subparsers)
 
None _create_cassandra_subcommand (argparse._SubParsersAction subparsers)
 
None _list_cassandra_subcommand (argparse._SubParsersAction subparsers)
 
None _delete_cassandra_subcommand (argparse._SubParsersAction subparsers)
 
None _list_index_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_show_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_get_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_set_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_delete_subcommand (argparse._SubParsersAction subparsers)
 

Function Documentation

◆ _create_cassandra_subcommand()

None apdb_cli._create_cassandra_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 68 of file apdb_cli.py.

68def _create_cassandra_subcommand(subparsers: argparse._SubParsersAction) -> None:
69 parser = subparsers.add_parser("create-cassandra", help="Create new APDB instance in Cassandra cluster.")
70 parser.add_argument("host", help="One or more host names for Cassandra cluster.", nargs="+")
71 parser.add_argument(
72 "keyspace", help="Cassandra keyspace name for APDB tables, will be created if does not exist."
73 )
74 parser.add_argument("output_config", help="Name of the new configuration file for created APDB instance.")
77 parser.add_argument(
78 "--drop", help="If True then drop existing tables.", default=False, action="store_true"
79 )
80 parser.set_defaults(method=scripts.create_cassandra)
81
82
None common_apdb_options(argparse.ArgumentParser parser)
Definition options.py:54
None cassandra_config_options(argparse.ArgumentParser parser)
Definition options.py:87

◆ _create_sql_subcommand()

None apdb_cli._create_sql_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 56 of file apdb_cli.py.

56def _create_sql_subcommand(subparsers: argparse._SubParsersAction) -> None:
57 parser = subparsers.add_parser("create-sql", help="Create new APDB instance in SQL database.")
58 parser.add_argument("db_url", help="Database URL in SQLAlchemy format for APDB instance.")
59 parser.add_argument("output_config", help="Name of the new configuration file for created APDB instance.")
62 parser.add_argument(
63 "--drop", help="If True then drop existing tables.", default=False, action="store_true"
64 )
65 parser.set_defaults(method=scripts.create_sql)
66
67
None sql_config_options(argparse.ArgumentParser parser)
Definition options.py:67

◆ _delete_cassandra_subcommand()

None apdb_cli._delete_cassandra_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 96 of file apdb_cli.py.

96def _delete_cassandra_subcommand(subparsers: argparse._SubParsersAction) -> None:
97 parser = subparsers.add_parser("delete-cassandra", help="Delete APDB instance from Cassandra cluster.")
98 parser.add_argument("host", help="One of the host names for Cassandra cluster.")
99 parser.add_argument("keyspace", help="Cassandra keyspace name for APDB tables.")
100 parser.add_argument(
101 "-y",
102 "--confirm",
103 help="Assume 'yes' answer for confirmation.",
104 default=False,
105 action="store_true",
106 )
107 parser.set_defaults(method=scripts.delete_cassandra)
108
109

◆ _list_cassandra_subcommand()

None apdb_cli._list_cassandra_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 83 of file apdb_cli.py.

83def _list_cassandra_subcommand(subparsers: argparse._SubParsersAction) -> None:
84 parser = subparsers.add_parser("list-cassandra", help="List APDB instances in Cassandra cluster.")
85 parser.add_argument("host", help="One of the host names for Cassandra cluster.")
86 parser.add_argument(
87 "-v",
88 "--verbose",
89 help="Provide full list of roles and associated permissions.",
90 default=False,
91 action="store_true",
92 )
93 parser.set_defaults(method=scripts.list_cassandra)
94
95

◆ _list_index_subcommand()

None apdb_cli._list_index_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 110 of file apdb_cli.py.

110def _list_index_subcommand(subparsers: argparse._SubParsersAction) -> None:
111 parser = subparsers.add_parser("list-index", help="List contents of APDB index file.")
112 parser.add_argument(
113 "index_path", help="Location of index file, if missing then $DAX_APDB_INDEX_URI is used.", nargs="?"
114 )
115 parser.set_defaults(method=scripts.list_index)
116
117

◆ _metadata_delete_subcommand()

None apdb_cli._metadata_delete_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 163 of file apdb_cli.py.

163def _metadata_delete_subcommand(subparsers: argparse._SubParsersAction) -> None:
164 parser = subparsers.add_parser("delete", help="Delete metadata item.")
165 parser.add_argument("config", help="Path or URI of APDB configuration file.")
166 parser.add_argument("key", help="Metadata key, arbitrary string.")
167 parser.set_defaults(method=scripts.metadata_delete)

◆ _metadata_get_subcommand()

None apdb_cli._metadata_get_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 141 of file apdb_cli.py.

141def _metadata_get_subcommand(subparsers: argparse._SubParsersAction) -> None:
142 parser = subparsers.add_parser("get", help="Print value of the metadata item.")
143 parser.add_argument("config", help="Path or URI of APDB configuration file.")
144 parser.add_argument("key", help="Metadata key, arbitrary string.")
145 parser.set_defaults(method=scripts.metadata_get)
146
147

◆ _metadata_set_subcommand()

None apdb_cli._metadata_set_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 148 of file apdb_cli.py.

148def _metadata_set_subcommand(subparsers: argparse._SubParsersAction) -> None:
149 parser = subparsers.add_parser("set", help="Add or update metadata item.")
150 parser.add_argument(
151 "-f",
152 "--force",
153 help="Force update of the existing key.",
154 default=False,
155 action="store_true",
156 )
157 parser.add_argument("config", help="Path or URI of APDB configuration file.")
158 parser.add_argument("key", help="Metadata key, arbitrary string.")
159 parser.add_argument("value", help="Corresponding metadata value.")
160 parser.set_defaults(method=scripts.metadata_set)
161
162

◆ _metadata_show_subcommand()

None apdb_cli._metadata_show_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 127 of file apdb_cli.py.

127def _metadata_show_subcommand(subparsers: argparse._SubParsersAction) -> None:
128 parser = subparsers.add_parser("show", help="Show contents of APDB metadata table.")
129 parser.add_argument(
130 "-j",
131 "--json",
132 dest="use_json",
133 help="Dump metadata in JSON format.",
134 default=False,
135 action="store_true",
136 )
137 parser.add_argument("config", help="Path or URI of APDB configuration file.")
138 parser.set_defaults(method=scripts.metadata_show)
139
140

◆ _metadata_subcommand()

None apdb_cli._metadata_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 118 of file apdb_cli.py.

118def _metadata_subcommand(subparsers: argparse._SubParsersAction) -> None:
119 parser = subparsers.add_parser("metadata", help="Operations with APDB metadata table.")
120 subparsers = parser.add_subparsers(title="available subcommands", required=True)
121 _metadata_set_subcommand(subparsers)
122 _metadata_get_subcommand(subparsers)
123 _metadata_show_subcommand(subparsers)
124 _metadata_delete_subcommand(subparsers)
125
126

◆ main()

None apdb_cli.main ( Sequence[str] | None args = None)
APDB command line tools.

Definition at line 34 of file apdb_cli.py.

34def main(args: Sequence[str] | None = None) -> None:
35 """APDB command line tools."""
36 parser = argparse.ArgumentParser(description="APDB command line tools")
37 log_cli = LoggingCli(parser)
38
39 subparsers = parser.add_subparsers(title="available subcommands", required=True)
40 _create_sql_subcommand(subparsers)
41 _create_cassandra_subcommand(subparsers)
42 _list_cassandra_subcommand(subparsers)
43 _delete_cassandra_subcommand(subparsers)
44 _list_index_subcommand(subparsers)
45 _metadata_subcommand(subparsers)
46
47 parsed_args = parser.parse_args(args)
48 log_cli.process_args(parsed_args)
49
50 kwargs = vars(parsed_args)
51 # Strip keywords not understood by scripts.
52 method = kwargs.pop("method")
53 method(**kwargs)
54
55
int main(void)