</span></span></code></pre></div><blockquote><p>💡 For local development purposes, this is super convenient to use a very small HTTP server running on your laptop or a common folder mounted into Microcks container as the default artifacts repository.</p></blockquote><h2 id=2-import-content-via-importer>2. Import content via Importer</h2><p>Another way of adding new Services or APIs mocks is by scheduling an <strong>Importer Job</strong> into Microcks. We think it’s actually the best way to achieve continuous, iterative and incremental discovery of your Services and APIs. The principle is very simple: you save your artifact file into the Git repository of your choice (public or private), and Microcks will take care of periodically checking if changes have been applied and new mock or service definitions are present in your artifact. The nice thing about using Importer is that external files referenced in the target artifact will be automatically resolved for you.</p><div align=center><figure><img src=/images/documentation/artifacts-scheduling.png width=80%></figure></div><blockquote><p>💡 Though we think that Git repositories (or other version control systems) are the best place to keep such artifacts, Microcks only requires a simple HTTP service. So you may store your artifact on a simple filesystem as long as it is reachable using HTTP.</p></blockquote><p>Still from the left vertical navigation bar, just select the <strong>Importers</strong> menu entry to see the list of existing importers.</p><h3 id=creating-a-new-scheduled-import>Creating a new scheduled import</h3><p>You may declare a new Importer job by hitting the <code>Create</code> button.</p><p>A wizard modal then appears, as creating an Importer is a three-step process. The first step concerns mandatory basic properties such as the name of your Importer and the repository URL it will use to check for discovering API mocks.</p><div align=center><figure><img src=/images/importer-step1.png width=90%></figure></div><blockquote><p>💡 You can also specify whether this artifact should be considered as <code>primary</code> or <code>secondary</code> per the <a href=/documentation/explanations/multi-artifacts>Multi Artifacts support</a>. In the case of a <code>secondary</code> artifact, you may check the <em>Just merge examples into existing API | Service definition</em> box.</p></blockquote><p>The second step concerns authentication options for accessing the repository. Depending on the type of repository (public or private), you may need to enable/disable certificate validation and manage an authentication process through the usage of a <strong>Secret</strong>. For more info, check the guide on <a href=/documentation/guides/administration/secrets>External Secrets</a>.</p><div align=center><figure><img src=/images/importer-step2.png width=90%></figure></div><p>Finally, the review displays a summary before creating the Importer Job.</p><div align=center><figure><img src=/images/importer-step3.png width=90%></figure></div><h3 id=managing-scheduled-importers>Managing scheduled importers</h3><p>At creation time, the importer job is automatically <code>Scanned</code> and <code>Imported</code>.</p><p>Once created, importer jobs can be managed, activated or forced through this screen. You’ll see a colored marker for each job line:</p><ul><li><code>Scanned</code> means that the job is actually scheduled for the next importation run. Otherwise, <code>Inactive</code> will be displayed.</li><li><code>Imported</code> means that the job has been successfully imported on a previous run. Otherwise, <code>Last import errors</code> will be displayed with a popup showing the last error,</li><li><code>Services</code> is a shortcut to access the services definitions discovered by this job.</li></ul><p>Using the 3-dotted menu, you can easily enable/disable or force the job.</p><div align=center><figure><img src=/images/importer-status.png width=90%></figure></div><h3 id=configure-scheduling-interval>Configure scheduling interval</h3><p>The scheduling interval can be globally configured for all Jobs. It is a global setting and not a per-job one. This is achieved through the <code>services.update.interval</code> property in the <code>application.properties</code> configuration file, which takes the value of the <code>SERVICES_UPDATE_INTERVAL</code> environment variable. The value should be set to a valid <a href=https://spring.io/blog/2020/11/10/new-in-spring-5-3-improved-cron-expressions target=_blank>CRON expression</a>; the default is every 2 hours.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-properties data-lang=properties><span style=display:flex><span><span style=color:#a6e22e>services.update.interval</span><span style=color:#f92672>=</span><span style=color:#e6db74>${SERVICES_UPDATE_INTERVAL:0 0 0/2 * * *}</span>
0 commit comments