1# coding=utf-8
2# --------------------------------------------------------------------------
3# Copyright (c) Microsoft Corporation. All rights reserved.
4# Licensed under the MIT License. See License.txt in the project root for
5# license information.
6#
7# Code generated by Microsoft (R) AutoRest Code Generator.
8# Changes may cause incorrect behavior and will be lost if the code is
9# regenerated.
10# --------------------------------------------------------------------------
11
12import uuid
13from msrest.pipeline import ClientRawResponse
14
15from .. import models
16
17
18class ApplicationsOperations(object):
19    """ApplicationsOperations operations.
20
21    :param client: Client for service requests.
22    :param config: Configuration of service client.
23    :param serializer: An object model serializer.
24    :param deserializer: An object model deserializer.
25    :ivar api_version: Client API version. Constant value: "1.6".
26    """
27
28    models = models
29
30    def __init__(self, client, config, serializer, deserializer):
31
32        self._client = client
33        self._serialize = serializer
34        self._deserialize = deserializer
35        self.api_version = "1.6"
36
37        self.config = config
38
39    def create(
40            self, parameters, custom_headers=None, raw=False, **operation_config):
41        """Create a new application.
42
43        :param parameters: The parameters for creating an application.
44        :type parameters: ~azure.graphrbac.models.ApplicationCreateParameters
45        :param dict custom_headers: headers that will be added to the request
46        :param bool raw: returns the direct response alongside the
47         deserialized response
48        :param operation_config: :ref:`Operation configuration
49         overrides<msrest:optionsforoperations>`.
50        :return: Application or ClientRawResponse if raw=true
51        :rtype: ~azure.graphrbac.models.Application or
52         ~msrest.pipeline.ClientRawResponse
53        :raises:
54         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
55        """
56        # Construct URL
57        url = self.create.metadata['url']
58        path_format_arguments = {
59            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
60        }
61        url = self._client.format_url(url, **path_format_arguments)
62
63        # Construct parameters
64        query_parameters = {}
65        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
66
67        # Construct headers
68        header_parameters = {}
69        header_parameters['Accept'] = 'application/json'
70        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
71        if self.config.generate_client_request_id:
72            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
73        if custom_headers:
74            header_parameters.update(custom_headers)
75        if self.config.accept_language is not None:
76            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
77
78        # Construct body
79        body_content = self._serialize.body(parameters, 'ApplicationCreateParameters')
80
81        # Construct and send request
82        request = self._client.post(url, query_parameters, header_parameters, body_content)
83        response = self._client.send(request, stream=False, **operation_config)
84
85        if response.status_code not in [201]:
86            raise models.GraphErrorException(self._deserialize, response)
87
88        deserialized = None
89
90        if response.status_code == 201:
91            deserialized = self._deserialize('Application', response)
92
93        if raw:
94            client_raw_response = ClientRawResponse(deserialized, response)
95            return client_raw_response
96
97        return deserialized
98    create.metadata = {'url': '/{tenantID}/applications'}
99
100    def list(
101            self, filter=None, custom_headers=None, raw=False, **operation_config):
102        """Lists applications by filter parameters.
103
104        :param filter: The filters to apply to the operation.
105        :type filter: str
106        :param dict custom_headers: headers that will be added to the request
107        :param bool raw: returns the direct response alongside the
108         deserialized response
109        :param operation_config: :ref:`Operation configuration
110         overrides<msrest:optionsforoperations>`.
111        :return: An iterator like instance of Application
112        :rtype:
113         ~azure.graphrbac.models.ApplicationPaged[~azure.graphrbac.models.Application]
114        :raises:
115         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
116        """
117        def internal_paging(next_link=None, raw=False):
118
119            if not next_link:
120                # Construct URL
121                url = self.list.metadata['url']
122                path_format_arguments = {
123                    'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
124                }
125                url = self._client.format_url(url, **path_format_arguments)
126
127                # Construct parameters
128                query_parameters = {}
129                if filter is not None:
130                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
131                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
132
133            else:
134                url = '/{tenantID}/{nextLink}'
135                path_format_arguments = {
136                    'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True),
137                    'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
138                }
139                url = self._client.format_url(url, **path_format_arguments)
140                query_parameters = {}
141                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
142
143            # Construct headers
144            header_parameters = {}
145            header_parameters['Accept'] = 'application/json'
146            if self.config.generate_client_request_id:
147                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
148            if custom_headers:
149                header_parameters.update(custom_headers)
150            if self.config.accept_language is not None:
151                header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
152
153            # Construct and send request
154            request = self._client.get(url, query_parameters, header_parameters)
155            response = self._client.send(request, stream=False, **operation_config)
156
157            if response.status_code not in [200]:
158                raise models.GraphErrorException(self._deserialize, response)
159
160            return response
161
162        # Deserialize response
163        deserialized = models.ApplicationPaged(internal_paging, self._deserialize.dependencies)
164
165        if raw:
166            header_dict = {}
167            client_raw_response = models.ApplicationPaged(internal_paging, self._deserialize.dependencies, header_dict)
168            return client_raw_response
169
170        return deserialized
171    list.metadata = {'url': '/{tenantID}/applications'}
172
173    def delete(
174            self, application_object_id, custom_headers=None, raw=False, **operation_config):
175        """Delete an application.
176
177        :param application_object_id: Application object ID.
178        :type application_object_id: str
179        :param dict custom_headers: headers that will be added to the request
180        :param bool raw: returns the direct response alongside the
181         deserialized response
182        :param operation_config: :ref:`Operation configuration
183         overrides<msrest:optionsforoperations>`.
184        :return: None or ClientRawResponse if raw=true
185        :rtype: None or ~msrest.pipeline.ClientRawResponse
186        :raises:
187         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
188        """
189        # Construct URL
190        url = self.delete.metadata['url']
191        path_format_arguments = {
192            'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
193            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
194        }
195        url = self._client.format_url(url, **path_format_arguments)
196
197        # Construct parameters
198        query_parameters = {}
199        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
200
201        # Construct headers
202        header_parameters = {}
203        if self.config.generate_client_request_id:
204            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
205        if custom_headers:
206            header_parameters.update(custom_headers)
207        if self.config.accept_language is not None:
208            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
209
210        # Construct and send request
211        request = self._client.delete(url, query_parameters, header_parameters)
212        response = self._client.send(request, stream=False, **operation_config)
213
214        if response.status_code not in [204]:
215            raise models.GraphErrorException(self._deserialize, response)
216
217        if raw:
218            client_raw_response = ClientRawResponse(None, response)
219            return client_raw_response
220    delete.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}'}
221
222    def get(
223            self, application_object_id, custom_headers=None, raw=False, **operation_config):
224        """Get an application by object ID.
225
226        :param application_object_id: Application object ID.
227        :type application_object_id: str
228        :param dict custom_headers: headers that will be added to the request
229        :param bool raw: returns the direct response alongside the
230         deserialized response
231        :param operation_config: :ref:`Operation configuration
232         overrides<msrest:optionsforoperations>`.
233        :return: Application or ClientRawResponse if raw=true
234        :rtype: ~azure.graphrbac.models.Application or
235         ~msrest.pipeline.ClientRawResponse
236        :raises:
237         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
238        """
239        # Construct URL
240        url = self.get.metadata['url']
241        path_format_arguments = {
242            'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
243            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
244        }
245        url = self._client.format_url(url, **path_format_arguments)
246
247        # Construct parameters
248        query_parameters = {}
249        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
250
251        # Construct headers
252        header_parameters = {}
253        header_parameters['Accept'] = 'application/json'
254        if self.config.generate_client_request_id:
255            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
256        if custom_headers:
257            header_parameters.update(custom_headers)
258        if self.config.accept_language is not None:
259            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
260
261        # Construct and send request
262        request = self._client.get(url, query_parameters, header_parameters)
263        response = self._client.send(request, stream=False, **operation_config)
264
265        if response.status_code not in [200]:
266            raise models.GraphErrorException(self._deserialize, response)
267
268        deserialized = None
269
270        if response.status_code == 200:
271            deserialized = self._deserialize('Application', response)
272
273        if raw:
274            client_raw_response = ClientRawResponse(deserialized, response)
275            return client_raw_response
276
277        return deserialized
278    get.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}'}
279
280    def patch(
281            self, application_object_id, parameters, custom_headers=None, raw=False, **operation_config):
282        """Update an existing application.
283
284        :param application_object_id: Application object ID.
285        :type application_object_id: str
286        :param parameters: Parameters to update an existing application.
287        :type parameters: ~azure.graphrbac.models.ApplicationUpdateParameters
288        :param dict custom_headers: headers that will be added to the request
289        :param bool raw: returns the direct response alongside the
290         deserialized response
291        :param operation_config: :ref:`Operation configuration
292         overrides<msrest:optionsforoperations>`.
293        :return: None or ClientRawResponse if raw=true
294        :rtype: None or ~msrest.pipeline.ClientRawResponse
295        :raises:
296         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
297        """
298        # Construct URL
299        url = self.patch.metadata['url']
300        path_format_arguments = {
301            'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
302            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
303        }
304        url = self._client.format_url(url, **path_format_arguments)
305
306        # Construct parameters
307        query_parameters = {}
308        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
309
310        # Construct headers
311        header_parameters = {}
312        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
313        if self.config.generate_client_request_id:
314            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
315        if custom_headers:
316            header_parameters.update(custom_headers)
317        if self.config.accept_language is not None:
318            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
319
320        # Construct body
321        body_content = self._serialize.body(parameters, 'ApplicationUpdateParameters')
322
323        # Construct and send request
324        request = self._client.patch(url, query_parameters, header_parameters, body_content)
325        response = self._client.send(request, stream=False, **operation_config)
326
327        if response.status_code not in [204]:
328            raise models.GraphErrorException(self._deserialize, response)
329
330        if raw:
331            client_raw_response = ClientRawResponse(None, response)
332            return client_raw_response
333    patch.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}'}
334
335    def list_owners(
336            self, application_object_id, custom_headers=None, raw=False, **operation_config):
337        """Directory objects that are owners of the application.
338
339        The owners are a set of non-admin users who are allowed to modify this
340        object.
341
342        :param application_object_id: The object ID of the application for
343         which to get owners.
344        :type application_object_id: str
345        :param dict custom_headers: headers that will be added to the request
346        :param bool raw: returns the direct response alongside the
347         deserialized response
348        :param operation_config: :ref:`Operation configuration
349         overrides<msrest:optionsforoperations>`.
350        :return: An iterator like instance of DirectoryObject
351        :rtype:
352         ~azure.graphrbac.models.DirectoryObjectPaged[~azure.graphrbac.models.DirectoryObject]
353        :raises:
354         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
355        """
356        def internal_paging(next_link=None, raw=False):
357
358            if not next_link:
359                # Construct URL
360                url = self.list_owners.metadata['url']
361                path_format_arguments = {
362                    'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
363                    'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
364                }
365                url = self._client.format_url(url, **path_format_arguments)
366
367                # Construct parameters
368                query_parameters = {}
369                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
370
371            else:
372                url = next_link
373                query_parameters = {}
374
375            # Construct headers
376            header_parameters = {}
377            header_parameters['Accept'] = 'application/json'
378            if self.config.generate_client_request_id:
379                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
380            if custom_headers:
381                header_parameters.update(custom_headers)
382            if self.config.accept_language is not None:
383                header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
384
385            # Construct and send request
386            request = self._client.get(url, query_parameters, header_parameters)
387            response = self._client.send(request, stream=False, **operation_config)
388
389            if response.status_code not in [200]:
390                raise models.GraphErrorException(self._deserialize, response)
391
392            return response
393
394        # Deserialize response
395        deserialized = models.DirectoryObjectPaged(internal_paging, self._deserialize.dependencies)
396
397        if raw:
398            header_dict = {}
399            client_raw_response = models.DirectoryObjectPaged(internal_paging, self._deserialize.dependencies, header_dict)
400            return client_raw_response
401
402        return deserialized
403    list_owners.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/owners'}
404
405    def add_owner(
406            self, application_object_id, url, additional_properties=None, custom_headers=None, raw=False, **operation_config):
407        """Add an owner to an application.
408
409        :param application_object_id: The object ID of the application to
410         which to add the owner.
411        :type application_object_id: str
412        :param url: A owner object URL, such as
413         "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd",
414         where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and
415         "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the owner
416         (user, application, servicePrincipal, group) to be added.
417        :type url: str
418        :param additional_properties: Unmatched properties from the message
419         are deserialized this collection
420        :type additional_properties: dict[str, object]
421        :param dict custom_headers: headers that will be added to the request
422        :param bool raw: returns the direct response alongside the
423         deserialized response
424        :param operation_config: :ref:`Operation configuration
425         overrides<msrest:optionsforoperations>`.
426        :return: None or ClientRawResponse if raw=true
427        :rtype: None or ~msrest.pipeline.ClientRawResponse
428        :raises:
429         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
430        """
431        parameters = models.AddOwnerParameters(additional_properties=additional_properties, url=url)
432
433        # Construct URL
434        url = self.add_owner.metadata['url']
435        path_format_arguments = {
436            'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
437            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
438        }
439        url = self._client.format_url(url, **path_format_arguments)
440
441        # Construct parameters
442        query_parameters = {}
443        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
444
445        # Construct headers
446        header_parameters = {}
447        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
448        if self.config.generate_client_request_id:
449            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
450        if custom_headers:
451            header_parameters.update(custom_headers)
452        if self.config.accept_language is not None:
453            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
454
455        # Construct body
456        body_content = self._serialize.body(parameters, 'AddOwnerParameters')
457
458        # Construct and send request
459        request = self._client.post(url, query_parameters, header_parameters, body_content)
460        response = self._client.send(request, stream=False, **operation_config)
461
462        if response.status_code not in [204]:
463            raise models.GraphErrorException(self._deserialize, response)
464
465        if raw:
466            client_raw_response = ClientRawResponse(None, response)
467            return client_raw_response
468    add_owner.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/$links/owners'}
469
470    def remove_owner(
471            self, application_object_id, owner_object_id, custom_headers=None, raw=False, **operation_config):
472        """Remove a member from owners.
473
474        :param application_object_id: The object ID of the application from
475         which to remove the owner.
476        :type application_object_id: str
477        :param owner_object_id: Owner object id
478        :type owner_object_id: str
479        :param dict custom_headers: headers that will be added to the request
480        :param bool raw: returns the direct response alongside the
481         deserialized response
482        :param operation_config: :ref:`Operation configuration
483         overrides<msrest:optionsforoperations>`.
484        :return: None or ClientRawResponse if raw=true
485        :rtype: None or ~msrest.pipeline.ClientRawResponse
486        :raises:
487         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
488        """
489        # Construct URL
490        url = self.remove_owner.metadata['url']
491        path_format_arguments = {
492            'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
493            'ownerObjectId': self._serialize.url("owner_object_id", owner_object_id, 'str'),
494            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
495        }
496        url = self._client.format_url(url, **path_format_arguments)
497
498        # Construct parameters
499        query_parameters = {}
500        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
501
502        # Construct headers
503        header_parameters = {}
504        if self.config.generate_client_request_id:
505            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
506        if custom_headers:
507            header_parameters.update(custom_headers)
508        if self.config.accept_language is not None:
509            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
510
511        # Construct and send request
512        request = self._client.delete(url, query_parameters, header_parameters)
513        response = self._client.send(request, stream=False, **operation_config)
514
515        if response.status_code not in [204]:
516            raise models.GraphErrorException(self._deserialize, response)
517
518        if raw:
519            client_raw_response = ClientRawResponse(None, response)
520            return client_raw_response
521    remove_owner.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/$links/owners/{ownerObjectId}'}
522
523    def list_key_credentials(
524            self, application_object_id, custom_headers=None, raw=False, **operation_config):
525        """Get the keyCredentials associated with an application.
526
527        :param application_object_id: Application object ID.
528        :type application_object_id: str
529        :param dict custom_headers: headers that will be added to the request
530        :param bool raw: returns the direct response alongside the
531         deserialized response
532        :param operation_config: :ref:`Operation configuration
533         overrides<msrest:optionsforoperations>`.
534        :return: An iterator like instance of KeyCredential
535        :rtype:
536         ~azure.graphrbac.models.KeyCredentialPaged[~azure.graphrbac.models.KeyCredential]
537        :raises:
538         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
539        """
540        def internal_paging(next_link=None, raw=False):
541
542            if not next_link:
543                # Construct URL
544                url = self.list_key_credentials.metadata['url']
545                path_format_arguments = {
546                    'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
547                    'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
548                }
549                url = self._client.format_url(url, **path_format_arguments)
550
551                # Construct parameters
552                query_parameters = {}
553                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
554
555            else:
556                url = next_link
557                query_parameters = {}
558
559            # Construct headers
560            header_parameters = {}
561            header_parameters['Accept'] = 'application/json'
562            if self.config.generate_client_request_id:
563                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
564            if custom_headers:
565                header_parameters.update(custom_headers)
566            if self.config.accept_language is not None:
567                header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
568
569            # Construct and send request
570            request = self._client.get(url, query_parameters, header_parameters)
571            response = self._client.send(request, stream=False, **operation_config)
572
573            if response.status_code not in [200]:
574                raise models.GraphErrorException(self._deserialize, response)
575
576            return response
577
578        # Deserialize response
579        deserialized = models.KeyCredentialPaged(internal_paging, self._deserialize.dependencies)
580
581        if raw:
582            header_dict = {}
583            client_raw_response = models.KeyCredentialPaged(internal_paging, self._deserialize.dependencies, header_dict)
584            return client_raw_response
585
586        return deserialized
587    list_key_credentials.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/keyCredentials'}
588
589    def update_key_credentials(
590            self, application_object_id, value, custom_headers=None, raw=False, **operation_config):
591        """Update the keyCredentials associated with an application.
592
593        :param application_object_id: Application object ID.
594        :type application_object_id: str
595        :param value: A collection of KeyCredentials.
596        :type value: list[~azure.graphrbac.models.KeyCredential]
597        :param dict custom_headers: headers that will be added to the request
598        :param bool raw: returns the direct response alongside the
599         deserialized response
600        :param operation_config: :ref:`Operation configuration
601         overrides<msrest:optionsforoperations>`.
602        :return: None or ClientRawResponse if raw=true
603        :rtype: None or ~msrest.pipeline.ClientRawResponse
604        :raises:
605         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
606        """
607        parameters = models.KeyCredentialsUpdateParameters(value=value)
608
609        # Construct URL
610        url = self.update_key_credentials.metadata['url']
611        path_format_arguments = {
612            'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
613            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
614        }
615        url = self._client.format_url(url, **path_format_arguments)
616
617        # Construct parameters
618        query_parameters = {}
619        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
620
621        # Construct headers
622        header_parameters = {}
623        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
624        if self.config.generate_client_request_id:
625            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
626        if custom_headers:
627            header_parameters.update(custom_headers)
628        if self.config.accept_language is not None:
629            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
630
631        # Construct body
632        body_content = self._serialize.body(parameters, 'KeyCredentialsUpdateParameters')
633
634        # Construct and send request
635        request = self._client.patch(url, query_parameters, header_parameters, body_content)
636        response = self._client.send(request, stream=False, **operation_config)
637
638        if response.status_code not in [204]:
639            raise models.GraphErrorException(self._deserialize, response)
640
641        if raw:
642            client_raw_response = ClientRawResponse(None, response)
643            return client_raw_response
644    update_key_credentials.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/keyCredentials'}
645
646    def list_password_credentials(
647            self, application_object_id, custom_headers=None, raw=False, **operation_config):
648        """Get the passwordCredentials associated with an application.
649
650        :param application_object_id: Application object ID.
651        :type application_object_id: str
652        :param dict custom_headers: headers that will be added to the request
653        :param bool raw: returns the direct response alongside the
654         deserialized response
655        :param operation_config: :ref:`Operation configuration
656         overrides<msrest:optionsforoperations>`.
657        :return: An iterator like instance of PasswordCredential
658        :rtype:
659         ~azure.graphrbac.models.PasswordCredentialPaged[~azure.graphrbac.models.PasswordCredential]
660        :raises:
661         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
662        """
663        def internal_paging(next_link=None, raw=False):
664
665            if not next_link:
666                # Construct URL
667                url = self.list_password_credentials.metadata['url']
668                path_format_arguments = {
669                    'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
670                    'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
671                }
672                url = self._client.format_url(url, **path_format_arguments)
673
674                # Construct parameters
675                query_parameters = {}
676                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
677
678            else:
679                url = next_link
680                query_parameters = {}
681
682            # Construct headers
683            header_parameters = {}
684            header_parameters['Accept'] = 'application/json'
685            if self.config.generate_client_request_id:
686                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
687            if custom_headers:
688                header_parameters.update(custom_headers)
689            if self.config.accept_language is not None:
690                header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
691
692            # Construct and send request
693            request = self._client.get(url, query_parameters, header_parameters)
694            response = self._client.send(request, stream=False, **operation_config)
695
696            if response.status_code not in [200]:
697                raise models.GraphErrorException(self._deserialize, response)
698
699            return response
700
701        # Deserialize response
702        deserialized = models.PasswordCredentialPaged(internal_paging, self._deserialize.dependencies)
703
704        if raw:
705            header_dict = {}
706            client_raw_response = models.PasswordCredentialPaged(internal_paging, self._deserialize.dependencies, header_dict)
707            return client_raw_response
708
709        return deserialized
710    list_password_credentials.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/passwordCredentials'}
711
712    def update_password_credentials(
713            self, application_object_id, value, custom_headers=None, raw=False, **operation_config):
714        """Update passwordCredentials associated with an application.
715
716        :param application_object_id: Application object ID.
717        :type application_object_id: str
718        :param value: A collection of PasswordCredentials.
719        :type value: list[~azure.graphrbac.models.PasswordCredential]
720        :param dict custom_headers: headers that will be added to the request
721        :param bool raw: returns the direct response alongside the
722         deserialized response
723        :param operation_config: :ref:`Operation configuration
724         overrides<msrest:optionsforoperations>`.
725        :return: None or ClientRawResponse if raw=true
726        :rtype: None or ~msrest.pipeline.ClientRawResponse
727        :raises:
728         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
729        """
730        parameters = models.PasswordCredentialsUpdateParameters(value=value)
731
732        # Construct URL
733        url = self.update_password_credentials.metadata['url']
734        path_format_arguments = {
735            'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'),
736            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str')
737        }
738        url = self._client.format_url(url, **path_format_arguments)
739
740        # Construct parameters
741        query_parameters = {}
742        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
743
744        # Construct headers
745        header_parameters = {}
746        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
747        if self.config.generate_client_request_id:
748            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
749        if custom_headers:
750            header_parameters.update(custom_headers)
751        if self.config.accept_language is not None:
752            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
753
754        # Construct body
755        body_content = self._serialize.body(parameters, 'PasswordCredentialsUpdateParameters')
756
757        # Construct and send request
758        request = self._client.patch(url, query_parameters, header_parameters, body_content)
759        response = self._client.send(request, stream=False, **operation_config)
760
761        if response.status_code not in [204]:
762            raise models.GraphErrorException(self._deserialize, response)
763
764        if raw:
765            client_raw_response = ClientRawResponse(None, response)
766            return client_raw_response
767    update_password_credentials.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/passwordCredentials'}
768
769    def get_service_principals_id_by_app_id(
770            self, application_id, custom_headers=None, raw=False, **operation_config):
771        """Gets an object id for a given application id from the current tenant.
772
773        :param application_id: The application ID.
774        :type application_id: str
775        :param dict custom_headers: headers that will be added to the request
776        :param bool raw: returns the direct response alongside the
777         deserialized response
778        :param operation_config: :ref:`Operation configuration
779         overrides<msrest:optionsforoperations>`.
780        :return: ServicePrincipalObjectResult or ClientRawResponse if raw=true
781        :rtype: ~azure.graphrbac.models.ServicePrincipalObjectResult or
782         ~msrest.pipeline.ClientRawResponse
783        :raises:
784         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
785        """
786        # Construct URL
787        url = self.get_service_principals_id_by_app_id.metadata['url']
788        path_format_arguments = {
789            'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str'),
790            'applicationID': self._serialize.url("application_id", application_id, 'str')
791        }
792        url = self._client.format_url(url, **path_format_arguments)
793
794        # Construct parameters
795        query_parameters = {}
796        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
797
798        # Construct headers
799        header_parameters = {}
800        header_parameters['Accept'] = 'application/json'
801        if self.config.generate_client_request_id:
802            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
803        if custom_headers:
804            header_parameters.update(custom_headers)
805        if self.config.accept_language is not None:
806            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
807
808        # Construct and send request
809        request = self._client.get(url, query_parameters, header_parameters)
810        response = self._client.send(request, stream=False, **operation_config)
811
812        if response.status_code not in [200]:
813            raise models.GraphErrorException(self._deserialize, response)
814
815        deserialized = None
816
817        if response.status_code == 200:
818            deserialized = self._deserialize('ServicePrincipalObjectResult', response)
819
820        if raw:
821            client_raw_response = ClientRawResponse(deserialized, response)
822            return client_raw_response
823
824        return deserialized
825    get_service_principals_id_by_app_id.metadata = {'url': '/{tenantID}/servicePrincipalsByAppId/{applicationID}/objectId'}
826