Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Create new Pac Version #238

Open
CyberPaschk opened this issue Jan 10, 2025 · 1 comment
Open

[FEATURE] Create new Pac Version #238

CyberPaschk opened this issue Jan 10, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request In development Under active development ZIA New API Resources ZIA New API Resources

Comments

@CyberPaschk
Copy link

CyberPaschk commented Jan 10, 2025

Problem Statement
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
--> Currently I can see that in the SDK under the class pac_file exist an update but this does not create a new version of the PAC (from 1-->2).
In my opinion this woud be very helpful for the full automation of PAC

Proposed Solution
I already created a class locally in the SDK and tested this. Maybe you can add this?

    def create_new_pac_version(
            self,
            pac_id: str,
            pac_version: str,
            pac_commit_message: str,
            pac_verification_status: str,
            pac_version_status: str,
            pac_content: str,
            **kwargs,
        ) -> Box:
            """
            Performs to create a new PAC Version 

            Args:
                pac_id (str): The unique identifier of the PAC file to be updated.
                pac_version (str): The specific version of the PAC file to be updated.
                pac_commit_message (str): Commit message for the PAC file.
                pac_verification_status (str): Verification status of the PAC file.
                                            Supported Values: `VERIFY_NOERR`, `VERIFY_ERR`, `NOVERIFY`
                pac_version_status (str): Version status of the PAC file.
                                        Supported Values: `DEPLOYED`, `STAGE`, `LKG`
                pac_content (str): The actual PAC file content to be updated.


            Keyword Args:
                Additional optional parameters as key-value pairs.

            Returns:
                Box: The updated PAC file resource record.


            Example:
                >>> pac_file = zia.update_pac_file(
                        pac_id="12345",
                        pac_version="1",
                        pac_version_action="DEPLOY",
                        name="Update_Pac_File_01",
                        description="Update_Pac_File_01",
                        domain="bd-hashicorp.com",
                        pac_commit_message="Update_Pac_File_01",
                        pac_verification_status="VERIFY_NOERR",
                        pac_version_status="DEPLOYED",
                        pac_content="function FindProxyForURL(url, host) { return 'PROXY gateway.example.com:80'; }",
                        new_lkg_ver=5
                    )
            """
            # Step 1: Validate the PAC content
            validation_result = self.validate_pac_file(pac_content)
            if not validation_result.success:
                raise Exception("PAC content validation failed: {}".format(validation_result))

            # Step 2: Construct the URL with mandatory parameters and optional newLKGVer
            url = f"/pacFiles/{pac_id}/version/{pac_version}"

            # Step 3: Construct the payload with required fields
            payload = {
                "pacCommitMessage": pac_commit_message,
                "pacVerificationStatus": pac_verification_status,
                "pacVersionStatus": pac_version_status,
                "pacContent": pac_content,
            }

            # Add any additional optional parameters
            for key, value in kwargs.items():
                payload[snake_to_camel(key)] = value

            # Step 4: Make the request to update the PAC file
            response = self.rest.post(url, json=payload)
            if isinstance(response, Response):
                if response.status_code != 200:
                    raise Exception(f"API call failed with status {response.status_code}: {response.json()}")
                return Box(response.json())
            return response

Additional Context
I also opened a Ticket for Zscaler since automation is a topic I can choose:
Case Number : 05342084 : zscaler SDK ZIAClientHelper [ thread::z0BsQLiWcP-DfFDdEvCYVFs:: ]

I already tested the class in our dev cloud / Pacs and can confirm this is working well.

@willguibr
Copy link
Member

Please refer to our README here.
At this moment we are not accepting contributions, but we welcome suggestions on how to improve this SDK or feature requests, which can then be added in future releases.
Finally, we have a major upcoming release slated for the next 2-3 weeks which will include such feature.

Zscaler DevRel

@willguibr willguibr self-assigned this Jan 10, 2025
@willguibr willguibr added enhancement New feature or request In development Under active development ZIA New API Resources ZIA New API Resources labels Jan 10, 2025
@willguibr willguibr moved this to ⚙️ In development in Zscaler Automation Dashboard 🛣 Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request In development Under active development ZIA New API Resources ZIA New API Resources
Projects
Status: ⚙️ In development
Development

Successfully merging a pull request may close this issue.

2 participants