1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
|
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# Generated file, DO NOT EDIT
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------
from msrest import Serializer, Deserializer
from ...client import Client
from ...v5_1.policy import models
class PolicyClient(Client):
"""Policy
:param str base_url: Service URL
:param Authentication creds: Authenticated credentials.
"""
def __init__(self, base_url=None, creds=None):
super(PolicyClient, self).__init__(base_url, creds)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
resource_area_identifier = 'fb13a388-40dd-4a04-b530-013a739c72ef'
def create_policy_configuration(self, configuration, project, configuration_id=None):
"""CreatePolicyConfiguration.
Create a policy configuration of a given policy type.
:param :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>` configuration: The policy configuration to create.
:param str project: Project ID or project name
:param int configuration_id:
:rtype: :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>`
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
if configuration_id is not None:
route_values['configurationId'] = self._serialize.url('configuration_id', configuration_id, 'int')
content = self._serialize.body(configuration, 'PolicyConfiguration')
response = self._send(http_method='POST',
location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
version='5.1',
route_values=route_values,
content=content)
return self._deserialize('PolicyConfiguration', response)
def delete_policy_configuration(self, project, configuration_id):
"""DeletePolicyConfiguration.
Delete a policy configuration by its ID.
:param str project: Project ID or project name
:param int configuration_id: ID of the policy configuration to delete.
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
if configuration_id is not None:
route_values['configurationId'] = self._serialize.url('configuration_id', configuration_id, 'int')
self._send(http_method='DELETE',
location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
version='5.1',
route_values=route_values)
def get_policy_configuration(self, project, configuration_id):
"""GetPolicyConfiguration.
Get a policy configuration by its ID.
:param str project: Project ID or project name
:param int configuration_id: ID of the policy configuration
:rtype: :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>`
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
if configuration_id is not None:
route_values['configurationId'] = self._serialize.url('configuration_id', configuration_id, 'int')
response = self._send(http_method='GET',
location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
version='5.1',
route_values=route_values)
return self._deserialize('PolicyConfiguration', response)
def get_policy_configurations(self, project, scope=None, top=None, continuation_token=None, policy_type=None):
"""GetPolicyConfigurations.
Get a list of policy configurations in a project.
:param str project: Project ID or project name
:param str scope: [Provided for legacy reasons] The scope on which a subset of policies is defined.
:param int top: Maximum number of policies to return.
:param str continuation_token: The continuation token used for pagination.
:param str policy_type: Filter returned policies to only this type
:rtype: :class:`<GetPolicyConfigurationsResponseValue>`
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
query_parameters = {}
if scope is not None:
query_parameters['scope'] = self._serialize.query('scope', scope, 'str')
if top is not None:
query_parameters['$top'] = self._serialize.query('top', top, 'int')
if continuation_token is not None:
query_parameters['continuationToken'] = self._serialize.query('continuation_token', continuation_token, 'str')
if policy_type is not None:
query_parameters['policyType'] = self._serialize.query('policy_type', policy_type, 'str')
response = self._send(http_method='GET',
location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
version='5.1',
route_values=route_values,
query_parameters=query_parameters)
response_value = self._deserialize('[PolicyConfiguration]', self._unwrap_collection(response))
continuation_token = self._get_continuation_token(response)
return self.GetPolicyConfigurationsResponseValue(response_value, continuation_token)
class GetPolicyConfigurationsResponseValue(object):
def __init__(self, value, continuation_token):
"""
Response for the get_policy_configurations method
:param value:
:type value: :class:`<[PolicyConfiguration]> <azure.devops.v5_1.policy.models.[PolicyConfiguration]>`
:param continuation_token: The continuation token to be used to get the next page of results.
:type continuation_token: str
"""
self.value = value
self.continuation_token = continuation_token
def update_policy_configuration(self, configuration, project, configuration_id):
"""UpdatePolicyConfiguration.
Update a policy configuration by its ID.
:param :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>` configuration: The policy configuration to update.
:param str project: Project ID or project name
:param int configuration_id: ID of the existing policy configuration to be updated.
:rtype: :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>`
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
if configuration_id is not None:
route_values['configurationId'] = self._serialize.url('configuration_id', configuration_id, 'int')
content = self._serialize.body(configuration, 'PolicyConfiguration')
response = self._send(http_method='PUT',
location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
version='5.1',
route_values=route_values,
content=content)
return self._deserialize('PolicyConfiguration', response)
def get_policy_configuration_revision(self, project, configuration_id, revision_id):
"""GetPolicyConfigurationRevision.
Retrieve a specific revision of a given policy by ID.
:param str project: Project ID or project name
:param int configuration_id: The policy configuration ID.
:param int revision_id: The revision ID.
:rtype: :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>`
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
if configuration_id is not None:
route_values['configurationId'] = self._serialize.url('configuration_id', configuration_id, 'int')
if revision_id is not None:
route_values['revisionId'] = self._serialize.url('revision_id', revision_id, 'int')
response = self._send(http_method='GET',
location_id='fe1e68a2-60d3-43cb-855b-85e41ae97c95',
version='5.1',
route_values=route_values)
return self._deserialize('PolicyConfiguration', response)
def get_policy_configuration_revisions(self, project, configuration_id, top=None, skip=None):
"""GetPolicyConfigurationRevisions.
Retrieve all revisions for a given policy.
:param str project: Project ID or project name
:param int configuration_id: The policy configuration ID.
:param int top: The number of revisions to retrieve.
:param int skip: The number of revisions to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.
:rtype: [PolicyConfiguration]
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
if configuration_id is not None:
route_values['configurationId'] = self._serialize.url('configuration_id', configuration_id, 'int')
query_parameters = {}
if top is not None:
query_parameters['$top'] = self._serialize.query('top', top, 'int')
if skip is not None:
query_parameters['$skip'] = self._serialize.query('skip', skip, 'int')
response = self._send(http_method='GET',
location_id='fe1e68a2-60d3-43cb-855b-85e41ae97c95',
version='5.1',
route_values=route_values,
query_parameters=query_parameters)
return self._deserialize('[PolicyConfiguration]', self._unwrap_collection(response))
def get_policy_type(self, project, type_id):
"""GetPolicyType.
Retrieve a specific policy type by ID.
:param str project: Project ID or project name
:param str type_id: The policy ID.
:rtype: :class:`<PolicyType> <azure.devops.v5_1.policy.models.PolicyType>`
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
if type_id is not None:
route_values['typeId'] = self._serialize.url('type_id', type_id, 'str')
response = self._send(http_method='GET',
location_id='44096322-2d3d-466a-bb30-d1b7de69f61f',
version='5.1',
route_values=route_values)
return self._deserialize('PolicyType', response)
def get_policy_types(self, project):
"""GetPolicyTypes.
Retrieve all available policy types.
:param str project: Project ID or project name
:rtype: [PolicyType]
"""
route_values = {}
if project is not None:
route_values['project'] = self._serialize.url('project', project, 'str')
response = self._send(http_method='GET',
location_id='44096322-2d3d-466a-bb30-d1b7de69f61f',
version='5.1',
route_values=route_values)
return self._deserialize('[PolicyType]', self._unwrap_collection(response))
|