<p>I have <a href="https://github.com/kubernetes-client/csharp/" rel="nofollow noreferrer">KubernetesClient</a> code running my app on K3s Orchestrator.</p>
<p>I want to understand the difference(use-case) between two K3s APIs <code>PatchNamespacedServiceWithHttpMessagesAsync</code> and <code>ReplaceNamespacedServiceWithHttpMessagesAsync</code> <a href="https://raw.githubusercontent.com/kubernetes-client/csharp/463e2d94dfe5a4bb54372aaab957ca8d794d767e/src/KubernetesClient/generated/Kubernetes.cs" rel="nofollow noreferrer">[link to these APIs]</a>. Apart from this link I cant find any place to read about K3s APIs use cases. Please help me here.</p>
<p><strong>PS:</strong></p>
<ol>
<li>Basically I am trying to update the existing Service, so want to understand the difference between above two APIs, either of which I will be calling with updated Patch body (updated service deployment).<br/></li>
<li>This que is extension of my <a href="https://stackoverflow.com/questions/70076040/how-to-find-existing-service-by-kubernetes-c-sharp-client-api">previous que</a></li>
</ol>

<p><strong>TL;DR</strong></p>
<p><strong><code>ReplaceNamespacedServiceWithHttpMessagesAsync</code> use <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT" rel="nofollow noreferrer">PUT</a> HTTP method. <code>PatchNamespacedServiceWithHttpMessagesAsync</code> use <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH" rel="nofollow noreferrer">PATCH</a> HTTP method.</strong></p>
<p>PUT method is to update or create a new object. If such an object already exists, all data are updated, if not, a new object is created on the basis of the information sent. The PATCH method, like PUT, is used to update data about an object, but it requires the object to exist. This is because it does not send complete data in the request, but only the data that is to be updated.</p>
<hr />
<p><strong>Overall, both APIs are very similar to each other. They only differ in a few places:</strong></p>
<p>We have a different name in the first line:
In the <code>ReplaceNamespacedServiceWithHttpMessagesAsync</code></p>
<pre><code>public async Task&lt;HttpOperationResponse&lt;V1Service&gt;&gt; ReplaceNamespacedServiceWithHttpMessagesAsync(
             V1Service body,
</code></pre>
<p>and in the <code>PatchNamespacedServiceWithHttpMessagesAsync</code>:</p>
<pre><code>public async Task&lt;HttpOperationResponse&lt;V1Service&gt;&gt; PatchNamespacedServiceWithHttpMessagesAsync(
            V1Patch body,
</code></pre>
<hr />
<p>A <code>bool</code> is added to the 7th line in the <code>PatchNamespacedServiceWithHttpMessagesAsync</code></p>
<pre><code>bool? force = null,
</code></pre>
<p>and in the 36th line:</p>
<pre><code>tracingParameters.Add(&quot;force&quot;, force);
</code></pre>
<hr />
<p>Lines 37th for <code>ReplaceNamespacedServiceWithHttpMessagesAsync</code> and  39th for <code>PatchNamespacedServiceWithHttpMessagesAsync</code>are also different:</p>
<pre><code>ServiceClientTracing.Enter(_invocationId, this, &quot;ReplaceNamespacedService&quot;, tracingParameters);
</code></pre>
<p>vs</p>
<pre><code>ServiceClientTracing.Enter(_invocationId, this, &quot;PatchNamespacedService&quot;, tracingParameters);
</code></pre>
<hr />
<p>Then is added a fragment (from 56th to 59th ) line for <code>PatchNamespacedServiceWithHttpMessagesAsync</code>:</p>
<pre><code>if (force != null)
             {
                 _queryParameters.Add(string.Format(&quot;force={0}&quot;, System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(force, SerializationSettings).Trim('&quot;'))));
             }
</code></pre>
<p><strong>The last and most important difference is the 65th line in the <code>ReplaceNamespacedServiceWithHttpMessagesAsync</code> and 71th line in the <code>PatchNamespacedServiceWithHttpMessagesAsync</code> .</strong></p>
<pre><code>_httpRequest.Method = HttpMethod.Put;
</code></pre>
<p>vs</p>
<pre><code>_httpRequest.Method = HttpMethod.Patch;
</code></pre>
