Skip to content

fix(python): accept CLI flags after export/import subcommands and sup… - #82

Merged
nsamarakkody merged 1 commit into
google:mainfrom
nsamarakkody:fix/cep-cli-subparser-args
Oct 11, 2026
Merged

nsamarakkody merged 1 commit into
google:mainfrom
nsamarakkody:fix/cep-cli-subparser-args

Conversation

@nsamarakkody

Copy link
Copy Markdown
Collaborator

Summary

Follow-up improvements to Python/cep_policy_manager.py verified during end-to-end export and import testing against a live Chrome Enterprise Premium (CEP) tenant:

Key Changes

  1. Subcommand CLI Flag Ordering (_add_common_arguments):
    • Registers common CLI options (--use-service-account, --key-file, --subject, --access-token, --client-secrets, --token-file, --customer, --org-id, --project-id, --debug) on both the root parser and the export / import subparsers (using argparse.SUPPRESS on subparsers).
    • Allows users to pass flags either before or after export / import (e.g., python3 cep_policy_manager.py export --customer C0xxxxxxx --org-id 123456789012), matching the command examples in Python/README.md.
  2. Backwards-Compatible Import Schema (import_environment):
    • Falls back to data.get("dlp_configurations", {}) when "cep_configurations" is not present so JSON exports generated by earlier script versions can be imported without manual edits.
  3. gcloud ADC Initial Token Refresh (_load_adc_user_credentials):
    • Refreshes authorized_user credentials from ~/.config/gcloud/application_default_credentials.json whenever not creds.valid (since ADC JSON files only store a refresh_token and have creds.token = None on initial load) without overriding the granted ADC scopes.

@nsamarakkody nsamarakkody self-assigned this Oct 11, 2026
@nsamarakkody
nsamarakkody merged commit 5cc1304 into google:main Oct 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant