csp-billing-adapter-amazon 1.4.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.
- csp_billing_adapter_amazon-1.4.0/CHANGES.md +76 -0
- csp_billing_adapter_amazon-1.4.0/CONTRIBUTING.md +88 -0
- csp_billing_adapter_amazon-1.4.0/LICENSE +201 -0
- csp_billing_adapter_amazon-1.4.0/MANIFEST.in +13 -0
- csp_billing_adapter_amazon-1.4.0/PKG-INFO +121 -0
- csp_billing_adapter_amazon-1.4.0/README.md +70 -0
- csp_billing_adapter_amazon-1.4.0/csp-billing-adapter-amazon.spec +74 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon/__init__.py +19 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon/plugin.py +340 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon.egg-info/PKG-INFO +121 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon.egg-info/SOURCES.txt +22 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon.egg-info/dependency_links.txt +1 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon.egg-info/entry_points.txt +2 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon.egg-info/not-zip-safe +1 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon.egg-info/requires.txt +14 -0
- csp_billing_adapter_amazon-1.4.0/csp_billing_adapter_amazon.egg-info/top_level.txt +1 -0
- csp_billing_adapter_amazon-1.4.0/requirements-dev.txt +3 -0
- csp_billing_adapter_amazon-1.4.0/requirements-test.txt +5 -0
- csp_billing_adapter_amazon-1.4.0/requirements.txt +3 -0
- csp_billing_adapter_amazon-1.4.0/setup.cfg +25 -0
- csp_billing_adapter_amazon-1.4.0/setup.py +80 -0
- csp_billing_adapter_amazon-1.4.0/tests/data/good_config.yaml +29 -0
- csp_billing_adapter_amazon-1.4.0/tests/unit/test_plugin.py +349 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
v1.4.0 (2026-07-08)
|
|
2
|
+
-------------------
|
|
3
|
+
|
|
4
|
+
- Add pypi publishing workflow
|
|
5
|
+
- Fix license classifier in setup.py
|
|
6
|
+
- Fix pypi package name in spec file
|
|
7
|
+
- Fix csp billing adapter requirement
|
|
8
|
+
|
|
9
|
+
v1.3.0 (2025-11-19)
|
|
10
|
+
-------------------
|
|
11
|
+
|
|
12
|
+
- Add handling for REGION environment variable. If it is
|
|
13
|
+
set this is preferred to checking the metadata.
|
|
14
|
+
- Add handling for SKIP_METADATA environment variable.
|
|
15
|
+
If it is set the metadata request will be skipped in
|
|
16
|
+
account info function.
|
|
17
|
+
|
|
18
|
+
v1.2.1 (2025-06-10)
|
|
19
|
+
-------------------
|
|
20
|
+
|
|
21
|
+
- Make customer id required in meter billing hookspec
|
|
22
|
+
|
|
23
|
+
v1.2.0 (2025-02-21)
|
|
24
|
+
-------------------
|
|
25
|
+
|
|
26
|
+
- Add batch metering function to handle subscription billing
|
|
27
|
+
|
|
28
|
+
v1.1.0 (2024-11-25)
|
|
29
|
+
-------------------
|
|
30
|
+
|
|
31
|
+
- Add plugin file with plugin name for verification
|
|
32
|
+
|
|
33
|
+
v1.0.0 (2024-06-03)
|
|
34
|
+
-------------------
|
|
35
|
+
|
|
36
|
+
- Switch spec build to python 3.11
|
|
37
|
+
|
|
38
|
+
v0.5.1 (2023-10-02)
|
|
39
|
+
-------------------
|
|
40
|
+
|
|
41
|
+
- Fix metadata url typo
|
|
42
|
+
|
|
43
|
+
v0.5.0 (2023-09-20)
|
|
44
|
+
-------------------
|
|
45
|
+
|
|
46
|
+
- Implement get version hookspec
|
|
47
|
+
|
|
48
|
+
v0.4.0 (2023-08-24)
|
|
49
|
+
-------------------
|
|
50
|
+
|
|
51
|
+
- Add IPv6 support and IMDSv2
|
|
52
|
+
|
|
53
|
+
v0.3.0 (2023-08-01)
|
|
54
|
+
-------------------
|
|
55
|
+
|
|
56
|
+
- Handle billing multiple dimensions.
|
|
57
|
+
|
|
58
|
+
v0.2.1 (2023-06-16)
|
|
59
|
+
-------------------
|
|
60
|
+
|
|
61
|
+
- Add region to boto3 client session.
|
|
62
|
+
|
|
63
|
+
v0.2.0 (2023-05-24)
|
|
64
|
+
-------------------
|
|
65
|
+
|
|
66
|
+
- Use existing `get_csp_name` function to prevent duplication.
|
|
67
|
+
|
|
68
|
+
v0.1.0 (2023-05-19)
|
|
69
|
+
-------------------
|
|
70
|
+
|
|
71
|
+
- Add logging and tests to cover fail cases
|
|
72
|
+
|
|
73
|
+
v0.0.1 (2023-05-03)
|
|
74
|
+
-------------------
|
|
75
|
+
|
|
76
|
+
- initial release
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Installation
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
```shell
|
|
5
|
+
$ git clone https://github.com/SUSE-Enceladus/csp-billing-adapter-amazon.git
|
|
6
|
+
$ cd csp-billing-adapter-amazon
|
|
7
|
+
|
|
8
|
+
# Activate virtual Environment then install
|
|
9
|
+
# csp-billing-adapter-amazon and dev dependences in editable mode
|
|
10
|
+
$ pip install -e .[dev]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
csp-billing-adapter-amazon is now installed in the active virtual environment in development
|
|
14
|
+
mode.
|
|
15
|
+
|
|
16
|
+
Dev Requirements
|
|
17
|
+
================
|
|
18
|
+
|
|
19
|
+
- bumpversion
|
|
20
|
+
|
|
21
|
+
Testing Requirements
|
|
22
|
+
====================
|
|
23
|
+
|
|
24
|
+
- coverage
|
|
25
|
+
- flake8
|
|
26
|
+
- pytest-cov
|
|
27
|
+
|
|
28
|
+
Contribution Checklist
|
|
29
|
+
======================
|
|
30
|
+
|
|
31
|
+
- All patches must be signed. [Signing Commits](#signing-commits)
|
|
32
|
+
- All contributed code must conform to flake8. [Code Style](#code-style)
|
|
33
|
+
- All new code contributions must be accompanied by a test.
|
|
34
|
+
- Tests must pass and coverage remain above 90%. [Unit & Integration Tests](#unit-&-integration-tests)
|
|
35
|
+
- Follow Semantic Versioning. [Versions & Releases](#versions-&-releases)
|
|
36
|
+
|
|
37
|
+
Versions & Releases
|
|
38
|
+
===================
|
|
39
|
+
|
|
40
|
+
**csp-billing-adapter-amazon** adheres to Semantic versioning; see <http://semver.org/> for
|
|
41
|
+
details.
|
|
42
|
+
|
|
43
|
+
[bumpversion](https://pypi.python.org/pypi/bumpversion/) is used for
|
|
44
|
+
release version management, and is configured in `setup.cfg`:
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
$ bumpversion major|minor|patch
|
|
48
|
+
$ git push
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Bumpversion will create a commit with version updated in all locations.
|
|
52
|
+
The annotated tag is created separately.
|
|
53
|
+
|
|
54
|
+
```shell
|
|
55
|
+
$ git tag -a v{version}
|
|
56
|
+
# git tag -a v0.0.1
|
|
57
|
+
|
|
58
|
+
# Create a message with the changes since last release and push tags.
|
|
59
|
+
$ git push --tags
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Unit & Integration Tests
|
|
63
|
+
========================
|
|
64
|
+
|
|
65
|
+
All tests should pass and test coverage should remain above 90%.
|
|
66
|
+
|
|
67
|
+
The tests and coverage can be run directly via pytest.
|
|
68
|
+
|
|
69
|
+
```shell
|
|
70
|
+
$ pytest --cov=csp_billing_adapter_amazon
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Code Style
|
|
74
|
+
==========
|
|
75
|
+
|
|
76
|
+
Source should pass flake8 and pep8 standards.
|
|
77
|
+
|
|
78
|
+
```shell
|
|
79
|
+
$ flake8 csp_billing_adapter_amazon
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Signing Commits
|
|
83
|
+
===============
|
|
84
|
+
|
|
85
|
+
The repository and the code base patches sent for inclusion must be GPG
|
|
86
|
+
signed. See the GitHub article, [Signing commits using
|
|
87
|
+
GPG](https://help.github.com/articles/signing-commits-using-gpg/), for
|
|
88
|
+
more information.
|
|
@@ -0,0 +1,201 @@
|
|
|
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 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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include CHANGES.md
|
|
3
|
+
include CONTRIBUTING.md
|
|
4
|
+
include README.md
|
|
5
|
+
include csp-billing-adapter-amazon.spec
|
|
6
|
+
include requirements.txt
|
|
7
|
+
include requirements-test.txt
|
|
8
|
+
include requirements-dev.txt
|
|
9
|
+
|
|
10
|
+
recursive-include tests *
|
|
11
|
+
recursive-exclude * __pycache__
|
|
12
|
+
recursive-exclude * *.coverage
|
|
13
|
+
recursive-exclude * *.py[co]
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: csp-billing-adapter-amazon
|
|
3
|
+
Version: 1.4.0
|
|
4
|
+
Summary: TBD
|
|
5
|
+
Home-page: https://github.com/SUSE-Enceladus/csp-billing-adapter-amazon
|
|
6
|
+
Author: SUSE
|
|
7
|
+
Author-email: public-cloud-dev@susecloud.net
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Keywords: csp-billing-adapter-amazon csp_billing_adapter_amazon
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: System :: Monitoring
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Natural Language :: English
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Requires-Python: >=3.6
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: csp-billing-adapter
|
|
27
|
+
Requires-Dist: boto3
|
|
28
|
+
Requires-Dist: pluggy
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: coverage; extra == "dev"
|
|
31
|
+
Requires-Dist: flake8; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
33
|
+
Requires-Dist: bumpversion; extra == "dev"
|
|
34
|
+
Provides-Extra: test
|
|
35
|
+
Requires-Dist: coverage; extra == "test"
|
|
36
|
+
Requires-Dist: flake8; extra == "test"
|
|
37
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
38
|
+
Dynamic: author
|
|
39
|
+
Dynamic: author-email
|
|
40
|
+
Dynamic: classifier
|
|
41
|
+
Dynamic: description
|
|
42
|
+
Dynamic: description-content-type
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: keywords
|
|
45
|
+
Dynamic: license
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
Dynamic: provides-extra
|
|
48
|
+
Dynamic: requires-dist
|
|
49
|
+
Dynamic: requires-python
|
|
50
|
+
Dynamic: summary
|
|
51
|
+
|
|
52
|
+
# CSP Billing Adapter Amazon Plugin
|
|
53
|
+
|
|
54
|
+
This is a plugin for
|
|
55
|
+
[csp-billing-adapter](https://github.com/SUSE-Enceladus/csp-billing-adapter)
|
|
56
|
+
that provides CSP hook implementations. This includes the hooks defined in the
|
|
57
|
+
[csp_hookspecs.py module](https://github.com/SUSE-Enceladus/csp-billing-adapter/blob/main/csp_billing_adapter/csp_hookspecs.py).
|
|
58
|
+
To enable metered billing in Amazon the container or instance is required to
|
|
59
|
+
have MeterUsage permissions. This can be added with a role policy such as:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
{
|
|
63
|
+
"Version": "2012-10-17",
|
|
64
|
+
"Statement": [
|
|
65
|
+
{
|
|
66
|
+
"Sid": "CSPBillingAdapterPermissions",
|
|
67
|
+
"Effect": "Allow",
|
|
68
|
+
"Action": [
|
|
69
|
+
"aws-marketplace:MeterUsage"
|
|
70
|
+
],
|
|
71
|
+
"Resource": "*"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Meter billing
|
|
78
|
+
|
|
79
|
+
The `meter_billing` function accepts a dictionary mapping of dimension name
|
|
80
|
+
to usage quantity. This information is used to bill the customer for
|
|
81
|
+
the product ID that is configured in the adapter. If there is an exception
|
|
82
|
+
with metered billing the exception is raised.
|
|
83
|
+
|
|
84
|
+
## Get CSP Name
|
|
85
|
+
|
|
86
|
+
The `get_csp_name` function returns the name of the CSP provider. In this
|
|
87
|
+
case it is *Amazon*.
|
|
88
|
+
|
|
89
|
+
## Get Account Info
|
|
90
|
+
|
|
91
|
+
The `get_account_info` function provides metadata information for the running
|
|
92
|
+
instance or container. The structure of this information is as follows:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
{
|
|
96
|
+
"document": {
|
|
97
|
+
"accountId": "1234567890",
|
|
98
|
+
"architecture": "x86_64",
|
|
99
|
+
"availabilityZone": "us-east-1d",
|
|
100
|
+
"billingProducts": null,
|
|
101
|
+
"devpayProductCodes": null,
|
|
102
|
+
"marketplaceProductCodes": null,
|
|
103
|
+
"imageId": "ami-1234567890abcdefg",
|
|
104
|
+
"instanceId": "i-1234567890abcdefg",
|
|
105
|
+
"instanceType": "t2.micro",
|
|
106
|
+
"kernelId": null,
|
|
107
|
+
"pendingTime": "2023-05-23T19:46:52Z",
|
|
108
|
+
"privateIp": "192.168.0.201",
|
|
109
|
+
"ramdiskId": null,
|
|
110
|
+
"region": "us-east-1",
|
|
111
|
+
"version": "2017-09-30"
|
|
112
|
+
},
|
|
113
|
+
"signature": "signature",
|
|
114
|
+
"pkcs7": "pkcs7",
|
|
115
|
+
"cloud_provider": "amazon"
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This information is pulled from the Amazon Instance metadata endpoint:
|
|
120
|
+
http://169.254.169.254/latest. Note: the exact information in the
|
|
121
|
+
*document* entry may vary.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# CSP Billing Adapter Amazon Plugin
|
|
2
|
+
|
|
3
|
+
This is a plugin for
|
|
4
|
+
[csp-billing-adapter](https://github.com/SUSE-Enceladus/csp-billing-adapter)
|
|
5
|
+
that provides CSP hook implementations. This includes the hooks defined in the
|
|
6
|
+
[csp_hookspecs.py module](https://github.com/SUSE-Enceladus/csp-billing-adapter/blob/main/csp_billing_adapter/csp_hookspecs.py).
|
|
7
|
+
To enable metered billing in Amazon the container or instance is required to
|
|
8
|
+
have MeterUsage permissions. This can be added with a role policy such as:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
{
|
|
12
|
+
"Version": "2012-10-17",
|
|
13
|
+
"Statement": [
|
|
14
|
+
{
|
|
15
|
+
"Sid": "CSPBillingAdapterPermissions",
|
|
16
|
+
"Effect": "Allow",
|
|
17
|
+
"Action": [
|
|
18
|
+
"aws-marketplace:MeterUsage"
|
|
19
|
+
],
|
|
20
|
+
"Resource": "*"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Meter billing
|
|
27
|
+
|
|
28
|
+
The `meter_billing` function accepts a dictionary mapping of dimension name
|
|
29
|
+
to usage quantity. This information is used to bill the customer for
|
|
30
|
+
the product ID that is configured in the adapter. If there is an exception
|
|
31
|
+
with metered billing the exception is raised.
|
|
32
|
+
|
|
33
|
+
## Get CSP Name
|
|
34
|
+
|
|
35
|
+
The `get_csp_name` function returns the name of the CSP provider. In this
|
|
36
|
+
case it is *Amazon*.
|
|
37
|
+
|
|
38
|
+
## Get Account Info
|
|
39
|
+
|
|
40
|
+
The `get_account_info` function provides metadata information for the running
|
|
41
|
+
instance or container. The structure of this information is as follows:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
{
|
|
45
|
+
"document": {
|
|
46
|
+
"accountId": "1234567890",
|
|
47
|
+
"architecture": "x86_64",
|
|
48
|
+
"availabilityZone": "us-east-1d",
|
|
49
|
+
"billingProducts": null,
|
|
50
|
+
"devpayProductCodes": null,
|
|
51
|
+
"marketplaceProductCodes": null,
|
|
52
|
+
"imageId": "ami-1234567890abcdefg",
|
|
53
|
+
"instanceId": "i-1234567890abcdefg",
|
|
54
|
+
"instanceType": "t2.micro",
|
|
55
|
+
"kernelId": null,
|
|
56
|
+
"pendingTime": "2023-05-23T19:46:52Z",
|
|
57
|
+
"privateIp": "192.168.0.201",
|
|
58
|
+
"ramdiskId": null,
|
|
59
|
+
"region": "us-east-1",
|
|
60
|
+
"version": "2017-09-30"
|
|
61
|
+
},
|
|
62
|
+
"signature": "signature",
|
|
63
|
+
"pkcs7": "pkcs7",
|
|
64
|
+
"cloud_provider": "amazon"
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This information is pulled from the Amazon Instance metadata endpoint:
|
|
69
|
+
http://169.254.169.254/latest. Note: the exact information in the
|
|
70
|
+
*document* entry may vary.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#
|
|
2
|
+
# spec file for package csp-billing-adapter-amazon
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2023 SUSE LLC
|
|
5
|
+
#
|
|
6
|
+
# All modifications and additions to the file contributed by third parties
|
|
7
|
+
# remain the property of their copyright owners, unless otherwise agreed
|
|
8
|
+
# upon. The license for this file, and modifications and additions to the
|
|
9
|
+
# file, is the same license as for the pristine package itself (unless the
|
|
10
|
+
# license for the pristine package is not an Open Source License, in which
|
|
11
|
+
# case the license is the MIT License). An "Open Source License" is a
|
|
12
|
+
# license that conforms to the Open Source Definition (Version 1.9)
|
|
13
|
+
# published by the Open Source Initiative.
|
|
14
|
+
|
|
15
|
+
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
%{?sle15_python_module_pythons}
|
|
19
|
+
|
|
20
|
+
Name: csp-billing-adapter-amazon
|
|
21
|
+
Version: 1.4.0
|
|
22
|
+
Release: 0
|
|
23
|
+
Summary: Implements Amazon metering hooks for csp-billing-adapter
|
|
24
|
+
License: Apache-2.0
|
|
25
|
+
Group: Development/Languages/Python
|
|
26
|
+
URL: https://github.com/SUSE-Enceladus/%{name}
|
|
27
|
+
Source: https://files.pythonhosted.org/packages/source/c/%{name}/csp_billing_adapter_amazon-%{version}.tar.gz
|
|
28
|
+
BuildRequires: fdupes
|
|
29
|
+
BuildRequires: python-rpm-macros
|
|
30
|
+
BuildRequires: %{python_module csp-billing-adapter}
|
|
31
|
+
BuildRequires: %{python_module pip}
|
|
32
|
+
BuildRequires: %{python_module pluggy}
|
|
33
|
+
BuildRequires: %{python_module boto3}
|
|
34
|
+
BuildRequires: %{python_module setuptools}
|
|
35
|
+
BuildRequires: %{python_module wheel}
|
|
36
|
+
%if %{with test}
|
|
37
|
+
BuildRequires: %{python_module pytest}
|
|
38
|
+
BuildRequires: %{python_module coverage}
|
|
39
|
+
BuildRequires: %{python_module pytest-cov}
|
|
40
|
+
%endif
|
|
41
|
+
Requires: python-setuptools
|
|
42
|
+
Requires: python-pluggy
|
|
43
|
+
Requires: python-boto3
|
|
44
|
+
Requires: python-csp-billing-adapter
|
|
45
|
+
BuildArch: noarch
|
|
46
|
+
Obsoletes: python3-csp-billing-adapter-amazon < %{version}
|
|
47
|
+
%python_subpackages
|
|
48
|
+
|
|
49
|
+
%description
|
|
50
|
+
Provides a plugin for csp-billing-adapter to handle
|
|
51
|
+
metering of usage in Amazon AWS.
|
|
52
|
+
|
|
53
|
+
%prep
|
|
54
|
+
%autosetup -n csp_billing_adapter_amazon-%{version}
|
|
55
|
+
|
|
56
|
+
%build
|
|
57
|
+
%pyproject_wheel
|
|
58
|
+
|
|
59
|
+
%install
|
|
60
|
+
%pyproject_install
|
|
61
|
+
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
|
62
|
+
|
|
63
|
+
%check
|
|
64
|
+
%if %{with test}
|
|
65
|
+
%pytest
|
|
66
|
+
%endif
|
|
67
|
+
|
|
68
|
+
%files %{python_files}
|
|
69
|
+
%license LICENSE
|
|
70
|
+
%doc README.md CONTRIBUTING.md CHANGES.md
|
|
71
|
+
%{python_sitelib}/csp_billing_adapter_amazon
|
|
72
|
+
%{python_sitelib}/csp_billing_adapter_amazon-%{version}*-info
|
|
73
|
+
|
|
74
|
+
%changelog
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2023 SUSE LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
__author__ = """SUSE"""
|
|
18
|
+
__email__ = 'public-cloud-dev@susecloud.net'
|
|
19
|
+
__version__ = '1.4.0'
|