opsmanager 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2024 Frank Snow
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,259 @@
1
+ Metadata-Version: 2.4
2
+ Name: opsmanager
3
+ Version: 0.1.0
4
+ Summary: Python client library for MongoDB Ops Manager API
5
+ Author-email: Frank Snow <frank.snow@mongodb.com>
6
+ Maintainer-email: Frank Snow <frank.snow@mongodb.com>
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/fsnow/python-mongodb-ops-manager
9
+ Project-URL: Documentation, https://github.com/fsnow/python-mongodb-ops-manager#readme
10
+ Project-URL: Repository, https://github.com/fsnow/python-mongodb-ops-manager.git
11
+ Project-URL: Issues, https://github.com/fsnow/python-mongodb-ops-manager/issues
12
+ Keywords: mongodb,ops-manager,cloud-manager,api,client,monitoring,database
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Database
25
+ Classifier: Topic :: System :: Monitoring
26
+ Classifier: Topic :: System :: Systems Administration
27
+ Classifier: Typing :: Typed
28
+ Requires-Python: >=3.9
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: requests>=2.28.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
34
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
35
+ Requires-Dist: black>=23.0.0; extra == "dev"
36
+ Requires-Dist: isort>=5.12.0; extra == "dev"
37
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
38
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
39
+ Requires-Dist: types-requests>=2.28.0; extra == "dev"
40
+ Provides-Extra: docs
41
+ Requires-Dist: sphinx>=6.0.0; extra == "docs"
42
+ Requires-Dist: sphinx-rtd-theme>=1.2.0; extra == "docs"
43
+ Dynamic: license-file
44
+
45
+ # python-mongodb-ops-manager
46
+
47
+ Python client library for MongoDB Ops Manager API
48
+
49
+ ## Status
50
+
51
+ **Beta** - Core functionality implemented and tested against live Ops Manager
52
+
53
+ ## Overview
54
+
55
+ A production-quality Python client library for the MongoDB Ops Manager API, designed to enable automated health checks, metrics collection, and fleet management for MongoDB deployments.
56
+
57
+ ## Features
58
+
59
+ - **Production-ready** - Built-in rate limiting, error handling, retry logic with exponential backoff
60
+ - **Type-safe** - Full type hints throughout with dataclass models
61
+ - **Pythonic** - Clean, idiomatic Python API design
62
+ - **Safe by default** - Conservative rate limiting to protect production Ops Manager instances
63
+ - **Tested** - Validated against live Ops Manager and cross-checked with mongocli (Go SDK)
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ pip install opsmanager
69
+ ```
70
+
71
+ Or install from source:
72
+
73
+ ```bash
74
+ git clone https://github.com/fsnow/python-mongodb-ops-manager.git
75
+ cd python-mongodb-ops-manager
76
+ pip install -e .
77
+ ```
78
+
79
+ ## Quick Start
80
+
81
+ ```python
82
+ from opsmanager import OpsManagerClient
83
+
84
+ # Create client
85
+ client = OpsManagerClient(
86
+ base_url="https://ops-manager.example.com",
87
+ public_key="your-public-key",
88
+ private_key="your-private-key",
89
+ )
90
+
91
+ # List all projects
92
+ projects = client.projects.list()
93
+ for project in projects:
94
+ print(f"Project: {project.name} ({project.id})")
95
+
96
+ # Get hosts in a project
97
+ hosts = client.deployments.list_hosts(project_id="your-project-id")
98
+ for host in hosts:
99
+ print(f"Host: {host.hostname}:{host.port} - {host.replica_state_name}")
100
+
101
+ # Get metrics for a host (last 24 hours, 1-minute granularity)
102
+ metrics = client.measurements.host(
103
+ project_id="your-project-id",
104
+ host_id="host-id",
105
+ granularity="PT1M",
106
+ period="P1D",
107
+ metrics=["OPCOUNTER_QUERY", "OPCOUNTER_INSERT", "CONNECTIONS"],
108
+ )
109
+
110
+ # Get Performance Advisor suggestions
111
+ suggestions = client.performance_advisor.get_suggested_indexes(
112
+ project_id="your-project-id",
113
+ host_id="hostname:27017",
114
+ duration=86400000, # 24 hours in milliseconds
115
+ )
116
+
117
+ # Clean up
118
+ client.close()
119
+ ```
120
+
121
+ ### Using as Context Manager
122
+
123
+ ```python
124
+ with OpsManagerClient(
125
+ base_url="https://ops-manager.example.com",
126
+ public_key="your-public-key",
127
+ private_key="your-private-key",
128
+ ) as client:
129
+ projects = client.projects.list()
130
+ ```
131
+
132
+ ## API Coverage
133
+
134
+ ### Currently Implemented
135
+
136
+ | Service | Description |
137
+ |---------|-------------|
138
+ | `organizations` | List organizations, get org details, list projects in org |
139
+ | `projects` | List projects, get project by ID or name |
140
+ | `clusters` | List clusters, get cluster details |
141
+ | `deployments` | List hosts, databases, disks; get by ID or name |
142
+ | `measurements` | Host, database, and disk metrics with time-series data |
143
+ | `performance_advisor` | Namespaces, slow queries, suggested indexes |
144
+ | `alerts` | List alerts, acknowledge alerts |
145
+
146
+ ### Configuration Options
147
+
148
+ ```python
149
+ client = OpsManagerClient(
150
+ base_url="https://ops-manager.example.com",
151
+ public_key="your-public-key",
152
+ private_key="your-private-key",
153
+ timeout=30.0, # Request timeout in seconds
154
+ rate_limit=2.0, # Max requests per second (conservative default)
155
+ retry_count=3, # Number of retries for failed requests
156
+ retry_backoff=1.0, # Base backoff time between retries
157
+ verify_ssl=True, # Verify SSL certificates
158
+ )
159
+ ```
160
+
161
+ ### Rate Limiting
162
+
163
+ Rate limiting is **built-in and enabled by default** to protect production Ops Manager instances. The default is 2 requests per second, which is conservative but safe.
164
+
165
+ ```python
166
+ # Adjust rate limit if needed (be careful with production systems!)
167
+ client.set_rate_limit(5.0) # 5 requests per second
168
+ ```
169
+
170
+ ### Pagination
171
+
172
+ All list methods support pagination automatically:
173
+
174
+ ```python
175
+ # Fetch all results (handles pagination internally)
176
+ all_hosts = client.deployments.list_hosts(project_id="abc123")
177
+
178
+ # Or iterate with automatic pagination
179
+ for host in client.deployments.list_hosts_iter(project_id="abc123"):
180
+ print(host.hostname)
181
+ ```
182
+
183
+ ### Return Types
184
+
185
+ All methods support returning either typed objects or raw dictionaries:
186
+
187
+ ```python
188
+ # Return typed objects (default)
189
+ hosts = client.deployments.list_hosts(project_id="abc123", as_obj=True)
190
+ print(hosts[0].hostname) # IDE autocomplete works
191
+
192
+ # Return raw dictionaries
193
+ hosts = client.deployments.list_hosts(project_id="abc123", as_obj=False)
194
+ print(hosts[0]["hostname"])
195
+ ```
196
+
197
+ ## Testing
198
+
199
+ ### Live Integration Tests
200
+
201
+ Run the integration test suite against a live Ops Manager instance:
202
+
203
+ ```bash
204
+ export OM_BASE_URL="http://ops-manager.example.com:8081"
205
+ export OM_PUBLIC_KEY="your-public-key"
206
+ export OM_PRIVATE_KEY="your-private-key"
207
+
208
+ python tests/test_live.py --verbose
209
+ ```
210
+
211
+ ### Validation Against mongocli
212
+
213
+ Compare output against the official MongoDB CLI (uses the Go SDK):
214
+
215
+ ```bash
216
+ export OM_ORG_ID="your-org-id"
217
+ export OM_PROJECT_ID="your-project-id"
218
+
219
+ python tests/validate_against_mongocli.py
220
+ ```
221
+
222
+ ## Design Principles
223
+
224
+ This library is modeled after the official [MongoDB Go SDK](https://github.com/mongodb/go-client-mongodb-ops-manager) with Pythonic adaptations:
225
+
226
+ 1. **Service-oriented architecture** - Logical grouping of API endpoints
227
+ 2. **Explicit over implicit** - Project ID passed per-call, not stored globally
228
+ 3. **Safe defaults** - Rate limiting and SSL verification enabled by default
229
+ 4. **Flexible output** - Choose between typed objects or raw dictionaries
230
+
231
+ ## Use Cases
232
+
233
+ - Automated health check reporting for large MongoDB fleets
234
+ - Metrics collection and statistical analysis
235
+ - Performance advisor recommendations aggregation
236
+ - Cluster topology documentation
237
+ - Operational automation and scripting
238
+
239
+ ## Inspiration
240
+
241
+ - **Go SDK**: [go-client-mongodb-ops-manager](https://github.com/mongodb/go-client-mongodb-ops-manager) - Official MongoDB Go client
242
+ - **Python**: [atlasapi](https://pypi.org/project/atlasapi/) - Community Atlas API library
243
+
244
+ ## Requirements
245
+
246
+ - Python 3.9+
247
+ - `requests` library
248
+
249
+ ## License
250
+
251
+ Apache License 2.0 - See [LICENSE](LICENSE) for details.
252
+
253
+ ## Contributing
254
+
255
+ Contributions welcome! Please open an issue or pull request.
256
+
257
+ ## Disclaimer
258
+
259
+ This is an independent project and is not officially affiliated with or endorsed by MongoDB, Inc.
@@ -0,0 +1,215 @@
1
+ # python-mongodb-ops-manager
2
+
3
+ Python client library for MongoDB Ops Manager API
4
+
5
+ ## Status
6
+
7
+ **Beta** - Core functionality implemented and tested against live Ops Manager
8
+
9
+ ## Overview
10
+
11
+ A production-quality Python client library for the MongoDB Ops Manager API, designed to enable automated health checks, metrics collection, and fleet management for MongoDB deployments.
12
+
13
+ ## Features
14
+
15
+ - **Production-ready** - Built-in rate limiting, error handling, retry logic with exponential backoff
16
+ - **Type-safe** - Full type hints throughout with dataclass models
17
+ - **Pythonic** - Clean, idiomatic Python API design
18
+ - **Safe by default** - Conservative rate limiting to protect production Ops Manager instances
19
+ - **Tested** - Validated against live Ops Manager and cross-checked with mongocli (Go SDK)
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install opsmanager
25
+ ```
26
+
27
+ Or install from source:
28
+
29
+ ```bash
30
+ git clone https://github.com/fsnow/python-mongodb-ops-manager.git
31
+ cd python-mongodb-ops-manager
32
+ pip install -e .
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ```python
38
+ from opsmanager import OpsManagerClient
39
+
40
+ # Create client
41
+ client = OpsManagerClient(
42
+ base_url="https://ops-manager.example.com",
43
+ public_key="your-public-key",
44
+ private_key="your-private-key",
45
+ )
46
+
47
+ # List all projects
48
+ projects = client.projects.list()
49
+ for project in projects:
50
+ print(f"Project: {project.name} ({project.id})")
51
+
52
+ # Get hosts in a project
53
+ hosts = client.deployments.list_hosts(project_id="your-project-id")
54
+ for host in hosts:
55
+ print(f"Host: {host.hostname}:{host.port} - {host.replica_state_name}")
56
+
57
+ # Get metrics for a host (last 24 hours, 1-minute granularity)
58
+ metrics = client.measurements.host(
59
+ project_id="your-project-id",
60
+ host_id="host-id",
61
+ granularity="PT1M",
62
+ period="P1D",
63
+ metrics=["OPCOUNTER_QUERY", "OPCOUNTER_INSERT", "CONNECTIONS"],
64
+ )
65
+
66
+ # Get Performance Advisor suggestions
67
+ suggestions = client.performance_advisor.get_suggested_indexes(
68
+ project_id="your-project-id",
69
+ host_id="hostname:27017",
70
+ duration=86400000, # 24 hours in milliseconds
71
+ )
72
+
73
+ # Clean up
74
+ client.close()
75
+ ```
76
+
77
+ ### Using as Context Manager
78
+
79
+ ```python
80
+ with OpsManagerClient(
81
+ base_url="https://ops-manager.example.com",
82
+ public_key="your-public-key",
83
+ private_key="your-private-key",
84
+ ) as client:
85
+ projects = client.projects.list()
86
+ ```
87
+
88
+ ## API Coverage
89
+
90
+ ### Currently Implemented
91
+
92
+ | Service | Description |
93
+ |---------|-------------|
94
+ | `organizations` | List organizations, get org details, list projects in org |
95
+ | `projects` | List projects, get project by ID or name |
96
+ | `clusters` | List clusters, get cluster details |
97
+ | `deployments` | List hosts, databases, disks; get by ID or name |
98
+ | `measurements` | Host, database, and disk metrics with time-series data |
99
+ | `performance_advisor` | Namespaces, slow queries, suggested indexes |
100
+ | `alerts` | List alerts, acknowledge alerts |
101
+
102
+ ### Configuration Options
103
+
104
+ ```python
105
+ client = OpsManagerClient(
106
+ base_url="https://ops-manager.example.com",
107
+ public_key="your-public-key",
108
+ private_key="your-private-key",
109
+ timeout=30.0, # Request timeout in seconds
110
+ rate_limit=2.0, # Max requests per second (conservative default)
111
+ retry_count=3, # Number of retries for failed requests
112
+ retry_backoff=1.0, # Base backoff time between retries
113
+ verify_ssl=True, # Verify SSL certificates
114
+ )
115
+ ```
116
+
117
+ ### Rate Limiting
118
+
119
+ Rate limiting is **built-in and enabled by default** to protect production Ops Manager instances. The default is 2 requests per second, which is conservative but safe.
120
+
121
+ ```python
122
+ # Adjust rate limit if needed (be careful with production systems!)
123
+ client.set_rate_limit(5.0) # 5 requests per second
124
+ ```
125
+
126
+ ### Pagination
127
+
128
+ All list methods support pagination automatically:
129
+
130
+ ```python
131
+ # Fetch all results (handles pagination internally)
132
+ all_hosts = client.deployments.list_hosts(project_id="abc123")
133
+
134
+ # Or iterate with automatic pagination
135
+ for host in client.deployments.list_hosts_iter(project_id="abc123"):
136
+ print(host.hostname)
137
+ ```
138
+
139
+ ### Return Types
140
+
141
+ All methods support returning either typed objects or raw dictionaries:
142
+
143
+ ```python
144
+ # Return typed objects (default)
145
+ hosts = client.deployments.list_hosts(project_id="abc123", as_obj=True)
146
+ print(hosts[0].hostname) # IDE autocomplete works
147
+
148
+ # Return raw dictionaries
149
+ hosts = client.deployments.list_hosts(project_id="abc123", as_obj=False)
150
+ print(hosts[0]["hostname"])
151
+ ```
152
+
153
+ ## Testing
154
+
155
+ ### Live Integration Tests
156
+
157
+ Run the integration test suite against a live Ops Manager instance:
158
+
159
+ ```bash
160
+ export OM_BASE_URL="http://ops-manager.example.com:8081"
161
+ export OM_PUBLIC_KEY="your-public-key"
162
+ export OM_PRIVATE_KEY="your-private-key"
163
+
164
+ python tests/test_live.py --verbose
165
+ ```
166
+
167
+ ### Validation Against mongocli
168
+
169
+ Compare output against the official MongoDB CLI (uses the Go SDK):
170
+
171
+ ```bash
172
+ export OM_ORG_ID="your-org-id"
173
+ export OM_PROJECT_ID="your-project-id"
174
+
175
+ python tests/validate_against_mongocli.py
176
+ ```
177
+
178
+ ## Design Principles
179
+
180
+ This library is modeled after the official [MongoDB Go SDK](https://github.com/mongodb/go-client-mongodb-ops-manager) with Pythonic adaptations:
181
+
182
+ 1. **Service-oriented architecture** - Logical grouping of API endpoints
183
+ 2. **Explicit over implicit** - Project ID passed per-call, not stored globally
184
+ 3. **Safe defaults** - Rate limiting and SSL verification enabled by default
185
+ 4. **Flexible output** - Choose between typed objects or raw dictionaries
186
+
187
+ ## Use Cases
188
+
189
+ - Automated health check reporting for large MongoDB fleets
190
+ - Metrics collection and statistical analysis
191
+ - Performance advisor recommendations aggregation
192
+ - Cluster topology documentation
193
+ - Operational automation and scripting
194
+
195
+ ## Inspiration
196
+
197
+ - **Go SDK**: [go-client-mongodb-ops-manager](https://github.com/mongodb/go-client-mongodb-ops-manager) - Official MongoDB Go client
198
+ - **Python**: [atlasapi](https://pypi.org/project/atlasapi/) - Community Atlas API library
199
+
200
+ ## Requirements
201
+
202
+ - Python 3.9+
203
+ - `requests` library
204
+
205
+ ## License
206
+
207
+ Apache License 2.0 - See [LICENSE](LICENSE) for details.
208
+
209
+ ## Contributing
210
+
211
+ Contributions welcome! Please open an issue or pull request.
212
+
213
+ ## Disclaimer
214
+
215
+ This is an independent project and is not officially affiliated with or endorsed by MongoDB, Inc.