Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Unreleased

# v0.1.2

## Features

### Registry Management
* Added registry provider version resource with full CRUD operations by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
* Added create method for registry provider versions by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
* Added list method with pagination support for registry provider versions by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
* Added read method for fetching specific registry provider version details by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
* Added delete method for removing registry provider versions by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)
* Added comprehensive unit tests for registry provider versions by @isivaselvan [#66](https://github.com/hashicorp/python-tfe/pull/66)

## Breaking Change

### Iterator Pattern Migration for List Method
* 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)
* Migrated Policy Set Outcome resource to use iterator pattern for list operations by @isivaselvan [#68](https://github.com/hashicorp/python-tfe/pull/68)
* Migrated OAuth Token resource to use iterator pattern and removed deprecated Uid attribute by @isivaselvan [#68](https://github.com/hashicorp/python-tfe/pull/68)
* 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)

### Deprecations
* Models OAuthTokenList, PolicyEvaluationList, PolicySetOutcomeList, ReservedTagKeyList were removed from models as part of initial Iterator pattern conversion of List Method.
* page_number attribute was removed at Models of OAuthTokenListOptions, PolicyEvaluationListOptions, PolicySetOutcomeListFilter and ReservedTagKeyListOptions.
* Removed deprecated Uid attribute at OauthToken Model.

### Enhancements
* 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)
* Removed ListOptions from model and improved Cancel and Force Cancel option handling by @aayushsingh2502 [#69](https://github.com/hashicorp/python-tfe/pull/69)
* Updated function naming conventions in example files for better clarity by @aayushsingh2502 [#69](https://github.com/hashicorp/python-tfe/pull/69)

## Bug Fixes
* 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)

# v0.1.1

## Features
Expand Down
31 changes: 7 additions & 24 deletions examples/oauth_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from pytfe import TFEClient, TFEConfig
from pytfe.errors import NotFound
from pytfe.models import OAuthTokenListOptions, OAuthTokenUpdateOptions
from pytfe.models import OAuthTokenUpdateOptions


def main():
Expand All @@ -55,34 +55,18 @@ def main():
# =====================================================
print("\n1. Testing list() function:")
try:
# Test basic list without options
token_list = client.oauth_tokens.list(organization_name)
print(f"Found {len(token_list.items)} OAuth tokens")

# Show token details
for i, token in enumerate(token_list.items[:3], 1): # Show first 3
print(f"{i}. Token ID: {token.id}")
print(f"UID: {token.uid}")
for token in client.oauth_tokens.list(organization_name):
print(f"Token ID: {token.id}")
print(f"Service Provider User: {token.service_provider_user}")
print(f"Has SSH Key: {token.has_ssh_key}")
print(f"Created: {token.created_at}")
if token.oauth_client:
print(f"OAuth Client: {token.oauth_client.id}")

# Store first token for subsequent tests
if token_list.items:
test_token_id = token_list.items[0].id
print(f"\n Using token {test_token_id} for subsequent tests")

# Test list with options
print("\nTesting list() with pagination options:")
options = OAuthTokenListOptions(page_size=10, page_number=1)
token_list_with_options = client.oauth_tokens.list(organization_name, options)
print(f"Found {len(token_list_with_options.items)} tokens with options")
if token_list_with_options.current_page:
print(f"Current page: {token_list_with_options.current_page}")
if token_list_with_options.total_count:
print(f"Total count: {token_list_with_options.total_count}")
# Store first token for subsequent tests
if token and not test_token_id:
test_token_id = token.id
print(f"\n Using token {test_token_id} for subsequent tests \n")

except NotFound:
print(
Expand All @@ -99,7 +83,6 @@ def main():
try:
token = client.oauth_tokens.read(test_token_id)
print(f"Read OAuth token: {token.id}")
print(f"UID: {token.uid}")
print(f"Service Provider User: {token.service_provider_user}")
print(f"Has SSH Key: {token.has_ssh_key}")
print(f"Created: {token.created_at}")
Expand Down
90 changes: 43 additions & 47 deletions examples/policy_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def main():
required=True,
help="Task stage ID to list policy evaluations for",
)
parser.add_argument("--page", type=int, default=1)
parser.add_argument("--page-size", type=int, default=20)
args = parser.parse_args()

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

options = PolicyEvaluationListOptions(
page_number=args.page,
page_size=args.page_size,
)

try:
pe_list = client.policy_evaluations.list(args.task_stage_id, options)

print(f"Total policy evaluations: {pe_list.total_count}")
print(f"Page {pe_list.current_page} of {pe_list.total_pages}")
print()

if not pe_list.items:
pe_count = 0
for pe in client.policy_evaluations.list(args.task_stage_id, options):
pe_count += 1
print(f"- ID: {pe.id}")
print(f"Status: {pe.status}")
print(f"Policy Kind: {pe.policy_kind}")

if pe.result_count:
print(" Result Count:")
if pe.result_count.passed is not None:
print(f"- Passed: {pe.result_count.passed}")
if pe.result_count.advisory_failed is not None:
print(f"- Advisory Failed: {pe.result_count.advisory_failed}")
if pe.result_count.mandatory_failed is not None:
print(f"- Mandatory Failed: {pe.result_count.mandatory_failed}")
if pe.result_count.errored is not None:
print(f"- Errored: {pe.result_count.errored}")

if pe.status_timestamp:
print(" Status Timestamps:")
if pe.status_timestamp.passed_at:
print(f"- Passed At: {pe.status_timestamp.passed_at}")
if pe.status_timestamp.failed_at:
print(f"- Failed At: {pe.status_timestamp.failed_at}")
if pe.status_timestamp.running_at:
print(f"- Running At: {pe.status_timestamp.running_at}")
if pe.status_timestamp.canceled_at:
print(f"- Canceled At: {pe.status_timestamp.canceled_at}")
if pe.status_timestamp.errored_at:
print(f"- Errored At: {pe.status_timestamp.errored_at}")

if pe.policy_attachable:
print(f"Task Stage: {pe.task_stage.id} ({pe.task_stage.type})")

if pe.created_at:
print(f"Created At: {pe.created_at}")
if pe.updated_at:
print(f"Updated At: {pe.updated_at}")

print()

if pe_count == 0:
print("No policy evaluations found for this task stage.")
else:
for pe in pe_list.items:
print(f"- ID: {pe.id}")
print(f"Status: {pe.status}")
print(f"Policy Kind: {pe.policy_kind}")

if pe.result_count:
print(" Result Count:")
if pe.result_count.passed is not None:
print(f"- Passed: {pe.result_count.passed}")
if pe.result_count.advisory_failed is not None:
print(f"- Advisory Failed: {pe.result_count.advisory_failed}")
if pe.result_count.mandatory_failed is not None:
print(f"- Mandatory Failed: {pe.result_count.mandatory_failed}")
if pe.result_count.errored is not None:
print(f"- Errored: {pe.result_count.errored}")

if pe.status_timestamp:
print(" Status Timestamps:")
if pe.status_timestamp.passed_at:
print(f"- Passed At: {pe.status_timestamp.passed_at}")
if pe.status_timestamp.failed_at:
print(f"- Failed At: {pe.status_timestamp.failed_at}")
if pe.status_timestamp.running_at:
print(f"- Running At: {pe.status_timestamp.running_at}")
if pe.status_timestamp.canceled_at:
print(f"- Canceled At: {pe.status_timestamp.canceled_at}")
if pe.status_timestamp.errored_at:
print(f"- Errored At: {pe.status_timestamp.errored_at}")

if pe.task_stage:
print(f"Task Stage: {pe.task_stage.id} ({pe.task_stage.type})")

if pe.created_at:
print(f"Created At: {pe.created_at}")
if pe.updated_at:
print(f"Updated At: {pe.updated_at}")

print()
print(f"\nTotal: {pe_count} policy evaluations")

except Exception as e:
print(f"Error listing policy evaluations: {e}")
Expand Down
Loading
Loading