Add Job.add_step

Signed-off-by: Jimmy Christensen <lithorus@gmail.com>

@@ -2181,6 +2181,15 @@ class Job(OpenJDModel_v2023_09):
     parameters: Optional[JobParameters] = None
     jobEnvironments: Optional[JobEnvironmentsList] = None

+    def add_step(self, *, step: Step):
+        """
+        Function to dynamically add step to jobs
+        Args:
+            step (Step): Step to be added
+
+        """
+        self.steps.append(step)
+

 class JobTemplate(OpenJDModel_v2023_09):
     """Definition of an Open Job Description Job Template.


Added del_step_by_name and get_step_by_name

Signed-off-by: Jimmy Christensen <lithorus@gmail.com>

@@ -2190,6 +2190,36 @@ def add_step(self, *, step: Step):
         """
         self.steps.append(step)

+    def del_step_by_name(self, *, step_name: str):
+        """
+
+        Args:
+            step_name: Name of the step to be removed
+
+        Returns:
+
+        """
+        step = self.get_step_by_name(step_name=step_name)
+        try:
+            self.steps.remove(step)
+            return True
+        except ValueError:
+            # Return false if no step with the name given was found
+            return False
+
+    def get_step_by_name(self, *, step_name: str):
+        """
+
+        Args:
+            step_name: Name of the step to be found
+
+        Returns:
+            Step
+        """
+
+        for step in self.steps:
+            if step.name == step_name:
+                return step

 class JobTemplate(OpenJDModel_v2023_09):
     """Definition of an Open Job Description Job Template.


feat: add functions to manipulate steps on jobs

Related to : #137

### What was the problem/requirement? (What/Why)
This adds the ability to dynamically add/remove steps to jobs

### What was the solution? (How)
Added public functions to the Job class

### What is the impact of this change?
It should not affect tha actual model, byt only add public functions to manipulate it

### How was this change tested?
Have tested with creating a jobs and adding/removing steps dynamically.
Unit tests are not yet added, but will add them later

### Was this change documented?
Have only added docstring for now which are not 100% complete yet (will update them)

### Is this a breaking change?
No

### Does this change impact security?
No

*By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.*

openjd-model-for-python

Provides a Python implementation of the data model for Open Job Description's template schemas.


## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=OpenJobDescription_openjd-model-for-python&pullRequest=140) **Quality Gate passed**
Issues
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=OpenJobDescription_openjd-model-for-python&pullRequest=140&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=OpenJobDescription_openjd-model-for-python&pullRequest=140&issueStatuses=ACCEPTED)

Measures
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=OpenJobDescription_openjd-model-for-python&pullRequest=140&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=OpenJobDescription_openjd-model-for-python&pullRequest=140&metric=new_coverage&view=list)
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=OpenJobDescription_openjd-model-for-python&pullRequest=140&metric=new_duplicated_lines_density&view=list)

[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=OpenJobDescription_openjd-model-for-python&pullRequest=140)

SonarQubeCloud

SonarQube Cloud (formerly SonarCloud) is a SaaS code analysis tool designed to detect coding issues in 30+ languages, frameworks, and IaC platforms. Your code is checked against an extensive set of rules that cover many attributes of code, such as maintainability, reliability, and security issues, on each merge/pull request.

For those requiring US-based hosting, [SonarQube Cloud US](https://sonarqube.us/) offers the perfect alternative. If you need data residency outside the US or within the EU, [SonarQube Cloud](https://sonarcloud.io/) with this GitHub app is the ideal solution.

SonarQube Cloud integrates seamlessly into your GitHub workflow and provides clear guidance for resolving any code quality and security issues detected. The majority of popular languages can be analyzed automatically; no configuration is required!

With [SonarQube Cloud](https://sonarcloud.io/github), you get:

-   Fast, precise static analysis and feedback on your code

-   Support for popular languages, frameworks, and IaC tools

-   Free analysis for open-source projects and private projects up to max 50k LoC

-   Automatic analysis of pull requests and branches with results reported inline

-   IDE Support with [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/) integration

-   Quality Gate (added as a GitHub check) acting at two different levels - first, preventing you from merging pull requests that contain issues - and later, helping you to release only clean, safe code

-   Sign up for SonarQube free tier and begin scanning your private and public repositories

A [GitHub Action](https://github.com/marketplace/actions/sonarcloud-scan) is available in the marketplace to make it easy for you (for projects where automatic analysis isn't available). SonarQube Cloud also integrates smoothly with Jenkins, CircleCI, TravisCI, CirrusCI, and many other tools.

A free tier is available that allows you to explore the benefits of SonarQube Cloud using your public and private repositories. We also provide a no-commitment, [14-day trial](https://www.sonarsource.com/products/sonarcloud/signup/) of SonarQube Cloud Team for unlimited team members, up to 1.9M LoC, AI CodeFix recommendations, and more. No need to speak with a sales rep or request a license key - get automatic code analysis results on your private projects in minutes! Want to see more examples of SonarCloud in action? You can [explore current Open Source projects in SonarCloud](https://sonarcloud.io/explore/projects?sort=-analysis_date) that are using the [Clean as You Code](https://www.sonarsource.com/solutions/our-unique-approach/) methodology.

What are you waiting for? SonarQube Cloud helps you consistently deliver cleaner, secure software that future developers will appreciate and your users will love. Start writing Clean Code. [Now](https://www.sonarsource.com/products/sonarcloud/signup/)!

read


read


Add functions to manipulate steps on jobs

feat: add functions to manipulate steps on jobs


@@ -2181,6 +2181,45 @@
     parameters: Optional[JobParameters] = None
     jobEnvironments: Optional[JobEnvironmentsList] = None

+    def add_step(self, *, step: Step):
+        """
+        Function to dynamically add step to jobs
+        Args:
+            step (Step): Step to be added
+
+        """
+        self.steps.append(step)
+
+    def del_step_by_name(self, *, step_name: str):
+        """
+
+        Args:
+            step_name: Name of the step to be removed
+
+        Returns:
+
+        """
+        step = self.get_step_by_name(step_name=step_name)
+        try:
+            self.steps.remove(step)
+            return True
+        except ValueError:
+            # Return false if no step with the name given was found
+            return False
+
+    def get_step_by_name(self, *, step_name: str):

## Explicit returns mixed with implicit (fall through) returns

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.

[Show more details](https://github.com/OpenJobDescription/openjd-model-for-python/security/code-scanning/11)


Hi Jimmy. This has been sitting in draft state for a while, so I'm going to close it off. Please feel free to reopen if you'd like to continue it.