Skip to content

Commit e6305f3

Browse files
Release 0.1.2 (#82)
* refactor(policy evaluation): Iterator pattern conversion of list method * refactor(policy set outcome): Iterator pattern conversion of list method * refactor(oauth token): Iterator pattern conversion and removal of Uid attribute * refactor(reserved tag key): Iterator pattern conversion, read method removed and service class renamed * feat(registry provider version): added create method in the resource * feat(registry provider version): added list method in the resource * feat(registry provider version): added read method in the resource * feat(registry provider version): added delete and helper methods in the resource * test(registry provider version): added unit tests * query run func update * query run all function update * note update * lint issues fixed * Removed ListOptions from model amd Updated Cancel and force cancel option * func name update in example file * update on version and changelog * Updated changelog --------- Co-authored-by: aayushsingh2502 <[email protected]>
1 parent d1ec88b commit e6305f3

30 files changed

Lines changed: 2243 additions & 1423 deletions

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# Unreleased
22

3+
# v0.1.2
4+
5+
## Features
6+
7+
### Registry Management
8+
* Added registry provider version resource with full CRUD operations by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
9+
* Added create method for registry provider versions by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
10+
* Added list method with pagination support for registry provider versions by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
11+
* Added read method for fetching specific registry provider version details by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
12+
* Added delete method for removing registry provider versions by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
13+
* Added comprehensive unit tests for registry provider versions by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
14+
15+
## Breaking Change
16+
17+
### Iterator Pattern Migration for List Method
18+
* Migrated Policy Evaluation resource to use iterator pattern for list operations and renamed attribute task_stage to policy_attachable at PolicyEvaluation Model by @isivaselvan [#68](https://github.com/hashicorp/python-tfe/pull/68)
19+
* Migrated Policy Set Outcome resource to use iterator pattern for list operations by @isivaselvan [#68](https://github.com/hashicorp/python-tfe/pull/68)
20+
* Migrated OAuth Token resource to use iterator pattern and removed deprecated Uid attribute by @isivaselvan [#68](https://github.com/hashicorp/python-tfe/pull/68)
21+
* Migrated Reserved Tag Key resource to use iterator pattern, removed read method, and renamed service class by @isivaselvan [#68](https://github.com/hashicorp/python-tfe/pull/68)
22+
23+
### Deprecations
24+
* Models OAuthTokenList, PolicyEvaluationList, PolicySetOutcomeList, ReservedTagKeyList were removed from models as part of initial Iterator pattern conversion of List Method.
25+
* page_number attribute was removed at Models of OAuthTokenListOptions, PolicyEvaluationListOptions, PolicySetOutcomeListFilter and ReservedTagKeyListOptions.
26+
* Removed deprecated Uid attribute at OauthToken Model.
27+
28+
### Enhancements
29+
* Updated query run functions with correct api endpoints, parameters and payload options for improved performance and consistency by @aayushsingh2502 [#69](https://github.com/hashicorp/python-tfe/pull/69)
30+
* Removed ListOptions from model and improved Cancel and Force Cancel option handling by @aayushsingh2502 [#69](https://github.com/hashicorp/python-tfe/pull/69)
31+
* Updated function naming conventions in example files for better clarity by @aayushsingh2502 [#69](https://github.com/hashicorp/python-tfe/pull/69)
32+
33+
## Bug Fixes
34+
* Fixed the issue related to the Regex pattern on string id validation for registry resource by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
35+
336
# v0.1.1
437

538
## Features

examples/oauth_token.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from pytfe import TFEClient, TFEConfig
3232
from pytfe.errors import NotFound
33-
from pytfe.models import OAuthTokenListOptions, OAuthTokenUpdateOptions
33+
from pytfe.models import OAuthTokenUpdateOptions
3434

3535

3636
def main():
@@ -55,34 +55,18 @@ def main():
5555
# =====================================================
5656
print("\n1. Testing list() function:")
5757
try:
58-
# Test basic list without options
59-
token_list = client.oauth_tokens.list(organization_name)
60-
print(f"Found {len(token_list.items)} OAuth tokens")
61-
62-
# Show token details
63-
for i, token in enumerate(token_list.items[:3], 1): # Show first 3
64-
print(f"{i}. Token ID: {token.id}")
65-
print(f"UID: {token.uid}")
58+
for token in client.oauth_tokens.list(organization_name):
59+
print(f"Token ID: {token.id}")
6660
print(f"Service Provider User: {token.service_provider_user}")
6761
print(f"Has SSH Key: {token.has_ssh_key}")
6862
print(f"Created: {token.created_at}")
6963
if token.oauth_client:
7064
print(f"OAuth Client: {token.oauth_client.id}")
7165

72-
# Store first token for subsequent tests
73-
if token_list.items:
74-
test_token_id = token_list.items[0].id
75-
print(f"\n Using token {test_token_id} for subsequent tests")
76-
77-
# Test list with options
78-
print("\nTesting list() with pagination options:")
79-
options = OAuthTokenListOptions(page_size=10, page_number=1)
80-
token_list_with_options = client.oauth_tokens.list(organization_name, options)
81-
print(f"Found {len(token_list_with_options.items)} tokens with options")
82-
if token_list_with_options.current_page:
83-
print(f"Current page: {token_list_with_options.current_page}")
84-
if token_list_with_options.total_count:
85-
print(f"Total count: {token_list_with_options.total_count}")
66+
# Store first token for subsequent tests
67+
if token and not test_token_id:
68+
test_token_id = token.id
69+
print(f"\n Using token {test_token_id} for subsequent tests \n")
8670

8771
except NotFound:
8872
print(
@@ -99,7 +83,6 @@ def main():
9983
try:
10084
token = client.oauth_tokens.read(test_token_id)
10185
print(f"Read OAuth token: {token.id}")
102-
print(f"UID: {token.uid}")
10386
print(f"Service Provider User: {token.service_provider_user}")
10487
print(f"Has SSH Key: {token.has_ssh_key}")
10588
print(f"Created: {token.created_at}")

examples/policy_evaluation.py

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def main():
2626
required=True,
2727
help="Task stage ID to list policy evaluations for",
2828
)
29-
parser.add_argument("--page", type=int, default=1)
3029
parser.add_argument("--page-size", type=int, default=20)
3130
args = parser.parse_args()
3231

@@ -41,58 +40,55 @@ def main():
4140
_print_header(f"Listing policy evaluations for task stage: {args.task_stage_id}")
4241

4342
options = PolicyEvaluationListOptions(
44-
page_number=args.page,
4543
page_size=args.page_size,
4644
)
4745

4846
try:
49-
pe_list = client.policy_evaluations.list(args.task_stage_id, options)
50-
51-
print(f"Total policy evaluations: {pe_list.total_count}")
52-
print(f"Page {pe_list.current_page} of {pe_list.total_pages}")
53-
print()
54-
55-
if not pe_list.items:
47+
pe_count = 0
48+
for pe in client.policy_evaluations.list(args.task_stage_id, options):
49+
pe_count += 1
50+
print(f"- ID: {pe.id}")
51+
print(f"Status: {pe.status}")
52+
print(f"Policy Kind: {pe.policy_kind}")
53+
54+
if pe.result_count:
55+
print(" Result Count:")
56+
if pe.result_count.passed is not None:
57+
print(f"- Passed: {pe.result_count.passed}")
58+
if pe.result_count.advisory_failed is not None:
59+
print(f"- Advisory Failed: {pe.result_count.advisory_failed}")
60+
if pe.result_count.mandatory_failed is not None:
61+
print(f"- Mandatory Failed: {pe.result_count.mandatory_failed}")
62+
if pe.result_count.errored is not None:
63+
print(f"- Errored: {pe.result_count.errored}")
64+
65+
if pe.status_timestamp:
66+
print(" Status Timestamps:")
67+
if pe.status_timestamp.passed_at:
68+
print(f"- Passed At: {pe.status_timestamp.passed_at}")
69+
if pe.status_timestamp.failed_at:
70+
print(f"- Failed At: {pe.status_timestamp.failed_at}")
71+
if pe.status_timestamp.running_at:
72+
print(f"- Running At: {pe.status_timestamp.running_at}")
73+
if pe.status_timestamp.canceled_at:
74+
print(f"- Canceled At: {pe.status_timestamp.canceled_at}")
75+
if pe.status_timestamp.errored_at:
76+
print(f"- Errored At: {pe.status_timestamp.errored_at}")
77+
78+
if pe.policy_attachable:
79+
print(f"Task Stage: {pe.task_stage.id} ({pe.task_stage.type})")
80+
81+
if pe.created_at:
82+
print(f"Created At: {pe.created_at}")
83+
if pe.updated_at:
84+
print(f"Updated At: {pe.updated_at}")
85+
86+
print()
87+
88+
if pe_count == 0:
5689
print("No policy evaluations found for this task stage.")
5790
else:
58-
for pe in pe_list.items:
59-
print(f"- ID: {pe.id}")
60-
print(f"Status: {pe.status}")
61-
print(f"Policy Kind: {pe.policy_kind}")
62-
63-
if pe.result_count:
64-
print(" Result Count:")
65-
if pe.result_count.passed is not None:
66-
print(f"- Passed: {pe.result_count.passed}")
67-
if pe.result_count.advisory_failed is not None:
68-
print(f"- Advisory Failed: {pe.result_count.advisory_failed}")
69-
if pe.result_count.mandatory_failed is not None:
70-
print(f"- Mandatory Failed: {pe.result_count.mandatory_failed}")
71-
if pe.result_count.errored is not None:
72-
print(f"- Errored: {pe.result_count.errored}")
73-
74-
if pe.status_timestamp:
75-
print(" Status Timestamps:")
76-
if pe.status_timestamp.passed_at:
77-
print(f"- Passed At: {pe.status_timestamp.passed_at}")
78-
if pe.status_timestamp.failed_at:
79-
print(f"- Failed At: {pe.status_timestamp.failed_at}")
80-
if pe.status_timestamp.running_at:
81-
print(f"- Running At: {pe.status_timestamp.running_at}")
82-
if pe.status_timestamp.canceled_at:
83-
print(f"- Canceled At: {pe.status_timestamp.canceled_at}")
84-
if pe.status_timestamp.errored_at:
85-
print(f"- Errored At: {pe.status_timestamp.errored_at}")
86-
87-
if pe.task_stage:
88-
print(f"Task Stage: {pe.task_stage.id} ({pe.task_stage.type})")
89-
90-
if pe.created_at:
91-
print(f"Created At: {pe.created_at}")
92-
if pe.updated_at:
93-
print(f"Updated At: {pe.updated_at}")
94-
95-
print()
91+
print(f"\nTotal: {pe_count} policy evaluations")
9692

9793
except Exception as e:
9894
print(f"Error listing policy evaluations: {e}")

0 commit comments

Comments
 (0)